@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,57 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Argon2 reference source code package - reference C implementations
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2015
|
|
5
|
+
* Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves
|
|
6
|
+
*
|
|
7
|
+
* You may use this work under the terms of a Creative Commons CC0 1.0
|
|
8
|
+
* License/Waiver or the Apache Public License 2.0, at your option. The terms of
|
|
9
|
+
* these licenses can be found at:
|
|
10
|
+
*
|
|
11
|
+
* - CC0 1.0 Universal : https://creativecommons.org/publicdomain/zero/1.0
|
|
12
|
+
* - Apache 2.0 : https://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
+
*
|
|
14
|
+
* You should have received a copy of both of these licenses along with this
|
|
15
|
+
* software. If not, they may be obtained at the above URLs.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
#ifndef ENCODING_H
|
|
19
|
+
#define ENCODING_H
|
|
20
|
+
#include "argon2.h"
|
|
21
|
+
|
|
22
|
+
#define ARGON2_MAX_DECODED_LANES UINT32_C(255)
|
|
23
|
+
#define ARGON2_MIN_DECODED_SALT_LEN UINT32_C(8)
|
|
24
|
+
#define ARGON2_MIN_DECODED_OUT_LEN UINT32_C(12)
|
|
25
|
+
|
|
26
|
+
/*
|
|
27
|
+
* encode an Argon2 hash string into the provided buffer. 'dst_len'
|
|
28
|
+
* contains the size, in characters, of the 'dst' buffer; if 'dst_len'
|
|
29
|
+
* is less than the number of required characters (including the
|
|
30
|
+
* terminating 0), then this function returns ARGON2_ENCODING_ERROR.
|
|
31
|
+
*
|
|
32
|
+
* on success, ARGON2_OK is returned.
|
|
33
|
+
*/
|
|
34
|
+
int encode_string(char *dst, size_t dst_len, argon2_context *ctx,
|
|
35
|
+
argon2_type type);
|
|
36
|
+
|
|
37
|
+
/*
|
|
38
|
+
* Decodes an Argon2 hash string into the provided structure 'ctx'.
|
|
39
|
+
* The only fields that must be set prior to this call are ctx.saltlen and
|
|
40
|
+
* ctx.outlen (which must be the maximal salt and out length values that are
|
|
41
|
+
* allowed), ctx.salt and ctx.out (which must be buffers of the specified
|
|
42
|
+
* length), and ctx.pwd and ctx.pwdlen which must hold a valid password.
|
|
43
|
+
*
|
|
44
|
+
* Invalid input string causes an error. On success, the ctx is valid and all
|
|
45
|
+
* fields have been initialized.
|
|
46
|
+
*
|
|
47
|
+
* Returned value is ARGON2_OK on success, other ARGON2_ codes on error.
|
|
48
|
+
*/
|
|
49
|
+
int decode_string(argon2_context *ctx, const char *str, argon2_type type);
|
|
50
|
+
|
|
51
|
+
/* Returns the length of the encoded byte stream with length len */
|
|
52
|
+
size_t b64len(uint32_t len);
|
|
53
|
+
|
|
54
|
+
/* Returns the length of the encoded number num */
|
|
55
|
+
size_t numlen(uint32_t num);
|
|
56
|
+
|
|
57
|
+
#endif
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Argon2 reference source code package - reference C implementations
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2015
|
|
5
|
+
* Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves
|
|
6
|
+
*
|
|
7
|
+
* You may use this work under the terms of a Creative Commons CC0 1.0
|
|
8
|
+
* License/Waiver or the Apache Public License 2.0, at your option. The terms of
|
|
9
|
+
* these licenses can be found at:
|
|
10
|
+
*
|
|
11
|
+
* - CC0 1.0 Universal : https://creativecommons.org/publicdomain/zero/1.0
|
|
12
|
+
* - Apache 2.0 : https://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
+
*
|
|
14
|
+
* You should have received a copy of both of these licenses along with this
|
|
15
|
+
* software. If not, they may be obtained at the above URLs.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
#include <stdint.h>
|
|
19
|
+
#include <string.h>
|
|
20
|
+
#include <stdlib.h>
|
|
21
|
+
|
|
22
|
+
#include "argon2.h"
|
|
23
|
+
#include "core.h"
|
|
24
|
+
|
|
25
|
+
#include "blake2/blamka-round-ref.h"
|
|
26
|
+
#include "blake2/blake2-impl.h"
|
|
27
|
+
#include "blake2/blake2.h"
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
/*
|
|
31
|
+
* Function fills a new memory block and optionally XORs the old block over the new one.
|
|
32
|
+
* @next_block must be initialized.
|
|
33
|
+
* @param prev_block Pointer to the previous block
|
|
34
|
+
* @param ref_block Pointer to the reference block
|
|
35
|
+
* @param next_block Pointer to the block to be constructed
|
|
36
|
+
* @param with_xor Whether to XOR into the new block (1) or just overwrite (0)
|
|
37
|
+
* @pre all block pointers must be valid
|
|
38
|
+
*/
|
|
39
|
+
static void fill_block(const block *prev_block, const block *ref_block,
|
|
40
|
+
block *next_block, int with_xor) {
|
|
41
|
+
block blockR, block_tmp;
|
|
42
|
+
unsigned i;
|
|
43
|
+
|
|
44
|
+
copy_block(&blockR, ref_block);
|
|
45
|
+
xor_block(&blockR, prev_block);
|
|
46
|
+
copy_block(&block_tmp, &blockR);
|
|
47
|
+
/* Now blockR = ref_block + prev_block and block_tmp = ref_block + prev_block */
|
|
48
|
+
if (with_xor) {
|
|
49
|
+
/* Saving the next block contents for XOR over: */
|
|
50
|
+
xor_block(&block_tmp, next_block);
|
|
51
|
+
/* Now blockR = ref_block + prev_block and
|
|
52
|
+
block_tmp = ref_block + prev_block + next_block */
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/* Apply Blake2 on columns of 64-bit words: (0,1,...,15) , then
|
|
56
|
+
(16,17,..31)... finally (112,113,...127) */
|
|
57
|
+
for (i = 0; i < 8; ++i) {
|
|
58
|
+
BLAKE2_ROUND_NOMSG(
|
|
59
|
+
blockR.v[16 * i], blockR.v[16 * i + 1], blockR.v[16 * i + 2],
|
|
60
|
+
blockR.v[16 * i + 3], blockR.v[16 * i + 4], blockR.v[16 * i + 5],
|
|
61
|
+
blockR.v[16 * i + 6], blockR.v[16 * i + 7], blockR.v[16 * i + 8],
|
|
62
|
+
blockR.v[16 * i + 9], blockR.v[16 * i + 10], blockR.v[16 * i + 11],
|
|
63
|
+
blockR.v[16 * i + 12], blockR.v[16 * i + 13], blockR.v[16 * i + 14],
|
|
64
|
+
blockR.v[16 * i + 15]);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/* Apply Blake2 on rows of 64-bit words: (0,1,16,17,...112,113), then
|
|
68
|
+
(2,3,18,19,...,114,115).. finally (14,15,30,31,...,126,127) */
|
|
69
|
+
for (i = 0; i < 8; i++) {
|
|
70
|
+
BLAKE2_ROUND_NOMSG(
|
|
71
|
+
blockR.v[2 * i], blockR.v[2 * i + 1], blockR.v[2 * i + 16],
|
|
72
|
+
blockR.v[2 * i + 17], blockR.v[2 * i + 32], blockR.v[2 * i + 33],
|
|
73
|
+
blockR.v[2 * i + 48], blockR.v[2 * i + 49], blockR.v[2 * i + 64],
|
|
74
|
+
blockR.v[2 * i + 65], blockR.v[2 * i + 80], blockR.v[2 * i + 81],
|
|
75
|
+
blockR.v[2 * i + 96], blockR.v[2 * i + 97], blockR.v[2 * i + 112],
|
|
76
|
+
blockR.v[2 * i + 113]);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
copy_block(next_block, &block_tmp);
|
|
80
|
+
xor_block(next_block, &blockR);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
static void next_addresses(block *address_block, block *input_block,
|
|
84
|
+
const block *zero_block) {
|
|
85
|
+
input_block->v[6]++;
|
|
86
|
+
fill_block(zero_block, input_block, address_block, 0);
|
|
87
|
+
fill_block(zero_block, address_block, address_block, 0);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
void fill_segment(const argon2_instance_t *instance,
|
|
91
|
+
argon2_position_t position) {
|
|
92
|
+
block *ref_block = NULL, *curr_block = NULL;
|
|
93
|
+
block address_block, input_block, zero_block;
|
|
94
|
+
uint64_t pseudo_rand, ref_index, ref_lane;
|
|
95
|
+
uint32_t prev_offset, curr_offset;
|
|
96
|
+
uint32_t starting_index;
|
|
97
|
+
uint32_t i;
|
|
98
|
+
int data_independent_addressing;
|
|
99
|
+
|
|
100
|
+
if (instance == NULL) {
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
data_independent_addressing =
|
|
105
|
+
(instance->type == Argon2_i) ||
|
|
106
|
+
(instance->type == Argon2_id && (position.pass == 0) &&
|
|
107
|
+
(position.slice < ARGON2_SYNC_POINTS / 2));
|
|
108
|
+
|
|
109
|
+
if (data_independent_addressing) {
|
|
110
|
+
init_block_value(&zero_block, 0);
|
|
111
|
+
init_block_value(&input_block, 0);
|
|
112
|
+
|
|
113
|
+
input_block.v[0] = position.pass;
|
|
114
|
+
input_block.v[1] = position.lane;
|
|
115
|
+
input_block.v[2] = position.slice;
|
|
116
|
+
input_block.v[3] = instance->memory_blocks;
|
|
117
|
+
input_block.v[4] = instance->passes;
|
|
118
|
+
input_block.v[5] = instance->type;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
starting_index = 0;
|
|
122
|
+
|
|
123
|
+
if ((0 == position.pass) && (0 == position.slice)) {
|
|
124
|
+
starting_index = 2; /* we have already generated the first two blocks */
|
|
125
|
+
|
|
126
|
+
/* Don't forget to generate the first block of addresses: */
|
|
127
|
+
if (data_independent_addressing) {
|
|
128
|
+
next_addresses(&address_block, &input_block, &zero_block);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/* Offset of the current block */
|
|
133
|
+
curr_offset = position.lane * instance->lane_length +
|
|
134
|
+
position.slice * instance->segment_length + starting_index;
|
|
135
|
+
|
|
136
|
+
if (0 == curr_offset % instance->lane_length) {
|
|
137
|
+
/* Last block in this lane */
|
|
138
|
+
prev_offset = curr_offset + instance->lane_length - 1;
|
|
139
|
+
} else {
|
|
140
|
+
/* Previous block */
|
|
141
|
+
prev_offset = curr_offset - 1;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
for (i = starting_index; i < instance->segment_length;
|
|
145
|
+
++i, ++curr_offset, ++prev_offset) {
|
|
146
|
+
/*1.1 Rotating prev_offset if needed */
|
|
147
|
+
if (curr_offset % instance->lane_length == 1) {
|
|
148
|
+
prev_offset = curr_offset - 1;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/* 1.2 Computing the index of the reference block */
|
|
152
|
+
/* 1.2.1 Taking pseudo-random value from the previous block */
|
|
153
|
+
if (data_independent_addressing) {
|
|
154
|
+
if (i % ARGON2_ADDRESSES_IN_BLOCK == 0) {
|
|
155
|
+
next_addresses(&address_block, &input_block, &zero_block);
|
|
156
|
+
}
|
|
157
|
+
pseudo_rand = address_block.v[i % ARGON2_ADDRESSES_IN_BLOCK];
|
|
158
|
+
} else {
|
|
159
|
+
pseudo_rand = instance->memory[prev_offset].v[0];
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/* 1.2.2 Computing the lane of the reference block */
|
|
163
|
+
ref_lane = ((pseudo_rand >> 32)) % instance->lanes;
|
|
164
|
+
|
|
165
|
+
if ((position.pass == 0) && (position.slice == 0)) {
|
|
166
|
+
/* Can not reference other lanes yet */
|
|
167
|
+
ref_lane = position.lane;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/* 1.2.3 Computing the number of possible reference block within the
|
|
171
|
+
* lane.
|
|
172
|
+
*/
|
|
173
|
+
position.index = i;
|
|
174
|
+
ref_index = index_alpha(instance, &position, pseudo_rand & 0xFFFFFFFF,
|
|
175
|
+
ref_lane == position.lane);
|
|
176
|
+
|
|
177
|
+
/* 2 Creating a new block */
|
|
178
|
+
ref_block =
|
|
179
|
+
instance->memory + instance->lane_length * ref_lane + ref_index;
|
|
180
|
+
curr_block = instance->memory + curr_offset;
|
|
181
|
+
if (ARGON2_VERSION_10 == instance->version) {
|
|
182
|
+
/* version 1.2.1 and earlier: overwrite, not XOR */
|
|
183
|
+
fill_block(instance->memory + prev_offset, ref_block, curr_block, 0);
|
|
184
|
+
} else {
|
|
185
|
+
if(0 == position.pass) {
|
|
186
|
+
fill_block(instance->memory + prev_offset, ref_block,
|
|
187
|
+
curr_block, 0);
|
|
188
|
+
} else {
|
|
189
|
+
fill_block(instance->memory + prev_offset, ref_block,
|
|
190
|
+
curr_block, 1);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Argon2 reference source code package - reference C implementations
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2015
|
|
5
|
+
* Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves
|
|
6
|
+
*
|
|
7
|
+
* You may use this work under the terms of a Creative Commons CC0 1.0
|
|
8
|
+
* License/Waiver or the Apache Public License 2.0, at your option. The terms of
|
|
9
|
+
* these licenses can be found at:
|
|
10
|
+
*
|
|
11
|
+
* - CC0 1.0 Universal : https://creativecommons.org/publicdomain/zero/1.0
|
|
12
|
+
* - Apache 2.0 : https://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
+
*
|
|
14
|
+
* You should have received a copy of both of these licenses along with this
|
|
15
|
+
* software. If not, they may be obtained at the above URLs.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
#if !defined(ARGON2_NO_THREADS)
|
|
19
|
+
|
|
20
|
+
#include "thread.h"
|
|
21
|
+
#if defined(_WIN32)
|
|
22
|
+
#include <windows.h>
|
|
23
|
+
#endif
|
|
24
|
+
|
|
25
|
+
int argon2_thread_create(argon2_thread_handle_t *handle,
|
|
26
|
+
argon2_thread_func_t func, void *args) {
|
|
27
|
+
if (NULL == handle || func == NULL) {
|
|
28
|
+
return -1;
|
|
29
|
+
}
|
|
30
|
+
#if defined(_WIN32)
|
|
31
|
+
*handle = _beginthreadex(NULL, 0, func, args, 0, NULL);
|
|
32
|
+
return *handle != 0 ? 0 : -1;
|
|
33
|
+
#else
|
|
34
|
+
return pthread_create(handle, NULL, func, args);
|
|
35
|
+
#endif
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
int argon2_thread_join(argon2_thread_handle_t handle) {
|
|
39
|
+
#if defined(_WIN32)
|
|
40
|
+
if (WaitForSingleObject((HANDLE)handle, INFINITE) == WAIT_OBJECT_0) {
|
|
41
|
+
return CloseHandle((HANDLE)handle) != 0 ? 0 : -1;
|
|
42
|
+
}
|
|
43
|
+
return -1;
|
|
44
|
+
#else
|
|
45
|
+
return pthread_join(handle, NULL);
|
|
46
|
+
#endif
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
void argon2_thread_exit(void) {
|
|
50
|
+
#if defined(_WIN32)
|
|
51
|
+
_endthreadex(0);
|
|
52
|
+
#else
|
|
53
|
+
pthread_exit(NULL);
|
|
54
|
+
#endif
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
#endif /* ARGON2_NO_THREADS */
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Argon2 reference source code package - reference C implementations
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2015
|
|
5
|
+
* Daniel Dinu, Dmitry Khovratovich, Jean-Philippe Aumasson, and Samuel Neves
|
|
6
|
+
*
|
|
7
|
+
* You may use this work under the terms of a Creative Commons CC0 1.0
|
|
8
|
+
* License/Waiver or the Apache Public License 2.0, at your option. The terms of
|
|
9
|
+
* these licenses can be found at:
|
|
10
|
+
*
|
|
11
|
+
* - CC0 1.0 Universal : https://creativecommons.org/publicdomain/zero/1.0
|
|
12
|
+
* - Apache 2.0 : https://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
+
*
|
|
14
|
+
* You should have received a copy of both of these licenses along with this
|
|
15
|
+
* software. If not, they may be obtained at the above URLs.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
#ifndef ARGON2_THREAD_H
|
|
19
|
+
#define ARGON2_THREAD_H
|
|
20
|
+
|
|
21
|
+
#if !defined(ARGON2_NO_THREADS)
|
|
22
|
+
|
|
23
|
+
/*
|
|
24
|
+
Here we implement an abstraction layer for the simpĺe requirements
|
|
25
|
+
of the Argon2 code. We only require 3 primitives---thread creation,
|
|
26
|
+
joining, and termination---so full emulation of the pthreads API
|
|
27
|
+
is unwarranted. Currently we wrap pthreads and Win32 threads.
|
|
28
|
+
|
|
29
|
+
The API defines 2 types: the function pointer type,
|
|
30
|
+
argon2_thread_func_t,
|
|
31
|
+
and the type of the thread handle---argon2_thread_handle_t.
|
|
32
|
+
*/
|
|
33
|
+
#if defined(_WIN32)
|
|
34
|
+
#include <process.h>
|
|
35
|
+
typedef unsigned(__stdcall *argon2_thread_func_t)(void *);
|
|
36
|
+
typedef uintptr_t argon2_thread_handle_t;
|
|
37
|
+
#else
|
|
38
|
+
#include <pthread.h>
|
|
39
|
+
typedef void *(*argon2_thread_func_t)(void *);
|
|
40
|
+
typedef pthread_t argon2_thread_handle_t;
|
|
41
|
+
#endif
|
|
42
|
+
|
|
43
|
+
/* Creates a thread
|
|
44
|
+
* @param handle pointer to a thread handle, which is the output of this
|
|
45
|
+
* function. Must not be NULL.
|
|
46
|
+
* @param func A function pointer for the thread's entry point. Must not be
|
|
47
|
+
* NULL.
|
|
48
|
+
* @param args Pointer that is passed as an argument to @func. May be NULL.
|
|
49
|
+
* @return 0 if @handle and @func are valid pointers and a thread is successfully
|
|
50
|
+
* created.
|
|
51
|
+
*/
|
|
52
|
+
int argon2_thread_create(argon2_thread_handle_t *handle,
|
|
53
|
+
argon2_thread_func_t func, void *args);
|
|
54
|
+
|
|
55
|
+
/* Waits for a thread to terminate
|
|
56
|
+
* @param handle Handle to a thread created with argon2_thread_create.
|
|
57
|
+
* @return 0 if @handle is a valid handle, and joining completed successfully.
|
|
58
|
+
*/
|
|
59
|
+
int argon2_thread_join(argon2_thread_handle_t handle);
|
|
60
|
+
|
|
61
|
+
/* Terminate the current thread. Must be run inside a thread created by
|
|
62
|
+
* argon2_thread_create.
|
|
63
|
+
*/
|
|
64
|
+
void argon2_thread_exit(void);
|
|
65
|
+
|
|
66
|
+
#endif /* ARGON2_NO_THREADS */
|
|
67
|
+
#endif
|
package/dist/cloud.d.mts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { HybridObject } from "react-native-nitro-modules";
|
|
2
|
+
import { CloudStore } from "@qntx/wallet-engine";
|
|
3
|
+
/**
|
|
4
|
+
* IOS CloudKit key-value transport for encrypted backup envelopes. Everything crossing this
|
|
5
|
+
* boundary is ciphertext: the native side only ever sees names, texts and a container identifier —
|
|
6
|
+
* no secrets, and a failure rejects with a message containing `[qntx-cloud:<code>]` where code is
|
|
7
|
+
* `unavailable | auth-required | quota | failed`, plus a detail that never names an account or
|
|
8
|
+
* carries file contents.
|
|
9
|
+
*/
|
|
10
|
+
interface CloudKitStore extends HybridObject<{
|
|
11
|
+
ios: "swift";
|
|
12
|
+
}> {
|
|
13
|
+
list(container: string): Promise<string[]>;
|
|
14
|
+
read(container: string, name: string): Promise<string | undefined>;
|
|
15
|
+
write(container: string, name: string, text: string): Promise<void>;
|
|
16
|
+
remove(container: string, name: string): Promise<void>;
|
|
17
|
+
setAccountListener(listener: () => void): void;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Android Google sign-in for drive.appdata access tokens. `accessToken(false)` must be silent — it
|
|
21
|
+
* rejects `auth-required` when consent is still missing; `accessToken(true)` may run the consent
|
|
22
|
+
* flow on the foreground activity. `clearToken` drops a token the API rejected.
|
|
23
|
+
*/
|
|
24
|
+
interface GoogleDriveAuth extends HybridObject<{
|
|
25
|
+
android: "kotlin";
|
|
26
|
+
}> {
|
|
27
|
+
accessToken(interactive: boolean): Promise<string>;
|
|
28
|
+
clearToken(token: string): Promise<void>;
|
|
29
|
+
}
|
|
30
|
+
export type CloudKitStoreLike = Pick<CloudKitStore, "list" | "read" | "write" | "remove" | "setAccountListener">;
|
|
31
|
+
export type GoogleDriveAuthLike = Pick<GoogleDriveAuth, "accessToken" | "clearToken">;
|
|
32
|
+
export type ICloudStore = CloudStore & {
|
|
33
|
+
/** Subscribes to iCloud account changes (sign-out, account switch); returns the unsubscribe. */
|
|
34
|
+
readonly onAccountChange: (listener: () => void) => () => void;
|
|
35
|
+
};
|
|
36
|
+
export type GoogleDriveStore = CloudStore & {
|
|
37
|
+
/** Runs the interactive consent flow — call from a user action after `auth-required`. */
|
|
38
|
+
readonly authorize: () => Promise<void>;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* The iCloud transport over the Nitro `CloudKitStore` hybrid. `native` is the test seam — by
|
|
42
|
+
* default the hybrid is created lazily on first use through
|
|
43
|
+
* `NitroModules.createHybridObject("CloudKitStore")`.
|
|
44
|
+
*/
|
|
45
|
+
export declare function createICloudStore(options: {
|
|
46
|
+
readonly container: string;
|
|
47
|
+
readonly native?: CloudKitStoreLike;
|
|
48
|
+
}): ICloudStore;
|
|
49
|
+
/**
|
|
50
|
+
* The Google Drive transport: the engine's `appDataFolder` adapter fed by the Nitro
|
|
51
|
+
* `GoogleDriveAuth` hybrid for tokens. `native` is the test seam — by default the hybrid is created
|
|
52
|
+
* lazily on first use through `NitroModules.createHybridObject("GoogleDriveAuth")`.
|
|
53
|
+
*/
|
|
54
|
+
export declare function createGoogleDriveStore(options?: {
|
|
55
|
+
readonly native?: GoogleDriveAuthLike;
|
|
56
|
+
}): GoogleDriveStore;
|
|
57
|
+
export {};
|
|
58
|
+
//# sourceMappingURL=cloud.d.mts.map
|
package/dist/cloud.mjs
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { CloudStoreError, checkCloudName, checkCloudText, createGoogleDriveCloudStore } from "@qntx/wallet-engine";
|
|
2
|
+
// src/cloud.ts
|
|
3
|
+
const CLOUD_ERROR = /\[qntx-cloud:(unavailable|auth-required|quota|failed)\]/;
|
|
4
|
+
const CONTAINER_NAME = /^iCloud\.[A-Za-z0-9.-]+$/;
|
|
5
|
+
/** Decodes a native rejection into the typed fault; a missing token is `failed`. */
|
|
6
|
+
function decode(error) {
|
|
7
|
+
const message = error instanceof Error ? error.message : "native cloud call failed";
|
|
8
|
+
const match = CLOUD_ERROR.exec(message)?.[1];
|
|
9
|
+
return new CloudStoreError(match === "unavailable" || match === "auth-required" || match === "quota" || match === "failed" ? match : "failed", message);
|
|
10
|
+
}
|
|
11
|
+
const call = async (fn) => {
|
|
12
|
+
try {
|
|
13
|
+
return await fn();
|
|
14
|
+
} catch (error) {
|
|
15
|
+
throw decode(error);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
const setTimer = (ms, fn) => {
|
|
19
|
+
const id = setTimeout(() => {
|
|
20
|
+
fn();
|
|
21
|
+
}, ms);
|
|
22
|
+
return () => {
|
|
23
|
+
clearTimeout(id);
|
|
24
|
+
};
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* The iCloud transport over the Nitro `CloudKitStore` hybrid. `native` is the test seam — by
|
|
28
|
+
* default the hybrid is created lazily on first use through
|
|
29
|
+
* `NitroModules.createHybridObject("CloudKitStore")`.
|
|
30
|
+
*/
|
|
31
|
+
function createICloudStore(options) {
|
|
32
|
+
if (!CONTAINER_NAME.test(options.container)) throw new CloudStoreError("invalid", "iCloud container must look like iCloud.<identifier>");
|
|
33
|
+
let { native } = options;
|
|
34
|
+
const store = async () => {
|
|
35
|
+
if (native === void 0) {
|
|
36
|
+
const { NitroModules } = await import("react-native-nitro-modules");
|
|
37
|
+
native = NitroModules.createHybridObject("CloudKitStore");
|
|
38
|
+
}
|
|
39
|
+
return native;
|
|
40
|
+
};
|
|
41
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
42
|
+
let registered = false;
|
|
43
|
+
const register = async () => {
|
|
44
|
+
registered = true;
|
|
45
|
+
try {
|
|
46
|
+
(await store()).setAccountListener(() => {
|
|
47
|
+
for (const listener of listeners) listener();
|
|
48
|
+
});
|
|
49
|
+
} catch {
|
|
50
|
+
registered = false;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
const callNative = async (op) => call(async () => {
|
|
54
|
+
return op(await store());
|
|
55
|
+
});
|
|
56
|
+
return {
|
|
57
|
+
list: async () => callNative(async (native) => native.list(options.container)),
|
|
58
|
+
read: async (name) => {
|
|
59
|
+
checkCloudName(name);
|
|
60
|
+
return callNative(async (native) => native.read(options.container, name));
|
|
61
|
+
},
|
|
62
|
+
write: async (name, text) => {
|
|
63
|
+
checkCloudName(name);
|
|
64
|
+
checkCloudText(text);
|
|
65
|
+
return callNative(async (native) => native.write(options.container, name, text));
|
|
66
|
+
},
|
|
67
|
+
delete: async (name) => {
|
|
68
|
+
checkCloudName(name);
|
|
69
|
+
return callNative(async (native) => native.remove(options.container, name));
|
|
70
|
+
},
|
|
71
|
+
onAccountChange: (listener) => {
|
|
72
|
+
listeners.add(listener);
|
|
73
|
+
if (!registered) register();
|
|
74
|
+
return () => {
|
|
75
|
+
listeners.delete(listener);
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* The Google Drive transport: the engine's `appDataFolder` adapter fed by the Nitro
|
|
82
|
+
* `GoogleDriveAuth` hybrid for tokens. `native` is the test seam — by default the hybrid is created
|
|
83
|
+
* lazily on first use through `NitroModules.createHybridObject("GoogleDriveAuth")`.
|
|
84
|
+
*/
|
|
85
|
+
function createGoogleDriveStore(options) {
|
|
86
|
+
let native = options?.native;
|
|
87
|
+
const auth = async () => {
|
|
88
|
+
if (native === void 0) {
|
|
89
|
+
const { NitroModules } = await import("react-native-nitro-modules");
|
|
90
|
+
native = NitroModules.createHybridObject("GoogleDriveAuth");
|
|
91
|
+
}
|
|
92
|
+
return native;
|
|
93
|
+
};
|
|
94
|
+
return {
|
|
95
|
+
...createGoogleDriveCloudStore({
|
|
96
|
+
fetch: async (input, init) => globalThis.fetch(input, init),
|
|
97
|
+
setTimer,
|
|
98
|
+
token: async () => call(async () => {
|
|
99
|
+
return (await auth()).accessToken(false);
|
|
100
|
+
}),
|
|
101
|
+
invalidateToken: async (token) => call(async () => {
|
|
102
|
+
return (await auth()).clearToken(token);
|
|
103
|
+
})
|
|
104
|
+
}),
|
|
105
|
+
authorize: async () => {
|
|
106
|
+
await call(async () => {
|
|
107
|
+
await (await auth()).accessToken(true);
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
export { createGoogleDriveStore, createICloudStore };
|
|
113
|
+
|
|
114
|
+
//# sourceMappingURL=cloud.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cloud.mjs","names":[],"sources":["../src/cloud.ts"],"sourcesContent":["import {\n checkCloudName,\n checkCloudText,\n CloudStoreError,\n createGoogleDriveCloudStore,\n} from \"@qntx/wallet-engine\";\nimport type { CloudStore, CloudStoreErrorCode, SetTimer } from \"@qntx/wallet-engine\";\n\nimport type { CloudKitStore, GoogleDriveAuth } from \"./specs/cloud.nitro.ts\";\n\nexport type CloudKitStoreLike = Pick<\n CloudKitStore,\n \"list\" | \"read\" | \"write\" | \"remove\" | \"setAccountListener\"\n>;\nexport type GoogleDriveAuthLike = Pick<GoogleDriveAuth, \"accessToken\" | \"clearToken\">;\nexport type ICloudStore = CloudStore & {\n /** Subscribes to iCloud account changes (sign-out, account switch); returns the unsubscribe. */\n readonly onAccountChange: (listener: () => void) => () => void;\n};\nexport type GoogleDriveStore = CloudStore & {\n /** Runs the interactive consent flow — call from a user action after `auth-required`. */\n readonly authorize: () => Promise<void>;\n};\n\nconst CLOUD_ERROR = /\\[qntx-cloud:(unavailable|auth-required|quota|failed)\\]/;\nconst CONTAINER_NAME = /^iCloud\\.[A-Za-z0-9.-]+$/;\n\n/** Decodes a native rejection into the typed fault; a missing token is `failed`. */\nfunction decode(error: unknown): CloudStoreError {\n const message = error instanceof Error ? error.message : \"native cloud call failed\";\n const match = CLOUD_ERROR.exec(message)?.[1];\n const code: CloudStoreErrorCode =\n match === \"unavailable\" || match === \"auth-required\" || match === \"quota\" || match === \"failed\"\n ? match\n : \"failed\";\n return new CloudStoreError(code, message);\n}\n\nconst call = async <T>(fn: () => Promise<T>): Promise<T> => {\n try {\n return await fn();\n } catch (error) {\n throw decode(error);\n }\n};\n\nconst setTimer: SetTimer = (ms, fn) => {\n const id = setTimeout(() => {\n fn();\n }, ms);\n return () => {\n clearTimeout(id);\n };\n};\n\n/**\n * The iCloud transport over the Nitro `CloudKitStore` hybrid. `native` is the test seam — by\n * default the hybrid is created lazily on first use through\n * `NitroModules.createHybridObject(\"CloudKitStore\")`.\n */\nexport function createICloudStore(options: {\n readonly container: string;\n readonly native?: CloudKitStoreLike;\n}): ICloudStore {\n if (!CONTAINER_NAME.test(options.container)) {\n throw new CloudStoreError(\"invalid\", \"iCloud container must look like iCloud.<identifier>\");\n }\n let { native } = options;\n const store = async (): Promise<CloudKitStoreLike> => {\n if (native === undefined) {\n const { NitroModules } = await import(\"react-native-nitro-modules\");\n native = NitroModules.createHybridObject<CloudKitStore>(\"CloudKitStore\");\n }\n return native;\n };\n const listeners = new Set<() => void>();\n let registered = false;\n const register = async (): Promise<void> => {\n registered = true;\n try {\n const native = await store();\n native.setAccountListener(() => {\n for (const listener of listeners) {\n listener();\n }\n });\n } catch {\n // Fire-and-forget: nobody awaits this — just let the next onAccountChange retry.\n registered = false;\n }\n };\n const callNative = async <T>(op: (native: CloudKitStoreLike) => Promise<T>): Promise<T> =>\n call(async () => {\n const native = await store();\n return op(native);\n });\n return {\n list: async () => callNative(async (native) => native.list(options.container)),\n read: async (name) => {\n checkCloudName(name);\n return callNative(async (native) => native.read(options.container, name));\n },\n write: async (name, text) => {\n checkCloudName(name);\n checkCloudText(text);\n return callNative(async (native) => native.write(options.container, name, text));\n },\n delete: async (name) => {\n checkCloudName(name);\n return callNative(async (native) => native.remove(options.container, name));\n },\n onAccountChange: (listener) => {\n listeners.add(listener);\n if (!registered) {\n void register();\n }\n return () => {\n listeners.delete(listener);\n };\n },\n };\n}\n\n/**\n * The Google Drive transport: the engine's `appDataFolder` adapter fed by the Nitro\n * `GoogleDriveAuth` hybrid for tokens. `native` is the test seam — by default the hybrid is created\n * lazily on first use through `NitroModules.createHybridObject(\"GoogleDriveAuth\")`.\n */\nexport function createGoogleDriveStore(options?: {\n readonly native?: GoogleDriveAuthLike;\n}): GoogleDriveStore {\n let native = options?.native;\n const auth = async (): Promise<GoogleDriveAuthLike> => {\n if (native === undefined) {\n const { NitroModules } = await import(\"react-native-nitro-modules\");\n native = NitroModules.createHybridObject<GoogleDriveAuth>(\"GoogleDriveAuth\");\n }\n return native;\n };\n const store = createGoogleDriveCloudStore({\n fetch: async (input, init) => globalThis.fetch(input, init),\n setTimer,\n token: async () =>\n call(async () => {\n const native = await auth();\n return native.accessToken(false);\n }),\n invalidateToken: async (token) =>\n call(async () => {\n const native = await auth();\n return native.clearToken(token);\n }),\n });\n return {\n ...store,\n authorize: async () => {\n await call(async () => {\n const native = await auth();\n await native.accessToken(true);\n });\n },\n };\n}\n"],"mappings":"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"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Wallet, WalletOptions } from "@qntx/wallet";
|
|
1
|
+
import { NativeAutoLockPolicy, Wallet, WalletOptions } from "@qntx/wallet";
|
|
2
2
|
import { MainPort } from "@qntx/wallet/host";
|
|
3
3
|
import { ProtocolValue } from "@qntx/wallet/protocol";
|
|
4
4
|
type KernelExitReason = "locked" | "crashed" | "integrity" | "background";
|
|
@@ -11,19 +11,28 @@ type KernelHostLike = {
|
|
|
11
11
|
readonly post: (frame: ArrayBuffer) => void;
|
|
12
12
|
readonly onMessage: (cb: (frame: ArrayBuffer) => void) => void;
|
|
13
13
|
readonly onExit: (cb: (reason: KernelExitReason) => void) => void;
|
|
14
|
+
/** Changes the background lock budget of the live kernel — applied by `setAutoLock`. */
|
|
15
|
+
readonly setBackgroundLock: (seconds: number) => void;
|
|
14
16
|
readonly lock: () => void;
|
|
15
17
|
};
|
|
16
18
|
export declare function spawnFromHost(host: KernelHostLike, backgroundLockSeconds: number): MainPort;
|
|
17
19
|
export declare const FRAME_MAX_BYTES: number;
|
|
18
|
-
type CborErrorCode = "oversize" | "truncated" | "malformed" | "float" | "unsafe-int" | "bigint" | "undefined" | "tag" | "non-string-key" | "duplicate-key" | "indefinite" | "bad-type";
|
|
20
|
+
type CborErrorCode = "oversize" | "truncated" | "malformed" | "float" | "unsafe-int" | "bigint" | "undefined" | "tag" | "non-string-key" | "duplicate-key" | "indefinite" | "lone-surrogate" | "bad-type";
|
|
19
21
|
export declare class CborError extends Error {
|
|
20
22
|
readonly code: CborErrorCode;
|
|
21
23
|
constructor(code: CborErrorCode, message: string);
|
|
22
24
|
}
|
|
23
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* Encode a `ProtocolValue` to a CBOR frame, enforcing the 1 MiB cap. `encodeInto` writes straight
|
|
27
|
+
* into an exact-size buffer the caller owns: `encode` reuses a module-level writer whose first
|
|
28
|
+
* chunk survives across calls, which would keep the last frame's bytes resident in cborg state.
|
|
29
|
+
*/
|
|
24
30
|
export declare function encodeFrame(value: ProtocolValue): ArrayBuffer;
|
|
25
31
|
/** Decode a CBOR frame back to a `ProtocolValue`, enforcing the 1 MiB cap and strictness. */
|
|
26
32
|
export declare function decodeFrame(frame: ArrayBuffer | Uint8Array): ProtocolValue;
|
|
33
|
+
export type NativeWallet = Wallet & {
|
|
34
|
+
readonly setAutoLock: (policy: NativeAutoLockPolicy) => void;
|
|
35
|
+
};
|
|
27
36
|
export type NativeWalletOptions = WalletOptions & {
|
|
28
37
|
/**
|
|
29
38
|
* Creates one `KernelHost` per kernel runtime (a Nitro hybrid object, or a like-shaped fake for
|
|
@@ -33,6 +42,6 @@ export type NativeWalletOptions = WalletOptions & {
|
|
|
33
42
|
*/
|
|
34
43
|
readonly createHost?: () => KernelHostLike;
|
|
35
44
|
};
|
|
36
|
-
export declare function createNativeWallet(options: NativeWalletOptions): Promise<
|
|
45
|
+
export declare function createNativeWallet(options: NativeWalletOptions): Promise<NativeWallet>;
|
|
37
46
|
export type { CborErrorCode, KernelExitReason, KernelHostLike };
|
|
38
47
|
//# sourceMappingURL=index.d.mts.map
|