@qntx/wallet-native 0.12.0 → 0.14.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.
- package/README.md +184 -31
- package/WalletNative.podspec +11 -2
- package/android/CMakeLists.txt +7 -1
- package/android/build.gradle +4 -0
- package/android/src/main/AndroidManifest.xml +1 -2
- package/android/src/main/cpp/cpp-adapter.cpp +9 -0
- package/android/src/main/java/com/margelo/nitro/qntxwallet/CardReader.kt +316 -0
- package/android/src/main/java/com/margelo/nitro/qntxwallet/HybridGoogleDriveAuth.kt +142 -0
- package/android/src/main/java/com/margelo/nitro/qntxwallet/HybridSecureInputView.kt +25 -0
- package/android/src/main/java/com/margelo/nitro/qntxwallet/Keystore.kt +148 -9
- package/android/src/main/java/com/margelo/nitro/qntxwallet/SecureInputField.kt +422 -0
- package/android/src/main/java/com/margelo/nitro/qntxwallet/VaultAnchor.kt +90 -0
- package/android/src/main/java/com/margelo/nitro/qntxwallet/WalletNativePackage.java +10 -0
- package/cpp/host/CardReader.hpp +70 -0
- package/cpp/host/HybridKernelHost.cpp +90 -15
- package/cpp/host/HybridKernelHost.hpp +21 -5
- package/cpp/host/KernelFile.cpp +79 -15
- package/cpp/host/KernelFile.hpp +17 -6
- package/cpp/host/KernelSlot.hpp +103 -0
- package/cpp/host/Keystore.hpp +35 -11
- package/cpp/host/Lifecycle.cpp +11 -0
- package/cpp/host/Lifecycle.hpp +3 -0
- package/cpp/host/Passkey.hpp +8 -0
- package/cpp/host/SecureInput.cpp +233 -0
- package/cpp/host/SecureInput.hpp +103 -0
- package/cpp/host/VaultAnchor.cpp +39 -0
- package/cpp/host/VaultAnchor.hpp +28 -0
- package/cpp/host/VaultDirectory.hpp +1 -1
- package/cpp/platform/CardReaderAndroid.cpp +146 -0
- package/cpp/platform/CardReaderIos.mm +318 -0
- package/cpp/platform/KeystoreAndroid.cpp +48 -1
- package/cpp/platform/KeystoreIos.mm +109 -19
- package/cpp/platform/PasskeyAndroid.cpp +2 -0
- package/cpp/platform/PasskeyIos.mm +20 -18
- package/cpp/platform/QntxSecureInputField.h +24 -0
- package/cpp/platform/SecureInputAndroid.cpp +110 -0
- package/cpp/platform/SecureInputIos.mm +282 -0
- package/cpp/platform/VaultAnchorAndroid.cpp +76 -0
- package/cpp/platform/VaultAnchorIos.mm +76 -0
- package/cpp/runtime/KernelBackends.cpp +35 -28
- package/cpp/runtime/KernelBuffer.hpp +2 -5
- package/cpp/runtime/KernelCardReader.cpp +385 -0
- package/cpp/runtime/KernelCardReader.hpp +27 -0
- package/cpp/runtime/KernelGlobals.cpp +176 -63
- package/cpp/runtime/KernelGlobals.hpp +13 -7
- package/cpp/runtime/KernelJs.cpp +14 -0
- package/cpp/runtime/KernelJs.hpp +4 -0
- package/cpp/runtime/KernelKeystore.cpp +78 -2
- package/cpp/runtime/KernelKeystore.hpp +1 -0
- package/cpp/runtime/KernelPasskey.cpp +15 -12
- package/cpp/runtime/KernelRuntime.cpp +24 -7
- package/cpp/runtime/KernelRuntime.hpp +14 -6
- package/cpp/runtime/KernelSecureInput.cpp +154 -0
- package/cpp/runtime/KernelSecureInput.hpp +25 -0
- package/cpp/runtime/platform/KernelArgon2.cpp +34 -0
- package/cpp/runtime/platform/KernelArgon2.hpp +23 -0
- package/cpp/vendor/argon2/LICENSE +314 -0
- package/cpp/vendor/argon2/README.md +20 -0
- package/cpp/vendor/argon2/include/argon2.h +437 -0
- package/cpp/vendor/argon2/src/argon2.c +452 -0
- package/cpp/vendor/argon2/src/blake2/blake2-impl.h +156 -0
- package/cpp/vendor/argon2/src/blake2/blake2.h +89 -0
- package/cpp/vendor/argon2/src/blake2/blake2b.c +390 -0
- package/cpp/vendor/argon2/src/blake2/blamka-round-ref.h +56 -0
- package/cpp/vendor/argon2/src/core.c +648 -0
- package/cpp/vendor/argon2/src/core.h +228 -0
- package/cpp/vendor/argon2/src/encoding.c +463 -0
- package/cpp/vendor/argon2/src/encoding.h +57 -0
- package/cpp/vendor/argon2/src/ref.c +194 -0
- package/cpp/vendor/argon2/src/thread.c +57 -0
- package/cpp/vendor/argon2/src/thread.h +67 -0
- package/dist/cloud.d.mts +58 -0
- package/dist/cloud.mjs +114 -0
- package/dist/cloud.mjs.map +1 -0
- package/dist/index.d.mts +13 -4
- package/dist/index.mjs +89 -14
- package/dist/index.mjs.map +1 -1
- package/dist/secure-input.d.mts +24 -0
- package/dist/secure-input.mjs +25 -0
- package/dist/secure-input.mjs.map +1 -0
- package/ios/HybridCloudKitStore.swift +159 -0
- package/ios/HybridSecureInputView.swift +35 -0
- package/ios/cloud/CloudKitEnvelopeStore.swift +179 -0
- package/kernel/generated/kernel-entry.js +51913 -20526
- package/kernel/generated/kernel.manifest.json +17 -7
- package/nitrogen/generated/android/WalletNative+autolinking.cmake +7 -1
- package/nitrogen/generated/android/WalletNativeOnLoad.cpp +37 -2
- package/nitrogen/generated/android/c++/JFunc_void_SecureInputState.hpp +77 -0
- package/nitrogen/generated/android/c++/JHybridGoogleDriveAuthSpec.cpp +82 -0
- package/nitrogen/generated/android/c++/JHybridGoogleDriveAuthSpec.hpp +64 -0
- package/nitrogen/generated/android/c++/JHybridSecureInputViewSpec.cpp +70 -0
- package/nitrogen/generated/android/c++/JHybridSecureInputViewSpec.hpp +64 -0
- package/nitrogen/generated/android/c++/JSecureInputState.hpp +64 -0
- package/nitrogen/generated/android/c++/views/JHybridSecureInputViewStateUpdater.cpp +74 -0
- package/nitrogen/generated/android/c++/views/JHybridSecureInputViewStateUpdater.hpp +54 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/qntxwallet/Func_void_SecureInputState.kt +78 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/qntxwallet/HybridGoogleDriveAuthSpec.kt +61 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/qntxwallet/HybridSecureInputViewSpec.kt +67 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/qntxwallet/SecureInputState.kt +25 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/qntxwallet/views/HybridSecureInputViewManager.kt +96 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/qntxwallet/views/HybridSecureInputViewStateUpdater.kt +23 -0
- package/nitrogen/generated/ios/WalletNative-Swift-Cxx-Bridge.cpp +74 -1
- package/nitrogen/generated/ios/WalletNative-Swift-Cxx-Bridge.hpp +252 -3
- package/nitrogen/generated/ios/WalletNative-Swift-Cxx-Umbrella.hpp +21 -3
- package/nitrogen/generated/ios/WalletNativeAutolinking.mm +17 -1
- package/nitrogen/generated/ios/WalletNativeAutolinking.swift +22 -0
- package/nitrogen/generated/ios/c++/HybridCloudKitStoreSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridCloudKitStoreSpecSwift.hpp +116 -0
- package/nitrogen/generated/ios/c++/HybridSecureInputViewSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridSecureInputViewSpecSwift.hpp +83 -0
- package/nitrogen/generated/ios/c++/views/HybridSecureInputViewComponent.mm +144 -0
- package/nitrogen/generated/ios/swift/Func_void.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_SecureInputState.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__optional_std__string_.swift +53 -0
- package/nitrogen/generated/ios/swift/Func_void_std__vector_std__string_.swift +46 -0
- package/nitrogen/generated/ios/swift/HybridCloudKitStoreSpec.swift +59 -0
- package/nitrogen/generated/ios/swift/HybridCloudKitStoreSpec_cxx.swift +230 -0
- package/nitrogen/generated/ios/swift/HybridSecureInputViewSpec.swift +55 -0
- package/nitrogen/generated/ios/swift/HybridSecureInputViewSpec_cxx.swift +164 -0
- package/nitrogen/generated/ios/swift/SecureInputState.swift +48 -0
- package/nitrogen/generated/shared/c++/HybridCloudKitStoreSpec.cpp +25 -0
- package/nitrogen/generated/shared/c++/HybridCloudKitStoreSpec.hpp +70 -0
- package/nitrogen/generated/shared/c++/HybridGoogleDriveAuthSpec.cpp +22 -0
- package/nitrogen/generated/shared/c++/HybridGoogleDriveAuthSpec.hpp +64 -0
- package/nitrogen/generated/shared/c++/HybridKernelHostSpec.cpp +1 -0
- package/nitrogen/generated/shared/c++/HybridKernelHostSpec.hpp +1 -0
- package/nitrogen/generated/shared/c++/HybridSecureInputViewSpec.cpp +22 -0
- package/nitrogen/generated/shared/c++/HybridSecureInputViewSpec.hpp +65 -0
- package/nitrogen/generated/shared/c++/SecureInputState.hpp +84 -0
- package/nitrogen/generated/shared/c++/views/HybridSecureInputViewComponent.cpp +34 -0
- package/nitrogen/generated/shared/c++/views/HybridSecureInputViewComponent.hpp +85 -0
- package/nitrogen/generated/shared/json/SecureInputViewConfig.json +10 -0
- package/package.json +24 -6
- package/scripts/compile-kernel.mjs +7 -3
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
// The iOS NFC reader: NFCTagReaderSession wrapped as a CardReader. The kernel
|
|
2
|
+
// sets the panel's alertMessage once at open; APDUs flow only between the
|
|
3
|
+
// kernel and this file. Delegate callbacks run on a private serial queue, so
|
|
4
|
+
// every piece of state is touched from that queue only. Nothing here logs a
|
|
5
|
+
// prompt, an APDU or a response.
|
|
6
|
+
#include "../host/CardReader.hpp"
|
|
7
|
+
|
|
8
|
+
#import <CoreNFC/CoreNFC.h>
|
|
9
|
+
#import <Foundation/Foundation.h>
|
|
10
|
+
|
|
11
|
+
#include <memory>
|
|
12
|
+
#include <optional>
|
|
13
|
+
#include <string>
|
|
14
|
+
#include <utility>
|
|
15
|
+
#include <vector>
|
|
16
|
+
|
|
17
|
+
namespace {
|
|
18
|
+
|
|
19
|
+
qntx::CardReaderStatus statusOf(NFCReaderError code) {
|
|
20
|
+
switch (code) {
|
|
21
|
+
case NFCReaderSessionInvalidationErrorUserCanceled:
|
|
22
|
+
return qntx::CardReaderStatus::cancelled;
|
|
23
|
+
case NFCReaderSessionInvalidationErrorSessionTimeout:
|
|
24
|
+
return qntx::CardReaderStatus::timeout;
|
|
25
|
+
case NFCReaderSessionInvalidationErrorSessionTerminatedUnexpectedly:
|
|
26
|
+
return qntx::CardReaderStatus::interrupted;
|
|
27
|
+
case NFCReaderSessionInvalidationErrorSystemIsBusy:
|
|
28
|
+
return qntx::CardReaderStatus::unavailable;
|
|
29
|
+
case NFCReaderTransceiveErrorTagConnectionLost:
|
|
30
|
+
case NFCReaderTransceiveErrorRetryExceeded:
|
|
31
|
+
case NFCReaderTransceiveErrorTagResponseError:
|
|
32
|
+
case NFCReaderTransceiveErrorTagNotConnected:
|
|
33
|
+
return qntx::CardReaderStatus::tagLost;
|
|
34
|
+
case NFCReaderTransceiveErrorSessionInvalidated:
|
|
35
|
+
// Our own invalidateSession; anything that reaches a caller here is
|
|
36
|
+
// already dropped by the kernel, so the mapped code only matters for
|
|
37
|
+
// the remembered session-end answer.
|
|
38
|
+
return qntx::CardReaderStatus::interrupted;
|
|
39
|
+
default:
|
|
40
|
+
return qntx::CardReaderStatus::unavailable;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
qntx::CardReaderResult resultOf(NSError* error) {
|
|
45
|
+
const auto status = statusOf(static_cast<NFCReaderError>(error.code));
|
|
46
|
+
return {status,
|
|
47
|
+
{},
|
|
48
|
+
std::string("NFCError:") + std::to_string(static_cast<long long>(error.code))};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
NSString* nsString(const std::string& text) {
|
|
52
|
+
return [[NSString alloc] initWithBytes:text.data()
|
|
53
|
+
length:text.size()
|
|
54
|
+
encoding:NSUTF8StringEncoding];
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
} // namespace
|
|
58
|
+
|
|
59
|
+
// Everything below runs on `_queue`, the private serial queue the session's
|
|
60
|
+
// delegate callbacks are delivered on — no locks needed.
|
|
61
|
+
@interface QntxNfcSession : NSObject <NFCTagReaderSessionDelegate>
|
|
62
|
+
|
|
63
|
+
- (instancetype)init;
|
|
64
|
+
- (void)openWithPrompt:(std::string)prompt done:(qntx::CardReaderDone)done;
|
|
65
|
+
- (void)transmitApdu:(std::vector<uint8_t>)apdu done:(qntx::CardReaderDone)done;
|
|
66
|
+
- (void)closeWithSuccess:(BOOL)success text:(std::string)text;
|
|
67
|
+
|
|
68
|
+
@end
|
|
69
|
+
|
|
70
|
+
@implementation QntxNfcSession {
|
|
71
|
+
dispatch_queue_t _queue;
|
|
72
|
+
NFCTagReaderSession* _session;
|
|
73
|
+
// A session close() invalidated that has not delivered didInvalidate yet —
|
|
74
|
+
// its delegate events must never touch `_session`, which may already be a
|
|
75
|
+
// newer session.
|
|
76
|
+
NFCTagReaderSession* _closing;
|
|
77
|
+
id<NFCISO7816Tag> _isoTag;
|
|
78
|
+
qntx::CardReaderDone _openDone;
|
|
79
|
+
qntx::CardReaderDone _txDone;
|
|
80
|
+
// A session is reusable only after didInvalidate arrived; an open that
|
|
81
|
+
// arrives before that waits here.
|
|
82
|
+
std::optional<std::pair<std::string, qntx::CardReaderDone>> _queuedOpen;
|
|
83
|
+
// A session-ending event with no in-flight call fails the next transmit.
|
|
84
|
+
std::optional<qntx::CardReaderResult> _ended;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
- (instancetype)init {
|
|
88
|
+
if (self = [super init]) {
|
|
89
|
+
_queue = dispatch_queue_create("org.qntx.wallet.nfc", DISPATCH_QUEUE_SERIAL);
|
|
90
|
+
}
|
|
91
|
+
return self;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
- (void)failAll:(qntx::CardReaderResult)result {
|
|
95
|
+
_ended = result;
|
|
96
|
+
auto openDone = std::move(_openDone);
|
|
97
|
+
_openDone = nullptr;
|
|
98
|
+
auto txDone = std::move(_txDone);
|
|
99
|
+
_txDone = nullptr;
|
|
100
|
+
if (openDone != nullptr) {
|
|
101
|
+
openDone(result);
|
|
102
|
+
}
|
|
103
|
+
if (txDone != nullptr) {
|
|
104
|
+
txDone(result);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
- (void)openWithPrompt:(std::string)prompt done:(qntx::CardReaderDone)done {
|
|
109
|
+
dispatch_async(_queue, ^{
|
|
110
|
+
if (!NFCTagReaderSession.readingAvailable) {
|
|
111
|
+
done({qntx::CardReaderStatus::unavailable, {}, "ios:nfc-unavailable"});
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
if (self->_queuedOpen.has_value()) {
|
|
115
|
+
// A contract violation: the kernel serializes opens, so this never
|
|
116
|
+
// fires — but the completion contract still must be kept.
|
|
117
|
+
done({qntx::CardReaderStatus::unavailable, {}, "ios:busy"});
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
if (self->_session != nil || self->_closing != nil) {
|
|
121
|
+
// didInvalidate has not arrived yet: a session cannot be reused or
|
|
122
|
+
// re-begun until it does (I8). Hold the open.
|
|
123
|
+
self->_queuedOpen = std::make_pair(std::move(prompt), std::move(done));
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
[self beginWithPrompt:std::move(prompt) done:std::move(done)];
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
- (void)beginWithPrompt:(std::string)prompt done:(qntx::CardReaderDone)done {
|
|
131
|
+
_ended = std::nullopt;
|
|
132
|
+
_isoTag = nil;
|
|
133
|
+
_openDone = std::move(done);
|
|
134
|
+
_session = [[NFCTagReaderSession alloc]
|
|
135
|
+
initWithPollingOption:NFCPollingISO14443
|
|
136
|
+
delegate:self
|
|
137
|
+
queue:_queue];
|
|
138
|
+
// The panel measures its label height once at begin (I1, I11): set the
|
|
139
|
+
// trusted text first and never rewrite it mid-session.
|
|
140
|
+
_session.alertMessage = nsString(prompt);
|
|
141
|
+
[_session beginSession];
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
- (void)transmitApdu:(std::vector<uint8_t>)apdu done:(qntx::CardReaderDone)done {
|
|
145
|
+
dispatch_async(_queue, ^{
|
|
146
|
+
if (self->_session == nil || self->_isoTag == nil) {
|
|
147
|
+
done(self->_ended.value_or(
|
|
148
|
+
qntx::CardReaderResult{qntx::CardReaderStatus::unavailable, {}, {}}));
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
if (self->_txDone != nullptr) {
|
|
152
|
+
done({qntx::CardReaderStatus::unavailable, {}, "ios:busy"});
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
NSData* data = [NSData dataWithBytes:apdu.data() length:apdu.size()];
|
|
156
|
+
NFCISO7816APDU* command = [[NFCISO7816APDU alloc] initWithData:data];
|
|
157
|
+
if (command == nil) {
|
|
158
|
+
done({qntx::CardReaderStatus::unavailable, {}, "qntx:bad-apdu"});
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
self->_txDone = std::move(done);
|
|
162
|
+
NFCTagReaderSession* session = self->_session;
|
|
163
|
+
id<NFCISO7816Tag> isoTag = self->_isoTag;
|
|
164
|
+
[isoTag sendCommandAPDU:command
|
|
165
|
+
completionHandler:^(NSData* _Nullable data, uint8_t sw1, uint8_t sw2,
|
|
166
|
+
NSError* _Nullable error) {
|
|
167
|
+
if (session != self->_session) {
|
|
168
|
+
// The call belonged to a session that close() already moved
|
|
169
|
+
// aside — its done was completed cancelled there.
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
auto txDone = std::move(self->_txDone);
|
|
173
|
+
self->_txDone = nullptr;
|
|
174
|
+
if (error != nil) {
|
|
175
|
+
// Every failure ends the session, silently.
|
|
176
|
+
auto result = resultOf(error);
|
|
177
|
+
[self->_session invalidateSession];
|
|
178
|
+
self->_isoTag = nil;
|
|
179
|
+
self->_ended = result;
|
|
180
|
+
txDone(result);
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
std::vector<uint8_t> response(
|
|
184
|
+
static_cast<const uint8_t*>(data.bytes),
|
|
185
|
+
static_cast<const uint8_t*>(data.bytes) + data.length);
|
|
186
|
+
response.push_back(sw1);
|
|
187
|
+
response.push_back(sw2);
|
|
188
|
+
txDone({qntx::CardReaderStatus::ok, std::move(response), {}});
|
|
189
|
+
}];
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
- (void)closeWithSuccess:(BOOL)success text:(std::string)text {
|
|
194
|
+
dispatch_async(_queue, ^{
|
|
195
|
+
auto queued = std::move(self->_queuedOpen);
|
|
196
|
+
self->_queuedOpen = std::nullopt;
|
|
197
|
+
if (queued.has_value() && queued->second != nullptr) {
|
|
198
|
+
queued->second({qntx::CardReaderStatus::cancelled, {}, {}});
|
|
199
|
+
}
|
|
200
|
+
// Anything still in flight on the closing session is cancelled now —
|
|
201
|
+
// its didInvalidate later must not complete a newer session's calls.
|
|
202
|
+
auto openDone = std::move(self->_openDone);
|
|
203
|
+
self->_openDone = nullptr;
|
|
204
|
+
auto txDone = std::move(self->_txDone);
|
|
205
|
+
self->_txDone = nullptr;
|
|
206
|
+
const qntx::CardReaderResult cancelled{qntx::CardReaderStatus::cancelled, {}, {}};
|
|
207
|
+
if (openDone != nullptr) {
|
|
208
|
+
openDone(cancelled);
|
|
209
|
+
}
|
|
210
|
+
if (txDone != nullptr) {
|
|
211
|
+
txDone(cancelled);
|
|
212
|
+
}
|
|
213
|
+
if (self->_session == nil) {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
if (success && !text.empty()) {
|
|
217
|
+
self->_session.alertMessage = nsString(text);
|
|
218
|
+
[self->_session invalidateSession];
|
|
219
|
+
} else if (!success && !text.empty()) {
|
|
220
|
+
[self->_session invalidateSessionWithErrorMessage:nsString(text)];
|
|
221
|
+
} else {
|
|
222
|
+
[self->_session invalidateSession];
|
|
223
|
+
}
|
|
224
|
+
// Keep the invalidated session: its didInvalidate still has to arrive
|
|
225
|
+
// and must be told apart from a newer session's events.
|
|
226
|
+
self->_closing = self->_session;
|
|
227
|
+
self->_session = nil;
|
|
228
|
+
self->_isoTag = nil;
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
- (void)tagReaderSession:(NFCTagReaderSession*)session
|
|
233
|
+
didDetectTags:(NSArray<id<NFCTag>>*)tags {
|
|
234
|
+
if (session != _session) {
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
if (_openDone == nullptr || tags.count != 1 ||
|
|
238
|
+
tags.firstObject.type != NFCTagTypeISO7816Compatible) {
|
|
239
|
+
// Anything that is not exactly one ISO-DEP tag: keep polling without
|
|
240
|
+
// touching the panel text.
|
|
241
|
+
[session restartPolling];
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
id<NFCTag> tag = tags.firstObject;
|
|
245
|
+
[session connectToTag:tag
|
|
246
|
+
completionHandler:^(NSError* _Nullable error) {
|
|
247
|
+
if (session != self->_session) {
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
if (error != nil) {
|
|
251
|
+
auto result = resultOf(error);
|
|
252
|
+
[self->_session invalidateSession];
|
|
253
|
+
self->_isoTag = nil;
|
|
254
|
+
self->_ended = result;
|
|
255
|
+
auto openDone = std::move(self->_openDone);
|
|
256
|
+
self->_openDone = nullptr;
|
|
257
|
+
openDone(result);
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
self->_isoTag = (id<NFCISO7816Tag>)tag;
|
|
261
|
+
auto openDone = std::move(self->_openDone);
|
|
262
|
+
self->_openDone = nullptr;
|
|
263
|
+
openDone({qntx::CardReaderStatus::ok, {}, {}});
|
|
264
|
+
}];
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
- (void)tagReaderSession:(NFCTagReaderSession*)session
|
|
268
|
+
didInvalidateWithError:(NSError*)error {
|
|
269
|
+
if (session == _closing) {
|
|
270
|
+
// The session close() invalidated delivered its final event: it may
|
|
271
|
+
// now be replaced.
|
|
272
|
+
_closing = nil;
|
|
273
|
+
} else if (session == _session) {
|
|
274
|
+
_session = nil;
|
|
275
|
+
_isoTag = nil;
|
|
276
|
+
[self failAll:resultOf(error)];
|
|
277
|
+
} else {
|
|
278
|
+
// A session older than _closing: nothing live refers to it.
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
281
|
+
if (_queuedOpen.has_value() && _session == nil && _closing == nil) {
|
|
282
|
+
auto queued = std::move(_queuedOpen);
|
|
283
|
+
_queuedOpen = std::nullopt;
|
|
284
|
+
[self beginWithPrompt:std::move(queued->first) done:std::move(queued->second)];
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
@end
|
|
289
|
+
|
|
290
|
+
namespace qntx {
|
|
291
|
+
namespace {
|
|
292
|
+
|
|
293
|
+
class IosCardReader final : public CardReader {
|
|
294
|
+
public:
|
|
295
|
+
void open(std::string prompt, CardReaderDone done) override {
|
|
296
|
+
[_session openWithPrompt:std::move(prompt) done:std::move(done)];
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
void transmit(std::vector<uint8_t> apdu, CardReaderDone done) override {
|
|
300
|
+
[_session transmitApdu:std::move(apdu) done:std::move(done)];
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
void close(bool success, std::string text) override {
|
|
304
|
+
[_session closeWithSuccess:success ? YES : NO text:std::move(text)];
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
private:
|
|
308
|
+
QntxNfcSession* _session = [[QntxNfcSession alloc] init];
|
|
309
|
+
};
|
|
310
|
+
|
|
311
|
+
} // namespace
|
|
312
|
+
|
|
313
|
+
std::shared_ptr<CardReader> platformCardReader() {
|
|
314
|
+
static const auto reader = std::make_shared<IosCardReader>();
|
|
315
|
+
return reader;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
} // namespace qntx
|
|
@@ -116,6 +116,49 @@ void keystoreOpen(
|
|
|
116
116
|
});
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
+
void keystoreSealDevice(const std::string& id, SecretBytes secret, KeystoreDone done) {
|
|
120
|
+
dispatch(std::move(done), [&](jlong token) {
|
|
121
|
+
auto method = keystoreClass()->getStaticMethod<void(
|
|
122
|
+
jlong, jni::alias_ref<jstring>, jni::alias_ref<jni::JArrayByte>)>("sealDevice");
|
|
123
|
+
method(
|
|
124
|
+
keystoreClass(),
|
|
125
|
+
token,
|
|
126
|
+
jni::make_jstring(id),
|
|
127
|
+
byteArray(secret.data(), secret.size()));
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
void keystoreOpenDevice(const std::string& id, std::vector<uint8_t> sealed, KeystoreDone done) {
|
|
132
|
+
dispatch(std::move(done), [&](jlong token) {
|
|
133
|
+
auto method = keystoreClass()->getStaticMethod<void(
|
|
134
|
+
jlong, jni::alias_ref<jstring>, jni::alias_ref<jni::JArrayByte>)>("openDevice");
|
|
135
|
+
method(
|
|
136
|
+
keystoreClass(),
|
|
137
|
+
token,
|
|
138
|
+
jni::make_jstring(id),
|
|
139
|
+
byteArray(sealed.data(), sealed.size()));
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
void keystoreProbe(const std::string& id, KeyProtection protection, KeystoreDone done) {
|
|
144
|
+
dispatch(std::move(done), [&](jlong token) {
|
|
145
|
+
auto method =
|
|
146
|
+
keystoreClass()->getStaticMethod<void(jlong, jni::alias_ref<jstring>, jboolean)>("probe");
|
|
147
|
+
method(
|
|
148
|
+
keystoreClass(),
|
|
149
|
+
token,
|
|
150
|
+
jni::make_jstring(id),
|
|
151
|
+
protection == KeyProtection::presence ? JNI_TRUE : JNI_FALSE);
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
void keystoreRemove(const std::string& id, KeystoreDone done) {
|
|
156
|
+
dispatch(std::move(done), [&](jlong token) {
|
|
157
|
+
auto method = keystoreClass()->getStaticMethod<void(jlong, jni::alias_ref<jstring>)>("remove");
|
|
158
|
+
method(keystoreClass(), token, jni::make_jstring(id));
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
|
|
119
162
|
void keystoreAuthenticate(KeystorePrompt prompt, KeystoreDone done) {
|
|
120
163
|
dispatch(std::move(done), [&](jlong token) {
|
|
121
164
|
auto method = keystoreClass()->getStaticMethod<void(
|
|
@@ -147,6 +190,10 @@ std::string keystoreLocale() {
|
|
|
147
190
|
return method(keystoreClass())->toStdString();
|
|
148
191
|
}
|
|
149
192
|
|
|
193
|
+
std::string keystorePlatform() {
|
|
194
|
+
return "android";
|
|
195
|
+
}
|
|
196
|
+
|
|
150
197
|
} // namespace qntx
|
|
151
198
|
|
|
152
199
|
// Kotlin's Keystore.nativeComplete: resolves the parked call. The byte array
|
|
@@ -161,7 +208,7 @@ Java_com_margelo_nitro_qntxwallet_Keystore_nativeComplete(
|
|
|
161
208
|
qntx::KeystoreResult result;
|
|
162
209
|
result.status = static_cast<qntx::KeystoreStatus>(status);
|
|
163
210
|
if (status < 0 ||
|
|
164
|
-
status > static_cast<jint>(qntx::KeystoreStatus::
|
|
211
|
+
status > static_cast<jint>(qntx::KeystoreStatus::noLockScreen)) {
|
|
165
212
|
result.status = qntx::KeystoreStatus::failed;
|
|
166
213
|
}
|
|
167
214
|
if (bytes != nullptr && result.status == qntx::KeystoreStatus::ok) {
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
// iOS keystore (W5): one Secure Enclave P-256 key per vault factor, tagged
|
|
2
|
-
// org.qntx.wallet.vault.<factor id
|
|
3
|
-
// set and usable only after a fresh user-presence check
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
2
|
+
// org.qntx.wallet.vault.<factor id>. A presence key is readable only while a
|
|
3
|
+
// device passcode is set and usable only after a fresh user-presence check; a
|
|
4
|
+
// device key is accessible whenever the device is unlocked and never prompts.
|
|
5
|
+
// Sealing is ECIES with the public key (no prompt); opening decrypts with the
|
|
6
|
+
// private key — presence behind a new LAContext whose reason is the kernel's
|
|
7
|
+
// prompt text (every unlock, re-verification and per-operation verification is
|
|
8
|
+
// its own system prompt), device behind an interactionNotAllowed context.
|
|
7
9
|
// The simulator has no Secure Enclave: there the key lives in the software
|
|
8
|
-
// keychain with the same
|
|
10
|
+
// keychain with the same access control.
|
|
9
11
|
#include "../host/Keystore.hpp"
|
|
10
12
|
|
|
11
13
|
#import <Foundation/Foundation.h>
|
|
@@ -62,7 +64,7 @@ KeystoreStatus statusOf(NSError* error) {
|
|
|
62
64
|
case LAErrorUserFallback:
|
|
63
65
|
return KeystoreStatus::cancelled;
|
|
64
66
|
case LAErrorPasscodeNotSet:
|
|
65
|
-
return KeystoreStatus::
|
|
67
|
+
return KeystoreStatus::noLockScreen;
|
|
66
68
|
default:
|
|
67
69
|
return KeystoreStatus::failed;
|
|
68
70
|
}
|
|
@@ -111,7 +113,7 @@ KeystoreResult credentialProbeFailure(NSError* error) {
|
|
|
111
113
|
return {
|
|
112
114
|
error != nil && [error.domain isEqualToString:LAErrorDomain] &&
|
|
113
115
|
error.code == LAErrorPasscodeNotSet
|
|
114
|
-
? KeystoreStatus::
|
|
116
|
+
? KeystoreStatus::noLockScreen
|
|
115
117
|
: KeystoreStatus::unavailable,
|
|
116
118
|
{},
|
|
117
119
|
detailOf(error)};
|
|
@@ -135,19 +137,28 @@ std::optional<KeystoreResult> deviceCredentialMissing() {
|
|
|
135
137
|
return credentialProbeFailure(error);
|
|
136
138
|
}
|
|
137
139
|
|
|
138
|
-
KeystoreResult sealNow(
|
|
139
|
-
|
|
140
|
-
|
|
140
|
+
KeystoreResult sealNow(
|
|
141
|
+
const std::string& factorId, const SecretBytes& secret, bool presence) {
|
|
142
|
+
// A presence key cannot exist while the policy cannot be evaluated at all;
|
|
143
|
+
// a device key has no such gate.
|
|
144
|
+
if (presence) {
|
|
145
|
+
if (auto missing = deviceCredentialMissing()) {
|
|
146
|
+
return std::move(*missing);
|
|
147
|
+
}
|
|
141
148
|
}
|
|
142
149
|
NSData* tag = tagFor(factorId);
|
|
143
150
|
deleteKey(tag);
|
|
144
|
-
SecAccessControlCreateFlags flags = kSecAccessControlUserPresence;
|
|
151
|
+
SecAccessControlCreateFlags flags = presence ? kSecAccessControlUserPresence : 0;
|
|
145
152
|
#if !TARGET_OS_SIMULATOR
|
|
146
153
|
flags |= kSecAccessControlPrivateKeyUsage;
|
|
147
154
|
#endif
|
|
148
155
|
CFErrorRef error = nullptr;
|
|
149
156
|
SecAccessControlRef access = SecAccessControlCreateWithFlags(
|
|
150
|
-
kCFAllocatorDefault,
|
|
157
|
+
kCFAllocatorDefault,
|
|
158
|
+
presence ? kSecAttrAccessibleWhenPasscodeSetThisDeviceOnly
|
|
159
|
+
: kSecAttrAccessibleWhenUnlockedThisDeviceOnly,
|
|
160
|
+
flags,
|
|
161
|
+
&error);
|
|
151
162
|
if (access == nullptr) {
|
|
152
163
|
KeystoreResult out{KeystoreStatus::unavailable, {}, detailOf(error)};
|
|
153
164
|
if (error != nullptr) {
|
|
@@ -203,10 +214,7 @@ KeystoreResult sealNow(const std::string& factorId, const SecretBytes& secret) {
|
|
|
203
214
|
KeystoreResult openNow(
|
|
204
215
|
const std::string& factorId,
|
|
205
216
|
const std::vector<uint8_t>& sealed,
|
|
206
|
-
|
|
207
|
-
LAContext* context = [LAContext new];
|
|
208
|
-
context.touchIDAuthenticationAllowableReuseDuration = 0;
|
|
209
|
-
context.localizedReason = @(prompt.description.c_str());
|
|
217
|
+
LAContext* context) {
|
|
210
218
|
CFTypeRef keyRef = nullptr;
|
|
211
219
|
const OSStatus found = SecItemCopyMatching(
|
|
212
220
|
(__bridge CFDictionaryRef) @{
|
|
@@ -249,6 +257,41 @@ KeystoreResult openNow(
|
|
|
249
257
|
return {KeystoreStatus::ok, std::move(out)};
|
|
250
258
|
}
|
|
251
259
|
|
|
260
|
+
// Reads only keychain state: item attributes under an interactionNotAllowed
|
|
261
|
+
// context, and for a presence key the device-credential policy — a
|
|
262
|
+
// WhenPasscodeSet key cannot be valid while no passcode is set.
|
|
263
|
+
KeystoreResult probeNow(const std::string& factorId, KeyProtection protection) {
|
|
264
|
+
LAContext* context = [LAContext new];
|
|
265
|
+
context.interactionNotAllowed = YES;
|
|
266
|
+
CFTypeRef found = nullptr;
|
|
267
|
+
const OSStatus status = SecItemCopyMatching(
|
|
268
|
+
(__bridge CFDictionaryRef) @{
|
|
269
|
+
(id)kSecClass : (id)kSecClassKey,
|
|
270
|
+
(id)kSecAttrKeyType : (id)kSecAttrKeyTypeECSECPrimeRandom,
|
|
271
|
+
(id)kSecAttrApplicationTag : tagFor(factorId),
|
|
272
|
+
(id)kSecReturnAttributes : @YES,
|
|
273
|
+
(id)kSecUseAuthenticationContext : context,
|
|
274
|
+
},
|
|
275
|
+
&found);
|
|
276
|
+
if (found != nullptr) {
|
|
277
|
+
CFRelease(found);
|
|
278
|
+
}
|
|
279
|
+
if (status == errSecItemNotFound) {
|
|
280
|
+
return {KeystoreStatus::invalidated, {}};
|
|
281
|
+
}
|
|
282
|
+
if (status != errSecSuccess && status != errSecInteractionNotAllowed) {
|
|
283
|
+
return {KeystoreStatus::failed, {}};
|
|
284
|
+
}
|
|
285
|
+
if (protection == KeyProtection::presence) {
|
|
286
|
+
NSError* error = nil;
|
|
287
|
+
if (![context canEvaluatePolicy:LAPolicyDeviceOwnerAuthentication error:&error] &&
|
|
288
|
+
[error.domain isEqualToString:LAErrorDomain] && error.code == LAErrorPasscodeNotSet) {
|
|
289
|
+
return {KeystoreStatus::invalidated, {}};
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
return {KeystoreStatus::ok, {}};
|
|
293
|
+
}
|
|
294
|
+
|
|
252
295
|
} // namespace
|
|
253
296
|
|
|
254
297
|
void keystoreSeal(
|
|
@@ -262,7 +305,7 @@ void keystoreSeal(
|
|
|
262
305
|
auto input = std::make_shared<SecretBytes>(std::move(secret));
|
|
263
306
|
auto finish = std::make_shared<KeystoreDone>(std::move(done));
|
|
264
307
|
dispatch_async(keystoreQueue(), ^{
|
|
265
|
-
(*finish)(sealNow(alias, *input));
|
|
308
|
+
(*finish)(sealNow(alias, *input, true));
|
|
266
309
|
});
|
|
267
310
|
}
|
|
268
311
|
|
|
@@ -272,9 +315,52 @@ void keystoreOpen(
|
|
|
272
315
|
KeystorePrompt prompt,
|
|
273
316
|
KeystoreDone done) {
|
|
274
317
|
const std::string alias = factorId;
|
|
318
|
+
const std::string reason = prompt.description;
|
|
275
319
|
auto finish = std::make_shared<KeystoreDone>(std::move(done));
|
|
276
320
|
dispatch_async(keystoreQueue(), ^{
|
|
277
|
-
|
|
321
|
+
LAContext* context = [LAContext new];
|
|
322
|
+
context.touchIDAuthenticationAllowableReuseDuration = 0;
|
|
323
|
+
context.localizedReason = @(reason.c_str());
|
|
324
|
+
(*finish)(openNow(alias, sealed, context));
|
|
325
|
+
});
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
void keystoreSealDevice(const std::string& id, SecretBytes secret, KeystoreDone done) {
|
|
329
|
+
const std::string alias = id;
|
|
330
|
+
auto input = std::make_shared<SecretBytes>(std::move(secret));
|
|
331
|
+
auto finish = std::make_shared<KeystoreDone>(std::move(done));
|
|
332
|
+
dispatch_async(keystoreQueue(), ^{
|
|
333
|
+
(*finish)(sealNow(alias, *input, false));
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
void keystoreOpenDevice(
|
|
338
|
+
const std::string& id,
|
|
339
|
+
std::vector<uint8_t> sealed,
|
|
340
|
+
KeystoreDone done) {
|
|
341
|
+
const std::string alias = id;
|
|
342
|
+
auto finish = std::make_shared<KeystoreDone>(std::move(done));
|
|
343
|
+
dispatch_async(keystoreQueue(), ^{
|
|
344
|
+
LAContext* context = [LAContext new];
|
|
345
|
+
context.interactionNotAllowed = YES;
|
|
346
|
+
(*finish)(openNow(alias, sealed, context));
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
void keystoreProbe(const std::string& id, KeyProtection protection, KeystoreDone done) {
|
|
351
|
+
const std::string alias = id;
|
|
352
|
+
auto finish = std::make_shared<KeystoreDone>(std::move(done));
|
|
353
|
+
dispatch_async(keystoreQueue(), ^{
|
|
354
|
+
(*finish)(probeNow(alias, protection));
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
void keystoreRemove(const std::string& id, KeystoreDone done) {
|
|
359
|
+
const std::string alias = id;
|
|
360
|
+
auto finish = std::make_shared<KeystoreDone>(std::move(done));
|
|
361
|
+
dispatch_async(keystoreQueue(), ^{
|
|
362
|
+
deleteKey(tagFor(alias));
|
|
363
|
+
(*finish)(KeystoreResult{KeystoreStatus::ok, {}});
|
|
278
364
|
});
|
|
279
365
|
}
|
|
280
366
|
|
|
@@ -341,4 +427,8 @@ std::string keystoreLocale() {
|
|
|
341
427
|
return language == nil ? "en" : std::string(language.UTF8String);
|
|
342
428
|
}
|
|
343
429
|
|
|
430
|
+
std::string keystorePlatform() {
|
|
431
|
+
return "ios";
|
|
432
|
+
}
|
|
433
|
+
|
|
344
434
|
} // namespace qntx
|
|
@@ -107,6 +107,8 @@ Java_com_margelo_nitro_qntxwallet_Passkey_nativeComplete(
|
|
|
107
107
|
default:
|
|
108
108
|
result.status = qntx::PasskeyStatus::failed;
|
|
109
109
|
}
|
|
110
|
+
// Credential Manager returns the PRF outputs only inside this JSON string, so on Android they
|
|
111
|
+
// cannot travel as wiped bytes the way iOS delivers them (PasskeyResult::prfFirst).
|
|
110
112
|
if (responseJson != nullptr && result.status == qntx::PasskeyStatus::ok) {
|
|
111
113
|
const char* utf = env->GetStringUTFChars(responseJson, nullptr);
|
|
112
114
|
if (utf != nullptr) {
|
|
@@ -62,6 +62,10 @@ NSData* _Nullable base64urlDecode(NSString* _Nullable value) {
|
|
|
62
62
|
return [[NSData alloc] initWithBase64EncodedString:standard options:0];
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
+
qntx::SecretBytes secretBytesOf(NSData* data) {
|
|
66
|
+
return qntx::SecretBytes(static_cast<const uint8_t*>(data.bytes), data.length);
|
|
67
|
+
}
|
|
68
|
+
|
|
65
69
|
NSString* base64urlEncode(NSData* data) {
|
|
66
70
|
NSString* standard = [data base64EncodedStringWithOptions:0];
|
|
67
71
|
standard = [standard stringByReplacingOccurrencesOfString:@"+" withString:@"-"];
|
|
@@ -278,6 +282,9 @@ API_AVAILABLE(ios(18.0))
|
|
|
278
282
|
NSMutableDictionary<NSString*, id>* extensions = [NSMutableDictionary new];
|
|
279
283
|
NSMutableDictionary<NSString*, id>* response = [NSMutableDictionary new];
|
|
280
284
|
std::string credentialId;
|
|
285
|
+
// The PRF outputs are the wallet entropy: they leave as wiped bytes, never in the JSON.
|
|
286
|
+
NSData* first = nil;
|
|
287
|
+
NSData* second = nil;
|
|
281
288
|
if ([authorization.credential
|
|
282
289
|
isKindOfClass:ASAuthorizationPlatformPublicKeyCredentialRegistration.class]) {
|
|
283
290
|
auto* credential = (ASAuthorizationPlatformPublicKeyCredentialRegistration*)
|
|
@@ -289,17 +296,9 @@ API_AVAILABLE(ios(18.0))
|
|
|
289
296
|
response[@"attestationObject"] = base64urlEncode(credential.rawAttestationObject);
|
|
290
297
|
}
|
|
291
298
|
if (credential.prf != nil) {
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
NSMutableDictionary<NSString*, id>* results =
|
|
296
|
-
[@{ @"first" : base64urlEncode(credential.prf.first) } mutableCopy];
|
|
297
|
-
if (credential.prf.second != nil) {
|
|
298
|
-
results[@"second"] = base64urlEncode(credential.prf.second);
|
|
299
|
-
}
|
|
300
|
-
prf[@"results"] = results;
|
|
301
|
-
}
|
|
302
|
-
extensions[@"prf"] = prf;
|
|
299
|
+
extensions[@"prf"] = @{ @"enabled" : @(credential.prf.isSupported) };
|
|
300
|
+
first = credential.prf.first;
|
|
301
|
+
second = credential.prf.second;
|
|
303
302
|
}
|
|
304
303
|
} else if ([authorization.credential
|
|
305
304
|
isKindOfClass:ASAuthorizationPlatformPublicKeyCredentialAssertion.class]) {
|
|
@@ -312,12 +311,8 @@ API_AVAILABLE(ios(18.0))
|
|
|
312
311
|
response[@"signature"] = base64urlEncode(credential.signature);
|
|
313
312
|
response[@"userHandle"] = base64urlEncode(credential.userID);
|
|
314
313
|
if (credential.prf != nil) {
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
if (credential.prf.second != nil) {
|
|
318
|
-
results[@"second"] = base64urlEncode(credential.prf.second);
|
|
319
|
-
}
|
|
320
|
-
extensions[@"prf"] = @{ @"results" : results };
|
|
314
|
+
first = credential.prf.first;
|
|
315
|
+
second = credential.prf.second;
|
|
321
316
|
}
|
|
322
317
|
} else {
|
|
323
318
|
[self finish:qntx::PasskeyResult{qntx::PasskeyStatus::failed, {}}];
|
|
@@ -335,7 +330,14 @@ API_AVAILABLE(ios(18.0))
|
|
|
335
330
|
[self finish:qntx::PasskeyResult{qntx::PasskeyStatus::failed, {}}];
|
|
336
331
|
return;
|
|
337
332
|
}
|
|
338
|
-
|
|
333
|
+
qntx::PasskeyResult result{qntx::PasskeyStatus::ok, std::move(json)};
|
|
334
|
+
if (first != nil) {
|
|
335
|
+
result.prfFirst = secretBytesOf(first);
|
|
336
|
+
if (second != nil) {
|
|
337
|
+
result.prfSecond = secretBytesOf(second);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
[self finish:std::move(result)];
|
|
339
341
|
}
|
|
340
342
|
|
|
341
343
|
- (void)authorizationController:(ASAuthorizationController*)controller
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#import <UIKit/UIKit.h>
|
|
4
|
+
|
|
5
|
+
// The only signal the mounted secure-input view reports to the main runtime.
|
|
6
|
+
// `submitted` is emitted on the clear that follows a confirmed entry, right
|
|
7
|
+
// before `idle`.
|
|
8
|
+
typedef NS_ENUM(NSInteger, QntxSecureInputState) {
|
|
9
|
+
QntxSecureInputStateIdle = 0,
|
|
10
|
+
QntxSecureInputStateEmpty,
|
|
11
|
+
QntxSecureInputStateFilled,
|
|
12
|
+
QntxSecureInputStateSubmitted,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
// The trusted input surface: a label the kernel sets plus a text field the
|
|
16
|
+
// main runtime cannot reach. It takes no props — what to collect and which
|
|
17
|
+
// label to show arrive through SecureInputHub while the view is attached to
|
|
18
|
+
// a window.
|
|
19
|
+
@interface QntxSecureInputField : UIView
|
|
20
|
+
|
|
21
|
+
// Fired on the main queue on every state transition.
|
|
22
|
+
@property(nonatomic, copy, nullable) void (^onStateChange)(QntxSecureInputState state);
|
|
23
|
+
|
|
24
|
+
@end
|