@digitalshieldfe/react-native-backup-card-sdk 0.1.2 → 0.1.4
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 +17 -25
- package/android/build.gradle +49 -4
- package/android/consumer-rules.pro +0 -0
- package/android/proguard-rules.pro +21 -0
- package/android/src/main/AndroidManifest.xml +4 -1
- package/android/src/main/java/com/ziancube/backupcardsdk/BackupCardSdk.kt +478 -0
- package/android/src/main/java/com/ziancube/backupcardsdk/GPChannelNatives.java +41 -0
- package/android/src/main/java/com/ziancube/backupcardsdk/listener/ApiAsyncListener.java +13 -0
- package/android/src/main/java/com/ziancube/backupcardsdk/nfc/ApiNfc.java +173 -0
- package/android/src/main/java/com/ziancube/backupcardsdk/nfc/ImplNfc.java +39 -0
- package/android/src/main/java/com/ziancube/backupcardsdk/nfc/NfcComm.java +115 -0
- package/android/src/main/java/com/ziancube/backupcardsdk/utils/ApduParam.java +67 -0
- package/android/src/main/java/com/ziancube/backupcardsdk/utils/CommList.java +41 -0
- package/android/src/main/java/com/ziancube/backupcardsdk/utils/Utils.java +109 -0
- package/android/src/main/java/com/ziancube/reactnativebackupcardsdk/BackupCardSdkModule.kt +49 -81
- package/android/src/main/jni/CMakeLists.txt +60 -0
- package/android/src/main/jni/GPChannel/include/GPChannelSDK.h +306 -0
- package/android/src/main/jni/GPChannel/include/context/BaseContext.h +56 -0
- package/android/src/main/jni/GPChannel/include/device/ApduBuilder.hpp +72 -0
- package/android/src/main/jni/GPChannel/include/utility/Apdu.hpp +166 -0
- package/android/src/main/jni/GPChannel/include/utility/Debug.hpp +59 -0
- package/android/src/main/jni/GPChannel/include/utility/Singleton.h +34 -0
- package/android/src/main/jni/GPChannel/include/utility/mutex.h +24 -0
- package/android/src/main/jni/GPChannel/include/utility/trim.hpp +155 -0
- package/android/src/main/jni/GPChannel/include/utility/util.h +104 -0
- package/android/src/main/jni/GPChannel/include/utility/xFactory.hpp +26 -0
- package/android/src/main/jni/GPChannel/include/utility/xManager.hpp +84 -0
- package/android/src/main/jni/GPChannel/src/arm64-v8a/libJUB_GPC_APDU_SDK.a +0 -0
- package/android/src/main/jni/GPChannel/src/arm64-v8a/libTrezorCrypto.a +0 -0
- package/android/src/main/jni/GPChannel/src/armeabi-v7a/libJUB_GPC_APDU_SDK.a +0 -0
- package/android/src/main/jni/GPChannel/src/armeabi-v7a/libTrezorCrypto.a +0 -0
- package/android/src/main/jni/GPChannel/src/x86/libJUB_GPC_APDU_SDK.a +0 -0
- package/android/src/main/jni/GPChannel/src/x86/libTrezorCrypto.a +0 -0
- package/android/src/main/jni/src/implJni.cpp +313 -0
- package/android/src/main/jni/src/implJni.h +9 -0
- package/android/src/main/jni/utils/jsoncpp/AUTHORS +111 -0
- package/android/src/main/jni/utils/jsoncpp/CMakeLists.txt +159 -0
- package/android/src/main/jni/utils/jsoncpp/LICENSE +55 -0
- package/android/src/main/jni/utils/jsoncpp/README.md +135 -0
- package/android/src/main/jni/utils/jsoncpp/amalgamate.py +155 -0
- package/android/src/main/jni/utils/jsoncpp/appveyor.yml +22 -0
- package/android/src/main/jni/utils/jsoncpp/dev.makefile +35 -0
- package/android/src/main/jni/utils/jsoncpp/devtools/__init__.py +6 -0
- package/android/src/main/jni/utils/jsoncpp/devtools/agent_vmw7.json +33 -0
- package/android/src/main/jni/utils/jsoncpp/devtools/agent_vmxp.json +26 -0
- package/android/src/main/jni/utils/jsoncpp/devtools/antglob.py +205 -0
- package/android/src/main/jni/utils/jsoncpp/devtools/batchbuild.py +278 -0
- package/android/src/main/jni/utils/jsoncpp/devtools/fixeol.py +70 -0
- package/android/src/main/jni/utils/jsoncpp/devtools/licenseupdater.py +94 -0
- package/android/src/main/jni/utils/jsoncpp/devtools/tarball.py +52 -0
- package/android/src/main/jni/utils/jsoncpp/doxybuild.py +189 -0
- package/android/src/main/jni/utils/jsoncpp/include/CMakeLists.txt +2 -0
- package/android/src/main/jni/utils/jsoncpp/include/json/allocator.h +98 -0
- package/android/src/main/jni/utils/jsoncpp/include/json/assertions.h +54 -0
- package/android/src/main/jni/utils/jsoncpp/include/json/autolink.h +25 -0
- package/android/src/main/jni/utils/jsoncpp/include/json/config.h +187 -0
- package/android/src/main/jni/utils/jsoncpp/include/json/features.h +61 -0
- package/android/src/main/jni/utils/jsoncpp/include/json/forwards.h +37 -0
- package/android/src/main/jni/utils/jsoncpp/include/json/json.h +15 -0
- package/android/src/main/jni/utils/jsoncpp/include/json/reader.h +411 -0
- package/android/src/main/jni/utils/jsoncpp/include/json/value.h +888 -0
- package/android/src/main/jni/utils/jsoncpp/include/json/version.h +20 -0
- package/android/src/main/jni/utils/jsoncpp/include/json/writer.h +357 -0
- package/android/src/main/jni/utils/jsoncpp/makefiles/vs71/jsontest.vcproj +119 -0
- package/android/src/main/jni/utils/jsoncpp/makefiles/vs71/lib_json.vcproj +205 -0
- package/android/src/main/jni/utils/jsoncpp/makefiles/vs71/test_lib_json.vcproj +130 -0
- package/android/src/main/jni/utils/jsoncpp/makerelease.py +390 -0
- package/android/src/main/jni/utils/jsoncpp/meson.build +103 -0
- package/android/src/main/jni/utils/jsoncpp/pkg-config/jsoncpp.pc.in +9 -0
- package/android/src/main/jni/utils/jsoncpp/src/CMakeLists.txt +5 -0
- package/android/src/main/jni/utils/jsoncpp/src/jsontestrunner/CMakeLists.txt +25 -0
- package/android/src/main/jni/utils/jsoncpp/src/jsontestrunner/main.cpp +333 -0
- package/android/src/main/jni/utils/jsoncpp/src/lib_json/CMakeLists.txt +117 -0
- package/android/src/main/jni/utils/jsoncpp/src/lib_json/json_reader.cpp +2060 -0
- package/android/src/main/jni/utils/jsoncpp/src/lib_json/json_tool.h +114 -0
- package/android/src/main/jni/utils/jsoncpp/src/lib_json/json_value.cpp +1661 -0
- package/android/src/main/jni/utils/jsoncpp/src/lib_json/json_valueiterator.inl +167 -0
- package/android/src/main/jni/utils/jsoncpp/src/lib_json/json_writer.cpp +1233 -0
- package/android/src/main/jni/utils/jsoncpp/src/lib_json/version.h.in +20 -0
- package/android/src/main/jni/utils/jsoncpp/src/test_lib_json/CMakeLists.txt +38 -0
- package/android/src/main/jni/utils/jsoncpp/src/test_lib_json/jsontest.cpp +457 -0
- package/android/src/main/jni/utils/jsoncpp/src/test_lib_json/jsontest.h +286 -0
- package/android/src/main/jni/utils/jsoncpp/src/test_lib_json/main.cpp +2606 -0
- package/android/src/main/jni/utils/jsoncpp/travis.sh +23 -0
- package/android/src/main/jni/utils/jsoncpp/version +1 -0
- package/android/src/main/jni/utils/jsoncpp/version.in +1 -0
- package/android/src/main/jni/utils/logUtils.cpp +108 -0
- package/android/src/main/jni/utils/logUtils.h +87 -0
- package/android/src/main/jni/utils/mSIGNA/stdutils/uchar_vector.h +614 -0
- package/package.json +3 -3
- package/android/libs/backupcardsdk-1.0.0.aar +0 -0
|
@@ -0,0 +1,614 @@
|
|
|
1
|
+
////////////////////////////////////////////////////////////////////////////////
|
|
2
|
+
//
|
|
3
|
+
// uchar_vector.h
|
|
4
|
+
//
|
|
5
|
+
// Copyright (c) 2011-2012 Eric Lombrozo
|
|
6
|
+
// Copyright (c) 2011-2016 Ciphrex Corp.
|
|
7
|
+
//
|
|
8
|
+
// Distributed under the MIT software license, see the accompanying
|
|
9
|
+
// file LICENSE or http://www.opensource.org/licenses/mit-license.php.
|
|
10
|
+
//
|
|
11
|
+
|
|
12
|
+
#ifndef UCHAR_VECTOR_H__
|
|
13
|
+
#define UCHAR_VECTOR_H__
|
|
14
|
+
|
|
15
|
+
#include <stdio.h>
|
|
16
|
+
#include <stdint.h>
|
|
17
|
+
|
|
18
|
+
#include <iostream>
|
|
19
|
+
#include <cstring>
|
|
20
|
+
|
|
21
|
+
#include <vector>
|
|
22
|
+
#include <string>
|
|
23
|
+
#include <algorithm>
|
|
24
|
+
|
|
25
|
+
//#include "TrustWalletCore/TWBitcoinOpCodes.h"
|
|
26
|
+
//#include "BinaryCoding.h"
|
|
27
|
+
|
|
28
|
+
const char g_hexBytes[][3] = {
|
|
29
|
+
"00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f",
|
|
30
|
+
"10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f",
|
|
31
|
+
"20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f",
|
|
32
|
+
"30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f",
|
|
33
|
+
"40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f",
|
|
34
|
+
"50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f",
|
|
35
|
+
"60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f",
|
|
36
|
+
"70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f",
|
|
37
|
+
"80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f",
|
|
38
|
+
"90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f",
|
|
39
|
+
"a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af",
|
|
40
|
+
"b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf",
|
|
41
|
+
"c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf",
|
|
42
|
+
"d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df",
|
|
43
|
+
"e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef",
|
|
44
|
+
"f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const char base64chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
48
|
+
|
|
49
|
+
typedef unsigned int uint;
|
|
50
|
+
|
|
51
|
+
/// TODO: Add secure allocator capabilities
|
|
52
|
+
//template < class Allocator = allocator<unsigned char> >
|
|
53
|
+
class uchar_vector : public std::vector<unsigned char>//, Allocator>
|
|
54
|
+
{
|
|
55
|
+
public:
|
|
56
|
+
uchar_vector() : std::vector<unsigned char>() {
|
|
57
|
+
m_cur_it = begin(); m_last_op_it = begin();
|
|
58
|
+
}
|
|
59
|
+
uchar_vector(size_type n, const unsigned char& value = 0) : std::vector<unsigned char>(n, value) {
|
|
60
|
+
m_cur_it = begin(); m_last_op_it = begin();
|
|
61
|
+
}
|
|
62
|
+
template <class InputIterator> uchar_vector(InputIterator first, InputIterator last) : std::vector<unsigned char>(first, last) {
|
|
63
|
+
m_cur_it = begin(); m_last_op_it = begin();
|
|
64
|
+
}
|
|
65
|
+
uchar_vector(const std::vector<unsigned char>& vec) : std::vector<unsigned char>(vec) {
|
|
66
|
+
m_cur_it = begin(); m_last_op_it = begin();
|
|
67
|
+
}
|
|
68
|
+
uchar_vector(const unsigned char* array, unsigned int size) : std::vector<unsigned char>(array, array + size) {
|
|
69
|
+
m_cur_it = begin(); m_last_op_it = begin();
|
|
70
|
+
}
|
|
71
|
+
uchar_vector(const std::string& hex) {
|
|
72
|
+
this->setHex(hex);
|
|
73
|
+
m_cur_it = begin(); m_last_op_it = begin();
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
uchar_vector& operator+=(const std::vector<unsigned char>& rhs)
|
|
77
|
+
{
|
|
78
|
+
this->insert(this->end(), rhs.begin(), rhs.end());
|
|
79
|
+
return *this;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
uchar_vector& operator<<(const std::vector<unsigned char>& rhs)
|
|
83
|
+
{
|
|
84
|
+
this->insert(this->end(), rhs.begin(), rhs.end());
|
|
85
|
+
return *this;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
uchar_vector& operator<<(unsigned char byte)
|
|
89
|
+
{
|
|
90
|
+
this->push_back(byte);
|
|
91
|
+
return *this;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// // https://en.bitcoin.it/wiki/Script
|
|
95
|
+
// // JuBiter-defined
|
|
96
|
+
// uchar_vector& operator<<(uint16_t data)
|
|
97
|
+
// {
|
|
98
|
+
// uchar_vector _data;
|
|
99
|
+
// TW::encode16LE(data, _data);
|
|
100
|
+
// insert(end(), _data.begin(), _data.end());
|
|
101
|
+
// return *this;
|
|
102
|
+
// }
|
|
103
|
+
//
|
|
104
|
+
// // JuBiter-defined
|
|
105
|
+
// uchar_vector& operator<<(uint32_t data)
|
|
106
|
+
// {
|
|
107
|
+
// uchar_vector _data;
|
|
108
|
+
// TW::encode32LE(data, _data);
|
|
109
|
+
// insert(end(), _data.begin(), _data.end());
|
|
110
|
+
// return *this;
|
|
111
|
+
// }
|
|
112
|
+
//
|
|
113
|
+
// // JuBiter-defined
|
|
114
|
+
// uchar_vector& operator<<(uint64_t data)
|
|
115
|
+
// {
|
|
116
|
+
// uchar_vector _data;
|
|
117
|
+
// TW::encode64LE(data, _data);
|
|
118
|
+
// insert(end(), _data.begin(), _data.end());
|
|
119
|
+
// return *this;
|
|
120
|
+
// }
|
|
121
|
+
//
|
|
122
|
+
// // JuBiter-defined
|
|
123
|
+
// uchar_vector& operator<<(const std::string& str)
|
|
124
|
+
// {
|
|
125
|
+
// this->insert(this->end(), str.begin(), str.end());
|
|
126
|
+
// return *this;
|
|
127
|
+
// }
|
|
128
|
+
//
|
|
129
|
+
// // JuBiter-defined
|
|
130
|
+
// uchar_vector& operator<<(OpCode byte)
|
|
131
|
+
// {
|
|
132
|
+
// this->push_back((unsigned char)byte);
|
|
133
|
+
// return *this;
|
|
134
|
+
// }
|
|
135
|
+
//
|
|
136
|
+
// // JuBiter-defined
|
|
137
|
+
// // handling OP_PUSHDATA
|
|
138
|
+
// uchar_vector& operator &(const std::vector<unsigned char>& rhs)
|
|
139
|
+
// {
|
|
140
|
+
// if (rhs.size() < (unsigned char)OpCode::OP_PUSHDATA1)
|
|
141
|
+
// {
|
|
142
|
+
// insert(end(), (unsigned char)rhs.size());
|
|
143
|
+
// }
|
|
144
|
+
// else if (rhs.size() <= 0xff)
|
|
145
|
+
// {
|
|
146
|
+
// insert(end(), (unsigned char)OpCode::OP_PUSHDATA1);
|
|
147
|
+
// *this << (uint8_t)rhs.size();
|
|
148
|
+
// }
|
|
149
|
+
// else if (rhs.size() <= 0xffff)
|
|
150
|
+
// {
|
|
151
|
+
// insert(end(), (unsigned char)OpCode::OP_PUSHDATA2);
|
|
152
|
+
// *this << (uint16_t)rhs.size();
|
|
153
|
+
// }
|
|
154
|
+
// else
|
|
155
|
+
// {
|
|
156
|
+
// insert(end(), (unsigned char)OpCode::OP_PUSHDATA4);
|
|
157
|
+
// *this << (uint32_t)rhs.size();
|
|
158
|
+
// }
|
|
159
|
+
// insert(end(), rhs.begin(), rhs.end());
|
|
160
|
+
// return *this;
|
|
161
|
+
// }
|
|
162
|
+
//
|
|
163
|
+
// JuBiter-defined
|
|
164
|
+
uchar_vector build_compact_size(uint64_t size)
|
|
165
|
+
{
|
|
166
|
+
uchar_vector v;
|
|
167
|
+
if (size < 0xfd) {
|
|
168
|
+
v.insert(v.end(), (unsigned char)size);
|
|
169
|
+
}
|
|
170
|
+
else if (size <= 0xffff) {
|
|
171
|
+
v.insert(v.end(), 0xfd);
|
|
172
|
+
v << (uint16_t)size;
|
|
173
|
+
}
|
|
174
|
+
else if (size <= 0xffff) {
|
|
175
|
+
v.insert(v.end(), 0xfe);
|
|
176
|
+
v << (uint32_t)size;
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
v.insert(v.end(), 0xff);
|
|
180
|
+
v << size;
|
|
181
|
+
}
|
|
182
|
+
return v;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// JuBiter-defined
|
|
186
|
+
// script_code
|
|
187
|
+
uchar_vector& operator &&(const std::vector<unsigned char>& rhs)
|
|
188
|
+
{
|
|
189
|
+
auto v_size = build_compact_size(rhs.size());
|
|
190
|
+
insert(end(), v_size.begin(), v_size.end());
|
|
191
|
+
insert(end(), rhs.begin(), rhs.end());
|
|
192
|
+
return *this;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// JuBiter-defined
|
|
196
|
+
uchar_vector& operator &&(const std::string& str)
|
|
197
|
+
{
|
|
198
|
+
auto v_size = build_compact_size(str.length());
|
|
199
|
+
insert(end(), v_size.begin(), v_size.end());
|
|
200
|
+
insert(end(), str.begin(), str.end());
|
|
201
|
+
return *this;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
const uchar_vector operator+(const std::vector<unsigned char>& rightOperand) const { return uchar_vector(*this) += rightOperand; }
|
|
205
|
+
|
|
206
|
+
uchar_vector& operator=(const std::string& hex) { this->setHex(hex); return *this; }
|
|
207
|
+
|
|
208
|
+
void copyToArray(unsigned char* array) { std::copy(this->begin(),this->end(), array); }
|
|
209
|
+
|
|
210
|
+
void padLeft(unsigned char pad, uint total_length)
|
|
211
|
+
{
|
|
212
|
+
this->reverse();
|
|
213
|
+
this->padRight(pad, total_length);
|
|
214
|
+
this->reverse();
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
void padRight(unsigned char pad, uint total_length)
|
|
218
|
+
{
|
|
219
|
+
for (uint i = (uint)this->size(); i < total_length; i++)
|
|
220
|
+
this->push_back(pad);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
std::string getHex(bool spaceBytes = false) const
|
|
224
|
+
{
|
|
225
|
+
std::string hex;
|
|
226
|
+
hex.reserve(this->size() * 2);
|
|
227
|
+
for (uint i = 0; i < this->size(); i++) {
|
|
228
|
+
if (spaceBytes && (i > 0)) hex += " ";
|
|
229
|
+
hex += g_hexBytes[(*this)[i]];
|
|
230
|
+
}
|
|
231
|
+
return hex;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
void setHex(std::string hex)
|
|
235
|
+
{
|
|
236
|
+
this->clear();
|
|
237
|
+
|
|
238
|
+
// pad on the left if hex contains an odd number of digits.
|
|
239
|
+
if (hex.size() % 2 == 1)
|
|
240
|
+
hex = "0" + hex;
|
|
241
|
+
|
|
242
|
+
this->reserve(hex.size() / 2);
|
|
243
|
+
|
|
244
|
+
for (uint i = 0; i < hex.size(); i+=2) {
|
|
245
|
+
uint byte;
|
|
246
|
+
sscanf(hex.substr(i, 2).c_str(), "%x", &byte);
|
|
247
|
+
this->push_back(byte);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
void reverse() { std::reverse(this->begin(), this->end()); }
|
|
252
|
+
|
|
253
|
+
uchar_vector getReverse() const
|
|
254
|
+
{
|
|
255
|
+
uchar_vector rval(*this);
|
|
256
|
+
rval.reverse();
|
|
257
|
+
return rval;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
std::string getCharsAsString() const
|
|
261
|
+
{
|
|
262
|
+
std::string chars;
|
|
263
|
+
chars.reserve(this->size());
|
|
264
|
+
for (uint i = 0; i < this->size(); i++)
|
|
265
|
+
chars += (*this)[i];
|
|
266
|
+
return chars;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
void setCharsFromString(const std::string& chars)
|
|
270
|
+
{
|
|
271
|
+
this->clear();
|
|
272
|
+
this->reserve(chars.size());
|
|
273
|
+
for (uint i = 0; i < chars.size(); i++)
|
|
274
|
+
this->push_back(chars[i]);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
std::string getBase64() const
|
|
278
|
+
{
|
|
279
|
+
unsigned int padding = (3 - (this->size() % 3)) % 3;
|
|
280
|
+
std::string base64;
|
|
281
|
+
|
|
282
|
+
uchar_vector paddedBytes = *this;
|
|
283
|
+
for (unsigned int i = 1; i <= padding; i++)
|
|
284
|
+
paddedBytes.push_back(0);
|
|
285
|
+
|
|
286
|
+
base64.reserve(4*(paddedBytes.size()) / 3);
|
|
287
|
+
|
|
288
|
+
for (unsigned int i = 0; i < paddedBytes.size(); i += 3) {
|
|
289
|
+
uint32_t triple = ((uint32_t)paddedBytes[i] << 16) | ((uint32_t)paddedBytes[i+1] << 8) | (uint32_t)paddedBytes[i+2];
|
|
290
|
+
base64 += base64chars[(triple & 0x00fc0000) >> 18];
|
|
291
|
+
base64 += base64chars[(triple & 0x0003f000) >> 12];
|
|
292
|
+
base64 += base64chars[(triple & 0x00000fc0) >> 6];
|
|
293
|
+
base64 += base64chars[triple & 0x0000003f];
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
for (unsigned int i = 1; i <= padding; i++)
|
|
297
|
+
base64[base64.size() - i] = '=';
|
|
298
|
+
|
|
299
|
+
return base64;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
void setBase64(std::string base64)
|
|
303
|
+
{
|
|
304
|
+
unsigned int padding = (4 - (base64.size() % 4)) % 4;
|
|
305
|
+
|
|
306
|
+
std::string paddedBase64;
|
|
307
|
+
paddedBase64.reserve(base64.size() + padding);
|
|
308
|
+
paddedBase64 = base64;
|
|
309
|
+
paddedBase64.append(padding, '=');
|
|
310
|
+
padding = 0; // we'll count them again in the loop so we also get any that were already there.
|
|
311
|
+
|
|
312
|
+
this->clear();
|
|
313
|
+
this->reserve(3*paddedBase64.size() / 4);
|
|
314
|
+
|
|
315
|
+
bool bEnd = false;
|
|
316
|
+
for (unsigned int i = 0; (i < paddedBase64.size()) && (!bEnd); i+=4) {
|
|
317
|
+
uint32_t digits[4];
|
|
318
|
+
for (unsigned int j = 0; j < 4; j++) {
|
|
319
|
+
const char* pPos = strchr(base64chars, paddedBase64[i+j]);
|
|
320
|
+
if (!pPos) bEnd = true;
|
|
321
|
+
if (bEnd) {
|
|
322
|
+
digits[j] = 0;
|
|
323
|
+
padding++;
|
|
324
|
+
}
|
|
325
|
+
else
|
|
326
|
+
digits[j] = (uint32_t)(pPos - base64chars);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
uint32_t quadruple = (digits[0] << 18) | (digits[1] << 12) | (digits[2] << 6) | digits[3];
|
|
330
|
+
|
|
331
|
+
this->push_back((quadruple & 0x00ff0000) >> 16);
|
|
332
|
+
this->push_back((quadruple & 0x0000ff00) >> 8);
|
|
333
|
+
this->push_back(quadruple & 0x000000ff);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
for (unsigned int i = 0; i < padding; i++)
|
|
337
|
+
this->pop_back();
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
// // for deserialize
|
|
341
|
+
// // JuBiter-defined
|
|
342
|
+
// uint64_t read_compact_size() {
|
|
343
|
+
// if (m_cur_it == end()) {
|
|
344
|
+
// std::string _err = "error in data index: ";
|
|
345
|
+
// _err += std::to_string(m_last_op_it - begin());
|
|
346
|
+
// throw std::runtime_error(_err);
|
|
347
|
+
// }
|
|
348
|
+
// uint64_t len = 0;
|
|
349
|
+
// if (*m_cur_it == 0xfd) {
|
|
350
|
+
// m_last_op_it = m_cur_it;
|
|
351
|
+
// m_cur_it++;
|
|
352
|
+
// len = read_le_uint16();
|
|
353
|
+
// }
|
|
354
|
+
// else if (*m_cur_it == 0xfe) {
|
|
355
|
+
// m_last_op_it = m_cur_it;
|
|
356
|
+
// m_cur_it++;
|
|
357
|
+
// len = read_le_uint32();
|
|
358
|
+
// }
|
|
359
|
+
// else if (*m_cur_it == 0xff) {
|
|
360
|
+
// m_last_op_it = m_cur_it;
|
|
361
|
+
// m_cur_it++;
|
|
362
|
+
// len = read_le_uint64();
|
|
363
|
+
// }
|
|
364
|
+
// else {
|
|
365
|
+
// len = read_uint8();
|
|
366
|
+
// }
|
|
367
|
+
//
|
|
368
|
+
// return len;
|
|
369
|
+
// }
|
|
370
|
+
//
|
|
371
|
+
// uchar_vector& operator | (uchar_vector& v)
|
|
372
|
+
// {
|
|
373
|
+
// if (m_cur_it == end())
|
|
374
|
+
// {
|
|
375
|
+
// std::string _err = "error in data index: ";
|
|
376
|
+
// _err += std::to_string(m_last_op_it - begin());
|
|
377
|
+
// throw std::runtime_error(_err);
|
|
378
|
+
// }
|
|
379
|
+
//
|
|
380
|
+
// uint32_t len = 0;
|
|
381
|
+
// if (*m_cur_it == (unsigned char)OpCode::OP_PUSHDATA1)
|
|
382
|
+
// {
|
|
383
|
+
// m_last_op_it = m_cur_it;
|
|
384
|
+
// m_cur_it++;
|
|
385
|
+
// len = read_uint8();
|
|
386
|
+
// }
|
|
387
|
+
// else if (*m_cur_it == (unsigned char)OpCode::OP_PUSHDATA2)
|
|
388
|
+
// {
|
|
389
|
+
// m_last_op_it = m_cur_it;
|
|
390
|
+
// m_cur_it ++;
|
|
391
|
+
// len = read_le_uint16();
|
|
392
|
+
// }
|
|
393
|
+
// else if (*m_cur_it == (unsigned char)OpCode::OP_PUSHDATA4)
|
|
394
|
+
// {
|
|
395
|
+
// m_last_op_it = m_cur_it;
|
|
396
|
+
// m_cur_it++;
|
|
397
|
+
// len = read_le_uint32();
|
|
398
|
+
// }
|
|
399
|
+
// else
|
|
400
|
+
// {
|
|
401
|
+
// len = read_uint8();
|
|
402
|
+
// }
|
|
403
|
+
// if (end()- m_cur_it < len)
|
|
404
|
+
// {
|
|
405
|
+
// std::string _err = "error in data index: ";
|
|
406
|
+
// _err += std::to_string(m_last_op_it - begin());
|
|
407
|
+
// throw std::runtime_error(_err);
|
|
408
|
+
// }
|
|
409
|
+
// v.clear();
|
|
410
|
+
// v.insert(v.end(), m_cur_it, m_cur_it + len);
|
|
411
|
+
// v.reset_it();
|
|
412
|
+
// m_last_op_it = m_cur_it;
|
|
413
|
+
// m_cur_it += len;
|
|
414
|
+
// return *this;
|
|
415
|
+
// }
|
|
416
|
+
//
|
|
417
|
+
// uchar_vector& operator || (uchar_vector& v)
|
|
418
|
+
// {
|
|
419
|
+
// uint64_t len = read_compact_size();
|
|
420
|
+
//
|
|
421
|
+
// if (end() - m_cur_it < len)
|
|
422
|
+
// {
|
|
423
|
+
// std::string _err = "error in data index: ";
|
|
424
|
+
// _err += std::to_string(m_last_op_it - begin());
|
|
425
|
+
// throw std::runtime_error(_err);
|
|
426
|
+
// }
|
|
427
|
+
// v.clear();
|
|
428
|
+
// v.insert(v.end(), m_cur_it, m_cur_it + len);
|
|
429
|
+
// v.reset_it();
|
|
430
|
+
// m_last_op_it = m_cur_it;
|
|
431
|
+
// m_cur_it += len;
|
|
432
|
+
// return *this;
|
|
433
|
+
// }
|
|
434
|
+
//
|
|
435
|
+
// // JuBiter-defined
|
|
436
|
+
// uchar_vector& operator >> (uchar_vector& v) {
|
|
437
|
+
// uint64_t len = read_compact_size();
|
|
438
|
+
//
|
|
439
|
+
// if (end() - m_cur_it < len) {
|
|
440
|
+
// std::string _err = "error in data index: ";
|
|
441
|
+
// _err += std::to_string(m_last_op_it - begin());
|
|
442
|
+
// throw std::runtime_error(_err);
|
|
443
|
+
// }
|
|
444
|
+
// v.clear();
|
|
445
|
+
// v.insert(v.end(), m_cur_it, m_cur_it + len);
|
|
446
|
+
// v.reset_it();
|
|
447
|
+
// m_last_op_it = m_cur_it;
|
|
448
|
+
// m_cur_it += len;
|
|
449
|
+
// return *this;
|
|
450
|
+
// }
|
|
451
|
+
|
|
452
|
+
// JuBiter-defined
|
|
453
|
+
uint8_t read_uint8() {
|
|
454
|
+
if (end() - m_cur_it < 1) {
|
|
455
|
+
std::string _err = "error in data index: ";
|
|
456
|
+
_err += std::to_string(m_last_op_it - begin());
|
|
457
|
+
throw std::runtime_error(_err);
|
|
458
|
+
}
|
|
459
|
+
m_last_op_it = m_cur_it;
|
|
460
|
+
return *(m_cur_it++);
|
|
461
|
+
};
|
|
462
|
+
|
|
463
|
+
// // JuBiter-defined
|
|
464
|
+
// uint16_t read_le_uint16() {
|
|
465
|
+
// if (end() - m_cur_it < 2) {
|
|
466
|
+
// std::string _err = "error in data index: ";
|
|
467
|
+
// _err += std::to_string(m_last_op_it - begin());
|
|
468
|
+
// throw std::runtime_error(_err);
|
|
469
|
+
// }
|
|
470
|
+
// uint16_t d = TW::decode16LE(&(*m_cur_it));
|
|
471
|
+
// m_last_op_it = m_cur_it;
|
|
472
|
+
// m_cur_it += 2;
|
|
473
|
+
// return d;
|
|
474
|
+
// };
|
|
475
|
+
//
|
|
476
|
+
// // JuBiter-defined
|
|
477
|
+
// uint16_t read_be_uint16() {
|
|
478
|
+
// if (end() - m_cur_it < 2) {
|
|
479
|
+
// std::string _err = "error in data index: ";
|
|
480
|
+
// _err += std::to_string(m_last_op_it - begin());
|
|
481
|
+
// throw std::runtime_error(_err);
|
|
482
|
+
// }
|
|
483
|
+
// uint16_t d = TW::decode16BE(&(*m_cur_it));
|
|
484
|
+
// m_last_op_it = m_cur_it;
|
|
485
|
+
// m_cur_it += 2;
|
|
486
|
+
// return d;
|
|
487
|
+
// };
|
|
488
|
+
//
|
|
489
|
+
// // JuBiter-defined
|
|
490
|
+
// uint32_t read_le_uint32() {
|
|
491
|
+
// if (end()- m_cur_it < 4) {
|
|
492
|
+
// std::string _err = "error in data index: ";
|
|
493
|
+
// _err += std::to_string(m_last_op_it - begin());
|
|
494
|
+
// throw std::runtime_error(_err);
|
|
495
|
+
// }
|
|
496
|
+
// uint32_t d = TW::decode32LE(&(*m_cur_it));
|
|
497
|
+
// m_last_op_it = m_cur_it;
|
|
498
|
+
// m_cur_it += 4;
|
|
499
|
+
// return d;
|
|
500
|
+
// }
|
|
501
|
+
//
|
|
502
|
+
// // JuBiter-defined
|
|
503
|
+
// uint32_t read_be_uint32() {
|
|
504
|
+
// if (end()- m_cur_it < 4) {
|
|
505
|
+
// std::string _err = "error in data index: ";
|
|
506
|
+
// _err += std::to_string(m_last_op_it - begin());
|
|
507
|
+
// throw std::runtime_error(_err);
|
|
508
|
+
// }
|
|
509
|
+
// uint32_t d = TW::decode32BE(&(*m_cur_it));
|
|
510
|
+
// m_last_op_it = m_cur_it;
|
|
511
|
+
// m_cur_it += 4;
|
|
512
|
+
// return d;
|
|
513
|
+
// }
|
|
514
|
+
//
|
|
515
|
+
// // JuBiter-defined
|
|
516
|
+
// uint64_t read_le_uint64() {
|
|
517
|
+
// if (end() - m_cur_it < 8) {
|
|
518
|
+
// std::string _err = "error in data index: ";
|
|
519
|
+
// _err += std::to_string(m_last_op_it - begin());
|
|
520
|
+
// throw std::runtime_error(_err);
|
|
521
|
+
// }
|
|
522
|
+
// uint64_t d = TW::decode64LE(&(*m_cur_it));
|
|
523
|
+
// m_last_op_it = m_cur_it;
|
|
524
|
+
// m_cur_it += 8;
|
|
525
|
+
// return d;
|
|
526
|
+
// }
|
|
527
|
+
//
|
|
528
|
+
// // JuBiter-defined
|
|
529
|
+
// uint64_t read_be_uint64() {
|
|
530
|
+
// if (end() - m_cur_it < 8) {
|
|
531
|
+
// std::string _err = "error in data index: ";
|
|
532
|
+
// _err += std::to_string(m_last_op_it - begin());
|
|
533
|
+
// throw std::runtime_error(_err);
|
|
534
|
+
// }
|
|
535
|
+
// uint64_t d = TW::decode64BE(&(*m_cur_it));
|
|
536
|
+
// m_last_op_it = m_cur_it;
|
|
537
|
+
// m_cur_it += 8;
|
|
538
|
+
// return d;
|
|
539
|
+
// }
|
|
540
|
+
//
|
|
541
|
+
// JuBiter-defined
|
|
542
|
+
uchar_vector read_vector(size_t len) {
|
|
543
|
+
if (end() - m_cur_it < len) {
|
|
544
|
+
std::string _err = "error in data index: ";
|
|
545
|
+
_err += std::to_string(m_last_op_it - begin());
|
|
546
|
+
throw std::runtime_error(_err);
|
|
547
|
+
}
|
|
548
|
+
uchar_vector v;
|
|
549
|
+
v.insert(v.begin(), m_cur_it, m_cur_it + len);
|
|
550
|
+
v.reset_it();
|
|
551
|
+
m_last_op_it = m_cur_it;
|
|
552
|
+
m_cur_it = m_cur_it + len;
|
|
553
|
+
return v;
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
void reset_it() { m_cur_it = begin(); m_last_op_it = begin();}
|
|
557
|
+
void reset_it(int offset) { m_cur_it = m_cur_it + offset; };
|
|
558
|
+
std::vector<unsigned char>::iterator get_cur_it() {
|
|
559
|
+
return m_cur_it;
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
private:
|
|
563
|
+
std::vector<unsigned char>::iterator m_cur_it;
|
|
564
|
+
std::vector<unsigned char>::iterator m_last_op_it;
|
|
565
|
+
};
|
|
566
|
+
|
|
567
|
+
typedef std::string string_secure;
|
|
568
|
+
typedef uchar_vector uchar_vector_secure; // not really :p at least not yet!
|
|
569
|
+
/*
|
|
570
|
+
//
|
|
571
|
+
// Allocator that locks its contents from being paged
|
|
572
|
+
// out of memory and clears its contents before deletion.
|
|
573
|
+
//
|
|
574
|
+
template<typename T>
|
|
575
|
+
struct secure_allocator : public std::allocator<T>
|
|
576
|
+
{
|
|
577
|
+
// MSVC8 default copy constructor is broken
|
|
578
|
+
typedef std::allocator<T> base;
|
|
579
|
+
typedef typename base::size_type size_type;
|
|
580
|
+
typedef typename base::difference_type difference_type;
|
|
581
|
+
typedef typename base::pointer pointer;
|
|
582
|
+
typedef typename base::const_pointer const_pointer;
|
|
583
|
+
typedef typename base::reference reference;
|
|
584
|
+
typedef typename base::const_reference const_reference;
|
|
585
|
+
typedef typename base::value_type value_type;
|
|
586
|
+
secure_allocator() throw() {}
|
|
587
|
+
secure_allocator(const secure_allocator& a) throw() : base(a) {}
|
|
588
|
+
template <typename U>
|
|
589
|
+
secure_allocator(const secure_allocator<U>& a) throw() : base(a) {}
|
|
590
|
+
~secure_allocator() throw() {}
|
|
591
|
+
template<typename _Other> struct rebind
|
|
592
|
+
{ typedef secure_allocator<_Other> other; };
|
|
593
|
+
|
|
594
|
+
T* allocate(std::size_t n, const void *hint = 0)
|
|
595
|
+
{
|
|
596
|
+
T *p;
|
|
597
|
+
p = std::allocator<T>::allocate(n, hint);
|
|
598
|
+
if (p != NULL)
|
|
599
|
+
mlock(p, sizeof(T) * n);
|
|
600
|
+
return p;
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
void deallocate(T* p, std::size_t n)
|
|
604
|
+
{
|
|
605
|
+
if (p != NULL)
|
|
606
|
+
{
|
|
607
|
+
memset(p, 0, sizeof(T) * n);
|
|
608
|
+
munlock(p, sizeof(T) * n);
|
|
609
|
+
}
|
|
610
|
+
std::allocator<T>::deallocate(p, n);
|
|
611
|
+
}
|
|
612
|
+
};
|
|
613
|
+
*/
|
|
614
|
+
#endif
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@digitalshieldfe/react-native-backup-card-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "ds react-native backup-card sdk",
|
|
5
5
|
"main": "./lib/module/index.js",
|
|
6
6
|
"types": "./lib/typescript/src/index.d.ts",
|
|
@@ -34,8 +34,7 @@
|
|
|
34
34
|
"scripts": {
|
|
35
35
|
"example": "yarn workspace react-native-backup-card-sdk-example",
|
|
36
36
|
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
|
|
37
|
-
"
|
|
38
|
-
"prepare": "node scripts/sync-backupcardsdk-aar.js && bob build",
|
|
37
|
+
"prepare": "bob build",
|
|
39
38
|
"typecheck": "tsc",
|
|
40
39
|
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
41
40
|
"test": "jest",
|
|
@@ -71,6 +70,7 @@
|
|
|
71
70
|
"@react-native/eslint-config": "0.85.1",
|
|
72
71
|
"@react-native/jest-preset": "0.85.1",
|
|
73
72
|
"@release-it/conventional-changelog": "^10.0.6",
|
|
73
|
+
"@types/node": "^25.9.1",
|
|
74
74
|
"@types/react": "^19.2.0",
|
|
75
75
|
"commitlint": "^20.5.0",
|
|
76
76
|
"del-cli": "^7.0.0",
|
|
Binary file
|