mayo-firebase-config 1.2.10 → 1.2.12
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.
@@ -1,5 +1,7 @@
|
|
1
1
|
package com.mayofirebaseconfig;
|
2
2
|
|
3
|
+
import android.util.Log;
|
4
|
+
|
3
5
|
import com.facebook.react.bridge.ReactApplicationContext;
|
4
6
|
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
5
7
|
import com.facebook.react.bridge.ReactMethod;
|
@@ -36,10 +38,16 @@ public class FirebaseConfigExtractorModule extends ReactContextBaseJavaModule {
|
|
36
38
|
// Use AssetManager to read the google-services.json file from the assets folder
|
37
39
|
AssetManager assetManager = getReactApplicationContext().getAssets();
|
38
40
|
InputStream input = assetManager.open("google-services.json");
|
39
|
-
|
41
|
+
|
42
|
+
// Log file opened successfully
|
43
|
+
Log.d(NAME, "google-services.json file opened successfully.");
|
44
|
+
|
40
45
|
// Convert InputStream to String
|
41
46
|
String json = convertStreamToString(input);
|
42
47
|
|
48
|
+
// Log raw JSON string
|
49
|
+
Log.d(NAME, "JSON string: " + json);
|
50
|
+
|
43
51
|
// Use JSONObject to parse the JSON string
|
44
52
|
JSONObject jsonObject = new JSONObject(json);
|
45
53
|
JSONArray clientArray = jsonObject.getJSONArray("client");
|
@@ -48,6 +56,10 @@ public class FirebaseConfigExtractorModule extends ReactContextBaseJavaModule {
|
|
48
56
|
JSONArray apiKeyArray = clientObject.getJSONArray("api_key");
|
49
57
|
JSONObject apiKeyObject = apiKeyArray.getJSONObject(0);
|
50
58
|
|
59
|
+
// Log parsed objects
|
60
|
+
Log.d(NAME, "Parsed projectInfo: " + projectInfo.toString());
|
61
|
+
Log.d(NAME, "Parsed apiKeyObject: " + apiKeyObject.toString());
|
62
|
+
|
51
63
|
// Extract webClientId
|
52
64
|
JSONArray oauthClientArray = clientObject.getJSONArray("oauth_client");
|
53
65
|
String webClientId = "";
|
@@ -72,7 +84,11 @@ public class FirebaseConfigExtractorModule extends ReactContextBaseJavaModule {
|
|
72
84
|
config.put("databaseURL", "https://" + projectInfo.getString("project_id") + ".firebaseio.com");
|
73
85
|
|
74
86
|
promise.resolve(config);
|
87
|
+
} catch (IOException e) {
|
88
|
+
Log.e(NAME, "Error reading Firebase config file", e);
|
89
|
+
promise.reject("ERR_IO_EXCEPTION", "Error reading Firebase config file", e);
|
75
90
|
} catch (Exception e) {
|
91
|
+
Log.e(NAME, "Error extracting Firebase config on Android", e);
|
76
92
|
promise.reject("ERR_UNEXPECTED_EXCEPTION", "Error extracting Firebase config on Android", e);
|
77
93
|
}
|
78
94
|
}
|
@@ -14,16 +14,23 @@ const react_native_1 = require("react-native");
|
|
14
14
|
const mayo_logger_1 = require("mayo-logger");
|
15
15
|
const { FirebaseConfigExtractor } = react_native_1.NativeModules;
|
16
16
|
const extractFirebaseConfig = () => __awaiter(void 0, void 0, void 0, function* () {
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
try {
|
18
|
+
mayo_logger_1.Logger.info('Starting Firebase config extraction...', null, { tag: 'mayo-firebase-config-extractor' });
|
19
|
+
const config = yield FirebaseConfigExtractor.extractConfig();
|
20
|
+
if (config && typeof config === 'object' && Object.keys(config).length > 0) {
|
21
|
+
mayo_logger_1.Logger.info('Successfully extracted Firebase config', null, { tag: 'mayo-firebase-config-extractor' });
|
22
|
+
}
|
23
|
+
else {
|
24
|
+
mayo_logger_1.Logger.warn('Failed to extract valid Firebase config or the config is empty', null, { tag: 'mayo-firebase-config-extractor' });
|
25
|
+
}
|
26
|
+
// Be cautious about logging potentially sensitive information
|
27
|
+
mayo_logger_1.Logger.error('Extracted Firebase config:', { config }, { tag: 'mayo-firebase-config-extractor' });
|
28
|
+
return config;
|
21
29
|
}
|
22
|
-
|
23
|
-
|
30
|
+
catch (error) {
|
31
|
+
// Handle the error appropriately
|
32
|
+
mayo_logger_1.Logger.error('Error extracting Firebase config', error, { tag: 'mayo-firebase-config-extractor' });
|
33
|
+
throw error;
|
24
34
|
}
|
25
|
-
// This log may expose sensitive information, so be cautious about using it in a production environment
|
26
|
-
mayo_logger_1.Logger.info('Extracted Firebase config:', { config }, { tag: 'mayo-firebase-config-extractor' });
|
27
|
-
return config;
|
28
35
|
});
|
29
36
|
exports.extractFirebaseConfig = extractFirebaseConfig;
|
package/package.json
CHANGED
@@ -5,18 +5,24 @@ import { FirebaseConfig } from 'mayo-firebase-config';
|
|
5
5
|
const { FirebaseConfigExtractor } = NativeModules;
|
6
6
|
|
7
7
|
export const extractFirebaseConfig = async (): Promise<FirebaseConfig> => {
|
8
|
-
|
8
|
+
try {
|
9
|
+
Logger.info('Starting Firebase config extraction...', null, { tag: 'mayo-firebase-config-extractor' });
|
9
10
|
|
10
|
-
|
11
|
+
const config: FirebaseConfig = await FirebaseConfigExtractor.extractConfig();
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
if (config && typeof config === 'object' && Object.keys(config).length > 0) {
|
14
|
+
Logger.info('Successfully extracted Firebase config', null, { tag: 'mayo-firebase-config-extractor' });
|
15
|
+
} else {
|
16
|
+
Logger.warn('Failed to extract valid Firebase config or the config is empty', null, { tag: 'mayo-firebase-config-extractor' });
|
17
|
+
}
|
17
18
|
|
18
|
-
|
19
|
-
|
19
|
+
// Be cautious about logging potentially sensitive information
|
20
|
+
Logger.error('Extracted Firebase config:', { config }, { tag: 'mayo-firebase-config-extractor' });
|
20
21
|
|
21
|
-
|
22
|
+
return config;
|
23
|
+
} catch (error) {
|
24
|
+
// Handle the error appropriately
|
25
|
+
Logger.error('Error extracting Firebase config', error, { tag: 'mayo-firebase-config-extractor' });
|
26
|
+
throw error;
|
27
|
+
}
|
22
28
|
};
|