Skip to content

Commit 8fb727f

Browse files
committed
include all archs, add podspec code to swtich b/w architectures
1 parent 5be017a commit 8fb727f

File tree

8 files changed

+949
-16
lines changed

8 files changed

+949
-16
lines changed

RNJuiceboxSdk.podspec

Lines changed: 33 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,31 +16,49 @@ Pod::Spec.new do |s|
1616
s.source = { :git => "https://github.com/juicebox-systems/react-native-juicebox-sdk.git", :tag => "#{s.version}" }
1717

1818
s.source_files = "ios/**/*.{h,m,mm,swift}"
19-
20-
s.vendored_libraries = "libjuicebox_sdk_ffi_arm64.a"
21-
s.vendored_libraries = "libjuicebox_sdk_ffi_x86.a"
19+
20+
# Specify the vendored libraries for different architectures
21+
s.vendored_libraries = [
22+
'./target/aarch64-apple-ios/libjuicebox_sdk_ffi.a',
23+
'./target/aarch64-apple-ios-sim/libjuicebox_sdk_ffi.a',
24+
'./target/x86_64/libjuicebox_sdk_ffi.a'
25+
]
26+
2227
s.dependency "JuiceboxSdk"
2328

2429
# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
2530
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
2631
if respond_to?(:install_modules_dependencies, true)
2732
install_modules_dependencies(s)
2833
else
29-
s.dependency "React-Core"
34+
s.dependency "React-Core"
3035

31-
# Don't install the dependencies when we run `pod install` in the old architecture.
32-
if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
33-
s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
34-
s.pod_target_xcconfig = {
36+
# Don't install the dependencies when we run `pod install` in the old architecture.
37+
if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
38+
s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
39+
s.pod_target_xcconfig = {
3540
"HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
3641
"OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
3742
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
38-
}
39-
s.dependency "React-Codegen"
40-
s.dependency "RCT-Folly"
41-
s.dependency "RCTRequired"
42-
s.dependency "RCTTypeSafety"
43-
s.dependency "ReactCommon/turbomodule/core"
44-
end
43+
}
44+
s.dependency "React-Codegen"
45+
s.dependency "RCT-Folly"
46+
s.dependency "RCTRequired"
47+
s.dependency "RCTTypeSafety"
48+
s.dependency "ReactCommon/turbomodule/core"
49+
end
4550
end
51+
52+
s.script_phase = {
53+
:name => 'Select appropriate libjuicebox_sdk_ffi.a',
54+
:script => <<-SCRIPT
55+
if [[ "$ARCHS" == "x86_64" ]]; then
56+
cp "${PODS_ROOT}/target/x86_64/libjuicebox_sdk_ffi.a" "${TARGET_BUILD_DIR}/${TARGET_NAME}.framework"
57+
elif [[ "$ARCHS" == "arm64" && "$EFFECTIVE_PLATFORM_NAME" == "-iphonesimulator" ]]; then
58+
cp "${PODS_ROOT}/target/aarch64-apple-ios-sim/libjuicebox_sdk_ffi.a" "${TARGET_BUILD_DIR}/${TARGET_NAME}.framework"
59+
elif [[ "$ARCHS" == "arm64" ]]; then
60+
cp "${PODS_ROOT}/target/aarch64-apple-ios/libjuicebox_sdk_ffi.a" "${TARGET_BUILD_DIR}/${TARGET_NAME}.framework"
61+
fi
62+
SCRIPT
63+
}
4664
end

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@phantom/react-native-juicebox-sdk",
3-
"version": "0.3.5",
3+
"version": "0.3.6",
44
"description": "React native SDK for Juicebox",
55
"main": "lib/commonjs/index",
66
"module": "lib/module/index",
Lines changed: 305 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,305 @@
1+
#ifndef JUICEBOX_FFI_H_
2+
#define JUICEBOX_FFI_H_
3+
4+
/* This file was automatically generated by cbindgen */
5+
6+
#include <stdarg.h>
7+
#include <stdbool.h>
8+
#include <stdint.h>
9+
#include <stdlib.h>
10+
11+
/**
12+
* Error returned during `Client.delete`
13+
*/
14+
typedef enum {
15+
/**
16+
* A realm rejected the `Client`'s auth token.
17+
*/
18+
JuiceboxDeleteErrorInvalidAuth = 0,
19+
/**
20+
* The SDK software is too old to communicate with this realm
21+
* and must be upgraded.
22+
*/
23+
JuiceboxDeleteErrorUpgradeRequired = 1,
24+
/**
25+
* A software error has occurred. This request should not be retried
26+
* with the same parameters. Verify your inputs, check for software
27+
* updates and try again.
28+
*/
29+
JuiceboxDeleteErrorAssertion = 2,
30+
/**
31+
* A transient error in sending or receiving requests to a realm.
32+
* This request may succeed by trying again with the same parameters.
33+
*/
34+
JuiceboxDeleteErrorTransient = 3,
35+
} JuiceboxDeleteError;
36+
37+
typedef enum {
38+
JuiceboxHttpRequestMethodGet = 0,
39+
JuiceboxHttpRequestMethodPut,
40+
JuiceboxHttpRequestMethodPost,
41+
JuiceboxHttpRequestMethodDelete,
42+
} JuiceboxHttpRequestMethod;
43+
44+
typedef enum {
45+
/**
46+
* A tuned hash, secure for use on modern devices as of 2019 with low-entropy PINs.
47+
*/
48+
JuiceboxPinHashingModeStandard2019 = 0,
49+
/**
50+
* A fast hash used for testing. Do not use in production.
51+
*/
52+
JuiceboxPinHashingModeFastInsecure = 1,
53+
} JuiceboxPinHashingMode;
54+
55+
/**
56+
* Error returned during `Client.recover`
57+
*/
58+
typedef enum {
59+
/**
60+
* The secret could not be unlocked, but you can try again
61+
* with a different PIN if you have guesses remaining. If no
62+
* guesses remain, this secret is locked and inaccessible.
63+
*/
64+
JuiceboxRecoverErrorReasonInvalidPin = 0,
65+
/**
66+
* The secret was not registered or not fully registered with the
67+
* provided realms.
68+
*/
69+
JuiceboxRecoverErrorReasonNotRegistered = 1,
70+
/**
71+
* A realm rejected the `Client`'s auth token.
72+
*/
73+
JuiceboxRecoverErrorReasonInvalidAuth = 2,
74+
/**
75+
* The SDK software is too old to communicate with this realm
76+
* and must be upgraded.
77+
*/
78+
JuiceboxRecoverErrorReasonUpgradeRequired = 3,
79+
/**
80+
* A software error has occurred. This request should not be retried
81+
* with the same parameters. Verify your inputs, check for software
82+
* updates and try again.
83+
*/
84+
JuiceboxRecoverErrorReasonAssertion = 4,
85+
/**
86+
* A transient error in sending or receiving requests to a realm.
87+
* This request may succeed by trying again with the same parameters.
88+
*/
89+
JuiceboxRecoverErrorReasonTransient = 5,
90+
} JuiceboxRecoverErrorReason;
91+
92+
/**
93+
* Error returned during `Client.register`
94+
*/
95+
typedef enum {
96+
/**
97+
* A realm rejected the `Client`'s auth token.
98+
*/
99+
JuiceboxRegisterErrorInvalidAuth = 0,
100+
/**
101+
* The SDK software is too old to communicate with this realm
102+
* and must be upgraded.
103+
*/
104+
JuiceboxRegisterErrorUpgradeRequired = 1,
105+
/**
106+
* A software error has occurred. This request should not be retried
107+
* with the same parameters. Verify your inputs, check for software
108+
* updates and try again.
109+
*/
110+
JuiceboxRegisterErrorAssertion = 2,
111+
/**
112+
* A transient error in sending or receiving requests to a realm.
113+
* This request may succeed by trying again with the same parameters.
114+
*/
115+
JuiceboxRegisterErrorTransient = 3,
116+
} JuiceboxRegisterError;
117+
118+
typedef struct JuiceboxAuthToken JuiceboxAuthToken;
119+
120+
typedef struct JuiceboxAuthTokenGenerator JuiceboxAuthTokenGenerator;
121+
122+
typedef struct JuiceboxAuthTokenManager JuiceboxAuthTokenManager;
123+
124+
typedef struct JuiceboxClient JuiceboxClient;
125+
126+
typedef struct JuiceboxConfiguration JuiceboxConfiguration;
127+
128+
typedef struct JuiceboxHttpClient JuiceboxHttpClient;
129+
130+
typedef struct {
131+
JuiceboxConfiguration *const *data;
132+
size_t length;
133+
} JuiceboxUnmanagedConfigurationArray;
134+
135+
typedef void (*JuiceboxAuthTokenGetCallbackFn)(JuiceboxAuthTokenManager *context,
136+
uint64_t context_id,
137+
const JuiceboxAuthToken *auth_token);
138+
139+
typedef void (*JuiceboxAuthTokenGetFn)(const JuiceboxAuthTokenManager *context,
140+
uint64_t context_id,
141+
const uint8_t (*realm_id)[16],
142+
JuiceboxAuthTokenGetCallbackFn callback);
143+
144+
typedef struct {
145+
const char *name;
146+
const char *value;
147+
} JuiceboxHttpHeader;
148+
149+
typedef struct {
150+
const JuiceboxHttpHeader *data;
151+
size_t length;
152+
} JuiceboxUnmanagedHttpHeaderArray;
153+
154+
typedef struct {
155+
const uint8_t *data;
156+
size_t length;
157+
} JuiceboxUnmanagedDataArray;
158+
159+
typedef struct {
160+
uint8_t id[16];
161+
JuiceboxHttpRequestMethod method;
162+
const char *url;
163+
JuiceboxUnmanagedHttpHeaderArray headers;
164+
JuiceboxUnmanagedDataArray body;
165+
} JuiceboxHttpRequest;
166+
167+
typedef struct {
168+
uint8_t id[16];
169+
uint16_t status_code;
170+
JuiceboxUnmanagedHttpHeaderArray headers;
171+
JuiceboxUnmanagedDataArray body;
172+
} JuiceboxHttpResponse;
173+
174+
typedef void (*JuiceboxHttpResponseFn)(JuiceboxHttpClient *context,
175+
const JuiceboxHttpResponse *response);
176+
177+
typedef void (*JuiceboxHttpSendFn)(const JuiceboxHttpClient *context,
178+
const JuiceboxHttpRequest *request,
179+
JuiceboxHttpResponseFn callback);
180+
181+
typedef struct {
182+
uint8_t id[16];
183+
const char *address;
184+
const JuiceboxUnmanagedDataArray *public_key;
185+
} JuiceboxRealm;
186+
187+
typedef struct {
188+
const JuiceboxRealm *data;
189+
size_t length;
190+
} JuiceboxUnmanagedRealmArray;
191+
192+
typedef struct {
193+
JuiceboxRecoverErrorReason reason;
194+
/**
195+
* If non-NULL, the number of guesses remaining after an Unsuccessful attempt.
196+
*/
197+
const uint16_t *guesses_remaining;
198+
} JuiceboxRecoverError;
199+
200+
typedef struct {
201+
uint8_t realm_id[16];
202+
uint8_t secret_id[16];
203+
} JuiceboxAuthTokenParameters;
204+
205+
typedef void (*JuiceboxAuthTokenStringCallbackFn)(JuiceboxAuthToken *auth_token,
206+
const void *context,
207+
const char *string);
208+
209+
/**
210+
* Constructs a new opaque `JuiceboxClient`.
211+
*
212+
* # Arguments
213+
*
214+
* * `configuration` – Represents the current configuration. The configuration
215+
* provided must include at least one `JuiceboxRealm`.
216+
* * `previous_configurations` – Represents any other configurations you have
217+
* previously registered with that you may not yet have migrated the data from.
218+
* During `juicebox_client_recover`, they will be tried if the current user has not yet
219+
* registered on the current configuration. These should be ordered from most recently
220+
* to least recently used.
221+
* * `auth_token` – Represents the authority to act as a particular user
222+
* and should be valid for the lifetime of the `JuiceboxClient`.
223+
* * `http_send` – A function pointer `http_send` that will be called when the client
224+
* wishes to make a network request. The appropriate request should be executed by you,
225+
* and the the response provided to the response function pointer. This send
226+
* should be performed asynchronously. `http_send` should not block on
227+
* performing the request, and the response should be returned to the
228+
* `response` function pointer argument when the asynchronous work has
229+
* completed. The request parameter is only valid for the lifetime of the
230+
* `http_send` function and should not be accessed after returning from the
231+
* function.
232+
*/
233+
JuiceboxClient *juicebox_client_create(JuiceboxConfiguration *configuration,
234+
JuiceboxUnmanagedConfigurationArray previous_configurations,
235+
JuiceboxAuthTokenGetFn auth_token_get,
236+
JuiceboxHttpSendFn http_send);
237+
238+
void juicebox_client_destroy(JuiceboxClient *client);
239+
240+
const char *juicebox_sdk_version(void);
241+
242+
JuiceboxConfiguration *juicebox_configuration_create(JuiceboxUnmanagedRealmArray realms,
243+
uint32_t register_threshold,
244+
uint32_t recover_threshold,
245+
JuiceboxPinHashingMode pin_hashing_mode);
246+
247+
JuiceboxConfiguration *juicebox_configuration_create_from_json(const char *json);
248+
249+
void juicebox_configuration_destroy(JuiceboxConfiguration *configuration);
250+
251+
bool juicebox_configurations_are_equal(JuiceboxConfiguration *configuration1,
252+
JuiceboxConfiguration *configuration2);
253+
254+
/**
255+
* Stores a new PIN-protected secret on the configured realms.
256+
*
257+
* # Note
258+
*
259+
* The provided secret must have a maximum length of 128-bytes.
260+
*/
261+
void juicebox_client_register(JuiceboxClient *client,
262+
const void *context,
263+
JuiceboxUnmanagedDataArray pin,
264+
JuiceboxUnmanagedDataArray secret,
265+
JuiceboxUnmanagedDataArray info,
266+
uint16_t num_guesses,
267+
void (*response)(const void *context,
268+
const JuiceboxRegisterError *error));
269+
270+
/**
271+
* Retrieves a PIN-protected secret from the configured realms, or falls
272+
* back to the previous realms if the current realms do not have a secret
273+
* registered.
274+
*/
275+
void juicebox_client_recover(JuiceboxClient *client,
276+
const void *context,
277+
JuiceboxUnmanagedDataArray pin,
278+
JuiceboxUnmanagedDataArray info,
279+
void (*response)(const void *context,
280+
JuiceboxUnmanagedDataArray secret,
281+
const JuiceboxRecoverError *error));
282+
283+
/**
284+
* Deletes the registered secret for this user, if any.
285+
*/
286+
void juicebox_client_delete(JuiceboxClient *client,
287+
const void *context,
288+
void (*response)(const void *context, const JuiceboxDeleteError *error));
289+
290+
JuiceboxAuthTokenGenerator *juicebox_auth_token_generator_create_from_json(const char *json);
291+
292+
void juicebox_auth_token_generator_destroy(JuiceboxAuthTokenGenerator *generator);
293+
294+
const JuiceboxAuthToken *juicebox_auth_token_generator_vend(JuiceboxAuthTokenGenerator *generator,
295+
JuiceboxAuthTokenParameters parameters);
296+
297+
const JuiceboxAuthToken *juicebox_auth_token_create(const char *token_cstr);
298+
299+
void juicebox_auth_token_destroy(JuiceboxAuthToken *token);
300+
301+
void juicebox_auth_token_string(JuiceboxAuthToken *token,
302+
const void *context,
303+
JuiceboxAuthTokenStringCallbackFn callback);
304+
305+
#endif /* JUICEBOX_FFI_H_ */
48.7 MB
Binary file not shown.

0 commit comments

Comments
 (0)