react-native-mfa-trustbuilder 0.1.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/LICENSE +20 -0
- package/README.md +202 -0
- package/Trustbuilder.podspec +29 -0
- package/android/build.gradle +74 -0
- package/android/libs/iwlib-mac-0.2.17.jar +0 -0
- package/android/proguard-rules.pro +2 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/com/trustbuilder/SimpleWebServiceCall.kt +40 -0
- package/android/src/main/java/com/trustbuilder/TrustbuilderModule.kt +590 -0
- package/android/src/main/java/com/trustbuilder/TrustbuilderPackage.kt +32 -0
- package/ios/RNTrustbuilder.h +5 -0
- package/ios/RNTrustbuilder.mm +433 -0
- package/ios/iw.h +785 -0
- package/ios/libs/libmaccess-0.2.19-ios-arm64_armv7.a +0 -0
- package/ios/libs/libmaccess-0.2.19-ios-arm64_i386_x86_64-simulator.a +0 -0
- package/lib/module/NativeRNTrustbuilder.js +5 -0
- package/lib/module/NativeRNTrustbuilder.js.map +1 -0
- package/lib/module/errors.js +64 -0
- package/lib/module/errors.js.map +1 -0
- package/lib/module/index.js +309 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/types.js +2 -0
- package/lib/module/types.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/NativeRNTrustbuilder.d.ts +89 -0
- package/lib/typescript/src/NativeRNTrustbuilder.d.ts.map +1 -0
- package/lib/typescript/src/errors.d.ts +29 -0
- package/lib/typescript/src/errors.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +68 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/types.d.ts +45 -0
- package/lib/typescript/src/types.d.ts.map +1 -0
- package/package.json +184 -0
- package/src/NativeRNTrustbuilder.ts +117 -0
- package/src/errors.ts +72 -0
- package/src/index.ts +461 -0
- package/src/types.ts +54 -0
|
@@ -0,0 +1,433 @@
|
|
|
1
|
+
#import "RNTrustbuilder.h"
|
|
2
|
+
#import "iw.h"
|
|
3
|
+
#import <React/RCTEventEmitter.h>
|
|
4
|
+
|
|
5
|
+
@interface RNTrustbuilder () <RCTBridgeModule>
|
|
6
|
+
@property (nonatomic, assign) IW *iw;
|
|
7
|
+
@property (nonatomic, assign) BOOL isInitialized;
|
|
8
|
+
@property (nonatomic, strong) NSCondition *webCallCondition;
|
|
9
|
+
@property (nonatomic, strong) NSString *webCallResult;
|
|
10
|
+
@end
|
|
11
|
+
|
|
12
|
+
@implementation RNTrustbuilder
|
|
13
|
+
|
|
14
|
+
RCT_EXPORT_MODULE()
|
|
15
|
+
|
|
16
|
+
- (instancetype)init {
|
|
17
|
+
self = [super init];
|
|
18
|
+
if (self) {
|
|
19
|
+
_webCallCondition = [[NSCondition alloc] init];
|
|
20
|
+
_isInitialized = NO;
|
|
21
|
+
}
|
|
22
|
+
return self;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
- (void)saveStorage {
|
|
26
|
+
if (IWStorageDataChanged(self.iw) > 0) {
|
|
27
|
+
char *data = IWStorageDataGet(self.iw);
|
|
28
|
+
if (data) {
|
|
29
|
+
NSString *dataStr = [NSString stringWithCString:data encoding:NSISOLatin1StringEncoding];
|
|
30
|
+
[self setStorageDataInternal:dataStr];
|
|
31
|
+
IWStorageDataRelease(self.iw);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
- (NSString *)getStorageDataInternal {
|
|
37
|
+
NSString *data = [[NSUserDefaults standardUserDefaults] stringForKey:@"trustbuilder_storage_data"];
|
|
38
|
+
return data ?: @"";
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
- (void)setStorageDataInternal:(NSString *)data {
|
|
42
|
+
[[NSUserDefaults standardUserDefaults] setObject:data forKey:@"trustbuilder_storage_data"];
|
|
43
|
+
[[NSUserDefaults standardUserDefaults] synchronize];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
- (IW *)createIWInstance {
|
|
47
|
+
return nil;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
- (NSNumber *)initialize:(NSString *)config {
|
|
51
|
+
NSError *error = nil;
|
|
52
|
+
NSData *configData = [config dataUsingEncoding:NSUTF8StringEncoding];
|
|
53
|
+
NSDictionary *configDict = [NSJSONSerialization JSONObjectWithData:configData options:0 error:&error];
|
|
54
|
+
|
|
55
|
+
NSString *macId = configDict[@"macId"];
|
|
56
|
+
NSString *server = configDict[@"server"] ?: @"https://www.myinwebo.com";
|
|
57
|
+
NSString *hostVersion = configDict[@"hostVersion"] ?: @"react-native-mfa-trustbuilder-0.1.0";
|
|
58
|
+
NSInteger timeout = [configDict[@"timeout"] integerValue] ?: 60000;
|
|
59
|
+
NSString *lang = configDict[@"lang"] ?: @"1";
|
|
60
|
+
|
|
61
|
+
NSString *sn = [[UIDevice currentDevice] identifierForVendor].UUIDString;
|
|
62
|
+
NSString *appData = @"_";
|
|
63
|
+
|
|
64
|
+
char *cSN = strdup([sn UTF8String]);
|
|
65
|
+
char *cAppData = strdup([appData UTF8String]);
|
|
66
|
+
|
|
67
|
+
__weak RNTrustbuilder *weakSelf = self;
|
|
68
|
+
|
|
69
|
+
self.iw = IWInit(0, cSN, cAppData, ^(char *url, int timeoutMs, void *user) {
|
|
70
|
+
RNTrustbuilder *strongSelf = weakSelf;
|
|
71
|
+
if (!strongSelf) return;
|
|
72
|
+
|
|
73
|
+
NSString *urlStr = [NSString stringWithCString:url encoding:NSISOLatin1StringEncoding];
|
|
74
|
+
|
|
75
|
+
NSURL *nsUrl = [NSURL URLWithString:urlStr];
|
|
76
|
+
NSURLRequest *request = [NSURLRequest requestWithURL:nsUrl
|
|
77
|
+
timeoutInterval:timeoutMs / 1000.0];
|
|
78
|
+
|
|
79
|
+
__block NSString *resultStr = nil;
|
|
80
|
+
__block BOOL completed = NO;
|
|
81
|
+
|
|
82
|
+
[[[NSURLSession sharedSession] dataTaskWithRequest:request
|
|
83
|
+
completionHandler:^(NSData *data, NSURLResponse *response, NSError *err) {
|
|
84
|
+
if (data && !err) {
|
|
85
|
+
const char *bytes = (const char *)[data bytes];
|
|
86
|
+
char *buffer = malloc([data length] + 1);
|
|
87
|
+
memcpy(buffer, bytes, [data length]);
|
|
88
|
+
buffer[[data length]] = '\0';
|
|
89
|
+
|
|
90
|
+
IWSetWsBuffer(user, buffer);
|
|
91
|
+
free(buffer);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
[strongSelf.webCallCondition lock];
|
|
95
|
+
completed = YES;
|
|
96
|
+
[strongSelf.webCallCondition signal];
|
|
97
|
+
[strongSelf.webCallCondition unlock];
|
|
98
|
+
}] resume];
|
|
99
|
+
|
|
100
|
+
[strongSelf.webCallCondition lock];
|
|
101
|
+
while (!completed) {
|
|
102
|
+
[strongSelf.webCallCondition wait];
|
|
103
|
+
}
|
|
104
|
+
[strongSelf.webCallCondition unlock];
|
|
105
|
+
}, NULL);
|
|
106
|
+
|
|
107
|
+
free(cSN);
|
|
108
|
+
free(cAppData);
|
|
109
|
+
|
|
110
|
+
IWHostVersionSet(self.iw, strdup([hostVersion UTF8String]));
|
|
111
|
+
IWWsServerSet(self.iw, strdup([server UTF8String]));
|
|
112
|
+
IWWsTimeoutSet(self.iw, (int)timeout);
|
|
113
|
+
IWMaccessSet(self.iw, strdup([macId UTF8String]));
|
|
114
|
+
IWLangSet(self.iw, strdup([lang UTF8String]));
|
|
115
|
+
|
|
116
|
+
NSString *storedData = [self getStorageDataInternal] ?: @"";
|
|
117
|
+
char *cData = strdup([storedData cStringUsingEncoding:NSISOLatin1StringEncoding]);
|
|
118
|
+
IWStorageDataSet(self.iw, cData);
|
|
119
|
+
free(cData);
|
|
120
|
+
|
|
121
|
+
self.isInitialized = YES;
|
|
122
|
+
|
|
123
|
+
NSDictionary *result = @{
|
|
124
|
+
@"isActivated": @(IWIsActivated(self.iw) == 1),
|
|
125
|
+
@"isBlocked": @(IWIsBlocked(self.iw) == 1)
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:result options:0 error:nil];
|
|
129
|
+
return [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
- (BOOL)setStorageData:(NSString *)data {
|
|
133
|
+
[self setStorageDataInternal:data];
|
|
134
|
+
char *cData = strdup([data cStringUsingEncoding:NSISOLatin1StringEncoding]);
|
|
135
|
+
int result = IWStorageDataSet(self.iw, cData);
|
|
136
|
+
free(cData);
|
|
137
|
+
return result == IW_ERR_OK;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
- (NSString *)getStorageData {
|
|
141
|
+
return [self getStorageDataInternal];
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
- (BOOL)storageDataChanged {
|
|
145
|
+
return IWStorageDataChanged(self.iw) > 0;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
- (BOOL)isActivated {
|
|
149
|
+
return IWIsActivated(self.iw) == 1;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
- (BOOL)isBlocked {
|
|
153
|
+
return IWIsBlocked(self.iw) == 1;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
- (BOOL)mustUpgrade {
|
|
157
|
+
return IWMustUpgrade(self.iw) == 1;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
- (NSString *)activationStart:(NSString *)code {
|
|
161
|
+
char *cCode = strdup([code UTF8String]);
|
|
162
|
+
int result = IWActivationStart(self.iw, cCode);
|
|
163
|
+
free(cCode);
|
|
164
|
+
return [NSString stringWithFormat:@"%d", result];
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
- (NSString *)activationFinalize:(NSString *)code pin:(NSString *)pin name:(NSString *)name {
|
|
168
|
+
char *cCode = strdup([code UTF8String]);
|
|
169
|
+
char *cPin = strdup([pin UTF8String]);
|
|
170
|
+
char *cName = strdup([name UTF8String]);
|
|
171
|
+
int result = IWActivationFinalize(self.iw, cCode, cPin, cName);
|
|
172
|
+
free(cCode);
|
|
173
|
+
free(cPin);
|
|
174
|
+
free(cName);
|
|
175
|
+
[self saveStorage];
|
|
176
|
+
return [NSString stringWithFormat:@"%d", result];
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
- (NSString *)resetStart:(NSString *)code {
|
|
180
|
+
char *cCode = strdup([code UTF8String]);
|
|
181
|
+
int result = IWResetStart(self.iw, cCode);
|
|
182
|
+
free(cCode);
|
|
183
|
+
return [NSString stringWithFormat:@"%d", result];
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
- (NSString *)resetFinalize:(NSString *)code pin:(NSString *)pin {
|
|
187
|
+
char *cCode = strdup([code UTF8String]);
|
|
188
|
+
char *cPin = strdup([pin UTF8String]);
|
|
189
|
+
int result = IWResetFinalize(self.iw, cCode, cPin);
|
|
190
|
+
free(cCode);
|
|
191
|
+
free(cPin);
|
|
192
|
+
[self saveStorage];
|
|
193
|
+
return [NSString stringWithFormat:@"%d", result];
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
- (NSString *)synchronizeStart {
|
|
197
|
+
int result = IWSynchronizeStart(self.iw);
|
|
198
|
+
return [NSString stringWithFormat:@"%d", result];
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
- (NSString *)synchronizeFinalize:(NSString *)pin {
|
|
202
|
+
char *cPin = strdup([pin UTF8String]);
|
|
203
|
+
int result = IWSynchronizeFinalize(self.iw, cPin);
|
|
204
|
+
free(cPin);
|
|
205
|
+
[self saveStorage];
|
|
206
|
+
return [NSString stringWithFormat:@"%d", result];
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
- (NSString *)pwdUpdateStart {
|
|
210
|
+
int result = IWPwdUpdateStart(self.iw);
|
|
211
|
+
return [NSString stringWithFormat:@"%d", result];
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
- (NSString *)pwdUpdateFinalize:(NSString *)newPin currentPin:(NSString *)currentPin {
|
|
215
|
+
char *cNewPin = strdup([newPin UTF8String]);
|
|
216
|
+
char *cCurrentPin = strdup([currentPin UTF8String]);
|
|
217
|
+
int result = IWPwdUpdateFinalize(self.iw, cNewPin, cCurrentPin);
|
|
218
|
+
free(cNewPin);
|
|
219
|
+
free(cCurrentPin);
|
|
220
|
+
[self saveStorage];
|
|
221
|
+
return [NSString stringWithFormat:@"%d", result];
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
- (NSString *)setBiokeyStart {
|
|
225
|
+
int result = IWSetBiokeyStart(self.iw);
|
|
226
|
+
return [NSString stringWithFormat:@"%d", result];
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
- (NSString *)setBiokeyFinalize:(NSString *)biokey pin:(NSString *)pin {
|
|
230
|
+
char *cBiokey = strdup([biokey UTF8String]);
|
|
231
|
+
char *cPin = strdup([pin UTF8String]);
|
|
232
|
+
int result = IWSetBiokeyFinalize(self.iw, cBiokey, cPin);
|
|
233
|
+
free(cBiokey);
|
|
234
|
+
free(cPin);
|
|
235
|
+
[self saveStorage];
|
|
236
|
+
return [NSString stringWithFormat:@"%d", result];
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
- (NSString *)unsetBiokeysStart {
|
|
240
|
+
int result = IWUnsetBiokeysStart(self.iw);
|
|
241
|
+
return [NSString stringWithFormat:@"%d", result];
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
- (NSString *)unsetBiokeysFinalize:(NSString *)pin {
|
|
245
|
+
char *cPin = strdup([pin UTF8String]);
|
|
246
|
+
int result = IWUnsetBiokeysFinalize(self.iw, cPin);
|
|
247
|
+
free(cPin);
|
|
248
|
+
[self saveStorage];
|
|
249
|
+
return [NSString stringWithFormat:@"%d", result];
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
- (NSString *)onlineOtpStart:(double)serviceIndex {
|
|
253
|
+
int result = IWOnlineOtpStart(self.iw, (int)serviceIndex);
|
|
254
|
+
return [NSString stringWithFormat:@"%d", result];
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
- (NSString *)onlineOtpFinalize:(double)serviceIndex pin:(NSString *)pin keyType:(double)keyType {
|
|
258
|
+
char *cPin = strdup([pin UTF8String]);
|
|
259
|
+
int result = IWOnlineOtpFinalizeExt(self.iw, (int)serviceIndex, cPin, (int)keyType);
|
|
260
|
+
free(cPin);
|
|
261
|
+
[self saveStorage];
|
|
262
|
+
return [NSString stringWithFormat:@"%d", result];
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
- (NSString *)otpAnswerOtp {
|
|
266
|
+
char *otp = IWOtpAnswerOtp(self.iw);
|
|
267
|
+
if (!otp) return @"";
|
|
268
|
+
NSString *result = [NSString stringWithCString:otp encoding:NSISOLatin1StringEncoding];
|
|
269
|
+
return result;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
- (BOOL)otpShouldSynchronize:(double)serviceId {
|
|
273
|
+
return IWOtpShouldSynchronize(self.iw, (int)serviceId) == 1;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
- (BOOL)otpModeQuery:(double)serviceId {
|
|
277
|
+
return IWOtpModeQuery(self.iw, (int)serviceId) == 1;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
- (NSString *)otpGenerate:(NSString *)pin {
|
|
281
|
+
char *cPin = strdup([pin UTF8String]);
|
|
282
|
+
char *otp = IWOtpGenerateMa(self.iw, cPin);
|
|
283
|
+
free(cPin);
|
|
284
|
+
[self saveStorage];
|
|
285
|
+
if (!otp) return @"";
|
|
286
|
+
NSString *result = [NSString stringWithCString:otp encoding:NSISOLatin1StringEncoding];
|
|
287
|
+
return result;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
- (double)displayTime {
|
|
291
|
+
return (double)IWDisplayTime(self.iw);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
- (void)setDeviceOS:(NSString *)deviceOS {
|
|
295
|
+
char *cOS = strdup([deviceOS UTF8String]);
|
|
296
|
+
IWSetDeviceOS(self.iw, cOS);
|
|
297
|
+
free(cOS);
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
- (NSString *)pushRegistrationStart {
|
|
301
|
+
int result = IWPushRegistrationStart(self.iw);
|
|
302
|
+
return [NSString stringWithFormat:@"%d", result];
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
- (NSString *)pushRegistrationFinalize:(NSString *)pushId {
|
|
306
|
+
char *cPushId = strdup([pushId UTF8String]);
|
|
307
|
+
int result = IWPushRegistrationFinalize(self.iw, cPushId);
|
|
308
|
+
free(cPushId);
|
|
309
|
+
[self saveStorage];
|
|
310
|
+
return [NSString stringWithFormat:@"%d", result];
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
- (NSString *)checkPush {
|
|
314
|
+
int result = IWCheckPush(self.iw);
|
|
315
|
+
return [NSString stringWithFormat:@"%d", result];
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
- (NSString *)pushAlias {
|
|
319
|
+
char *alias = IWPushAlias(self.iw);
|
|
320
|
+
if (!alias) return @"";
|
|
321
|
+
NSString *result = [NSString stringWithCString:alias encoding:NSISOLatin1StringEncoding];
|
|
322
|
+
return result;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
- (NSString *)pushAction {
|
|
326
|
+
char *action = IWPushAction(self.iw);
|
|
327
|
+
if (!action) return @"";
|
|
328
|
+
NSString *result = [NSString stringWithCString:action encoding:NSISOLatin1StringEncoding];
|
|
329
|
+
return result;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
- (NSString *)pushContext {
|
|
333
|
+
char *context = IWPushContext(self.iw);
|
|
334
|
+
if (!context) return @"";
|
|
335
|
+
NSString *result = [NSString stringWithCString:context encoding:NSISOLatin1StringEncoding];
|
|
336
|
+
return result;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
- (NSString *)onlineSealStart:(double)serviceIndex {
|
|
340
|
+
int result = IWOnlineSealStart(self.iw, (int)serviceIndex);
|
|
341
|
+
return [NSString stringWithFormat:@"%d", result];
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
- (NSString *)onlineSealFinalize:(double)serviceIndex pin:(NSString *)pin keyType:(double)keyType sealData:(NSString *)sealData {
|
|
345
|
+
char *cPin = strdup([pin UTF8String]);
|
|
346
|
+
char *cSealData = strdup([sealData UTF8String]);
|
|
347
|
+
int result = IWOnlineSealFinalizeExt(self.iw, (int)serviceIndex, cPin, (int)keyType, cSealData);
|
|
348
|
+
free(cPin);
|
|
349
|
+
free(cSealData);
|
|
350
|
+
[self saveStorage];
|
|
351
|
+
return [NSString stringWithFormat:@"%d", result];
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
- (NSString *)sealAnswerOtp {
|
|
355
|
+
char *otp = IWSealAnswerOtp(self.iw);
|
|
356
|
+
if (!otp) return @"";
|
|
357
|
+
NSString *result = [NSString stringWithCString:otp encoding:NSISOLatin1StringEncoding];
|
|
358
|
+
return result;
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
- (BOOL)sealShouldSynchronize:(double)serviceId {
|
|
362
|
+
return IWSealShouldSynchronize(self.iw, (int)serviceId) == 1;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
- (BOOL)sealModeQuery:(double)serviceId {
|
|
366
|
+
return IWSealModeQuery(self.iw, (int)serviceId) == 1;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
- (NSString *)sealGenerate:(NSString *)pin sealData:(NSString *)sealData {
|
|
370
|
+
char *cPin = strdup([pin UTF8String]);
|
|
371
|
+
char *cSealData = strdup([sealData UTF8String]);
|
|
372
|
+
char *seal = IWSealGenerate(self.iw, cPin, cSealData);
|
|
373
|
+
free(cPin);
|
|
374
|
+
free(cSealData);
|
|
375
|
+
[self saveStorage];
|
|
376
|
+
if (!seal) return @"";
|
|
377
|
+
NSString *result = [NSString stringWithCString:seal encoding:NSISOLatin1StringEncoding];
|
|
378
|
+
return result;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
- (double)serviceNb {
|
|
382
|
+
return (double)IWServiceNb(self.iw);
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
- (NSString *)serviceName:(double)index {
|
|
386
|
+
char *name = IWServiceName(self.iw, (int)index);
|
|
387
|
+
if (!name) return @"";
|
|
388
|
+
NSString *result = [NSString stringWithCString:name encoding:NSISOLatin1StringEncoding];
|
|
389
|
+
return result;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
- (NSString *)serviceLogo:(double)index {
|
|
393
|
+
char *logo = IWServiceLogo(self.iw, (int)index);
|
|
394
|
+
if (!logo) return @"";
|
|
395
|
+
NSString *result = [NSString stringWithCString:logo encoding:NSISOLatin1StringEncoding];
|
|
396
|
+
return result;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
- (BOOL)serviceDisabled:(double)index {
|
|
400
|
+
return IWServiceDisabled(self.iw, (int)index) == 1;
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
- (NSString *)getVersionInfo {
|
|
404
|
+
NSDictionary *result = @{
|
|
405
|
+
@"libraryVersion": @(IWVersionGet(self.iw) ? [NSString stringWithCString:IWVersionGet(self.iw) encoding:NSISOLatin1StringEncoding] : @""),
|
|
406
|
+
@"newVersionAvailable": @(IWNewVersionAvailable(self.iw) ? [NSString stringWithCString:IWNewVersionAvailable(self.iw) encoding:NSISOLatin1StringEncoding] : @""),
|
|
407
|
+
@"newVersionUrl": @(IWNewVersionURL(self.iw) ? [NSString stringWithCString:IWNewVersionURL(self.iw) encoding:NSISOLatin1StringEncoding] : @""),
|
|
408
|
+
@"majorVersionRequired": @(IWMajorVersionRequired(self.iw) == 1),
|
|
409
|
+
@"shouldAskForMinorUpdate": @(IWShouldAskForMinorUpdate(self.iw) == 1)
|
|
410
|
+
};
|
|
411
|
+
|
|
412
|
+
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:result options:0 error:nil];
|
|
413
|
+
return [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
|
|
417
|
+
(const facebook::react::ObjCTurboModule::InitParams &)params {
|
|
418
|
+
return std::make_shared<facebook::react::NativeRNTrustbuilderSpecJSI>(params);
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
+ (NSString *)moduleName {
|
|
422
|
+
return @"RNTrustbuilder";
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
+ (BOOL)requiresMainQueueSetup {
|
|
426
|
+
return NO;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
- (NSArray<NSString *> *)supportedEvents {
|
|
430
|
+
return @[@"TrustbuilderPushEvent"];
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
@end
|