@onairos/react-native 1.0.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.
Files changed (130) hide show
  1. package/README.md +334 -0
  2. package/lib/commonjs/components/DataRequestModal.js +176 -0
  3. package/lib/commonjs/components/DataRequestModal.js.map +1 -0
  4. package/lib/commonjs/components/Notification.js +106 -0
  5. package/lib/commonjs/components/Notification.js.map +1 -0
  6. package/lib/commonjs/components/OnairosButton.js +575 -0
  7. package/lib/commonjs/components/OnairosButton.js.map +1 -0
  8. package/lib/commonjs/components/Overlay.js +818 -0
  9. package/lib/commonjs/components/Overlay.js.map +1 -0
  10. package/lib/commonjs/components/UniversalOnboarding.js +173 -0
  11. package/lib/commonjs/components/UniversalOnboarding.js.map +1 -0
  12. package/lib/commonjs/components/onboarding/OAuthWebView.js +137 -0
  13. package/lib/commonjs/components/onboarding/OAuthWebView.js.map +1 -0
  14. package/lib/commonjs/components/onboarding/OnboardingHeader.js +74 -0
  15. package/lib/commonjs/components/onboarding/OnboardingHeader.js.map +1 -0
  16. package/lib/commonjs/components/onboarding/PinInput.js +283 -0
  17. package/lib/commonjs/components/onboarding/PinInput.js.map +1 -0
  18. package/lib/commonjs/components/onboarding/PlatformConnector.js +244 -0
  19. package/lib/commonjs/components/onboarding/PlatformConnector.js.map +1 -0
  20. package/lib/commonjs/components/screens/ConnectorScreen.js +145 -0
  21. package/lib/commonjs/components/screens/ConnectorScreen.js.map +1 -0
  22. package/lib/commonjs/components/screens/LoadingScreen.js +91 -0
  23. package/lib/commonjs/components/screens/LoadingScreen.js.map +1 -0
  24. package/lib/commonjs/components/screens/PinCreationScreen.js +61 -0
  25. package/lib/commonjs/components/screens/PinCreationScreen.js.map +1 -0
  26. package/lib/commonjs/constants/index.js +78 -0
  27. package/lib/commonjs/constants/index.js.map +1 -0
  28. package/lib/commonjs/hooks/useConnections.js +89 -0
  29. package/lib/commonjs/hooks/useConnections.js.map +1 -0
  30. package/lib/commonjs/hooks/useCredentials.js +85 -0
  31. package/lib/commonjs/hooks/useCredentials.js.map +1 -0
  32. package/lib/commonjs/index.js +282 -0
  33. package/lib/commonjs/index.js.map +1 -0
  34. package/lib/commonjs/services/oauthService.js +362 -0
  35. package/lib/commonjs/services/oauthService.js.map +1 -0
  36. package/lib/commonjs/types/declarations.d.js +2 -0
  37. package/lib/commonjs/types/declarations.d.js.map +1 -0
  38. package/lib/commonjs/types/index.js +2 -0
  39. package/lib/commonjs/types/index.js.map +1 -0
  40. package/lib/commonjs/utils/api.js +129 -0
  41. package/lib/commonjs/utils/api.js.map +1 -0
  42. package/lib/commonjs/utils/auth.js +111 -0
  43. package/lib/commonjs/utils/auth.js.map +1 -0
  44. package/lib/commonjs/utils/crypto.js +62 -0
  45. package/lib/commonjs/utils/crypto.js.map +1 -0
  46. package/lib/commonjs/utils/debugHelper.js +64 -0
  47. package/lib/commonjs/utils/debugHelper.js.map +1 -0
  48. package/lib/commonjs/utils/onairosApi.js +270 -0
  49. package/lib/commonjs/utils/onairosApi.js.map +1 -0
  50. package/lib/commonjs/utils/secureStorage.js +210 -0
  51. package/lib/commonjs/utils/secureStorage.js.map +1 -0
  52. package/lib/module/components/DataRequestModal.js +168 -0
  53. package/lib/module/components/DataRequestModal.js.map +1 -0
  54. package/lib/module/components/Notification.js +99 -0
  55. package/lib/module/components/Notification.js.map +1 -0
  56. package/lib/module/components/OnairosButton.js +550 -0
  57. package/lib/module/components/OnairosButton.js.map +1 -0
  58. package/lib/module/components/Overlay.js +825 -0
  59. package/lib/module/components/Overlay.js.map +1 -0
  60. package/lib/module/components/UniversalOnboarding.js +164 -0
  61. package/lib/module/components/UniversalOnboarding.js.map +1 -0
  62. package/lib/module/components/onboarding/OAuthWebView.js +128 -0
  63. package/lib/module/components/onboarding/OAuthWebView.js.map +1 -0
  64. package/lib/module/components/onboarding/OnboardingHeader.js +66 -0
  65. package/lib/module/components/onboarding/OnboardingHeader.js.map +1 -0
  66. package/lib/module/components/onboarding/PinInput.js +274 -0
  67. package/lib/module/components/onboarding/PinInput.js.map +1 -0
  68. package/lib/module/components/onboarding/PlatformConnector.js +235 -0
  69. package/lib/module/components/onboarding/PlatformConnector.js.map +1 -0
  70. package/lib/module/components/screens/ConnectorScreen.js +137 -0
  71. package/lib/module/components/screens/ConnectorScreen.js.map +1 -0
  72. package/lib/module/components/screens/LoadingScreen.js +83 -0
  73. package/lib/module/components/screens/LoadingScreen.js.map +1 -0
  74. package/lib/module/components/screens/PinCreationScreen.js +53 -0
  75. package/lib/module/components/screens/PinCreationScreen.js.map +1 -0
  76. package/lib/module/constants/index.js +72 -0
  77. package/lib/module/constants/index.js.map +1 -0
  78. package/lib/module/hooks/useConnections.js +81 -0
  79. package/lib/module/hooks/useConnections.js.map +1 -0
  80. package/lib/module/hooks/useCredentials.js +77 -0
  81. package/lib/module/hooks/useCredentials.js.map +1 -0
  82. package/lib/module/index.js +34 -0
  83. package/lib/module/index.js.map +1 -0
  84. package/lib/module/services/oauthService.js +352 -0
  85. package/lib/module/services/oauthService.js.map +1 -0
  86. package/lib/module/types/declarations.d.js +2 -0
  87. package/lib/module/types/declarations.d.js.map +1 -0
  88. package/lib/module/types/index.js +2 -0
  89. package/lib/module/types/index.js.map +1 -0
  90. package/lib/module/utils/api.js +117 -0
  91. package/lib/module/utils/api.js.map +1 -0
  92. package/lib/module/utils/auth.js +99 -0
  93. package/lib/module/utils/auth.js.map +1 -0
  94. package/lib/module/utils/crypto.js +54 -0
  95. package/lib/module/utils/crypto.js.map +1 -0
  96. package/lib/module/utils/debugHelper.js +54 -0
  97. package/lib/module/utils/debugHelper.js.map +1 -0
  98. package/lib/module/utils/onairosApi.js +256 -0
  99. package/lib/module/utils/onairosApi.js.map +1 -0
  100. package/lib/module/utils/secureStorage.js +196 -0
  101. package/lib/module/utils/secureStorage.js.map +1 -0
  102. package/package.json +115 -0
  103. package/src/components/DataRequestModal.tsx +187 -0
  104. package/src/components/Notification.js +101 -0
  105. package/src/components/OnairosButton.js +604 -0
  106. package/src/components/OnairosButton.tsx +182 -0
  107. package/src/components/Overlay.js +854 -0
  108. package/src/components/Overlay.tsx +272 -0
  109. package/src/components/UniversalOnboarding.tsx +184 -0
  110. package/src/components/onboarding/OAuthWebView.tsx +134 -0
  111. package/src/components/onboarding/OnboardingHeader.tsx +70 -0
  112. package/src/components/onboarding/PinInput.tsx +356 -0
  113. package/src/components/onboarding/PlatformConnector.tsx +297 -0
  114. package/src/components/screens/ConnectorScreen.tsx +152 -0
  115. package/src/components/screens/LoadingScreen.tsx +100 -0
  116. package/src/components/screens/PinCreationScreen.tsx +67 -0
  117. package/src/constants/index.ts +78 -0
  118. package/src/hooks/useConnections.ts +90 -0
  119. package/src/hooks/useCredentials.ts +83 -0
  120. package/src/index.js +14 -0
  121. package/src/index.ts +82 -0
  122. package/src/services/oauthService.ts +360 -0
  123. package/src/types/declarations.d.ts +26 -0
  124. package/src/types/index.ts +82 -0
  125. package/src/utils/api.js +112 -0
  126. package/src/utils/auth.js +104 -0
  127. package/src/utils/crypto.js +60 -0
  128. package/src/utils/debugHelper.ts +53 -0
  129. package/src/utils/onairosApi.ts +303 -0
  130. package/src/utils/secureStorage.ts +230 -0
@@ -0,0 +1,129 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.validateDomain = exports.getApiUrl = exports.fetchAccountInfo = exports.createApiInstance = exports.createAccount = void 0;
7
+ var _axios = _interopRequireDefault(require("axios"));
8
+ var _asyncStorage = _interopRequireDefault(require("@react-native-async-storage/async-storage"));
9
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
+ const API_URL = 'https://api2.onairos.uk';
11
+
12
+ /**
13
+ * Create an API instance with authorization headers
14
+ * @returns {Promise<Object>} - The axios instance
15
+ */
16
+ const createApiInstance = async () => {
17
+ const token = await _asyncStorage.default.getItem('onairosToken');
18
+ return _axios.default.create({
19
+ baseURL: API_URL,
20
+ headers: {
21
+ 'Content-Type': 'application/json',
22
+ ...(token ? {
23
+ 'Authorization': `Bearer ${token}`
24
+ } : {})
25
+ }
26
+ });
27
+ };
28
+
29
+ /**
30
+ * Validate the domain with the Onairos API
31
+ * @returns {Promise<Object>} - The validation response
32
+ */
33
+ exports.createApiInstance = createApiInstance;
34
+ const validateDomain = async () => {
35
+ try {
36
+ const api = await createApiInstance();
37
+ const response = await api.post('/valid/validate-domain');
38
+ return response.data;
39
+ } catch (error) {
40
+ console.error('Error validating domain:', error);
41
+ return {
42
+ status: false
43
+ };
44
+ }
45
+ };
46
+
47
+ /**
48
+ * Fetch account information
49
+ * @param {string} identifier - The username or email
50
+ * @param {boolean} isEmail - Whether the identifier is an email
51
+ * @returns {Promise<Object>} - The account information
52
+ */
53
+ exports.validateDomain = validateDomain;
54
+ const fetchAccountInfo = async (identifier, isEmail = false) => {
55
+ try {
56
+ const api = await createApiInstance();
57
+ const jsonData = isEmail ? {
58
+ Info: {
59
+ identifier
60
+ }
61
+ } : {
62
+ Info: {
63
+ userName: identifier
64
+ }
65
+ };
66
+ const endpoint = isEmail ? '/getAccountInfo/email' : '/getAccountInfo';
67
+ const response = await api.post(endpoint, jsonData);
68
+ return response.data;
69
+ } catch (error) {
70
+ console.error('Error fetching account info:', error);
71
+ throw error;
72
+ }
73
+ };
74
+
75
+ /**
76
+ * Get API URL for data requests
77
+ * @param {Array} approvedRequests - The approved data requests
78
+ * @param {string} pin - The encrypted PIN
79
+ * @param {string} othentSub - The hashed Othent sub
80
+ * @returns {Promise<Object>} - The API URL response
81
+ */
82
+ exports.fetchAccountInfo = fetchAccountInfo;
83
+ const getApiUrl = async (approvedRequests, pin, othentSub) => {
84
+ try {
85
+ const api = await createApiInstance();
86
+ const jsonData = {
87
+ Info: {
88
+ EncryptedUserPin: pin,
89
+ confirmations: approvedRequests,
90
+ web3Type: 'othent',
91
+ Domain: Platform.OS,
92
+ proofMode: false,
93
+ OthentSub: othentSub
94
+ }
95
+ };
96
+ const response = await api.post('/getAPIurl', jsonData);
97
+ return response.data;
98
+ } catch (error) {
99
+ console.error('Error getting API URL:', error);
100
+ throw error;
101
+ }
102
+ };
103
+
104
+ /**
105
+ * Create a new user account
106
+ * @param {string} othentSub - The hashed Othent sub
107
+ * @param {string} pin - The PIN
108
+ * @param {Array} socialAccounts - The selected social accounts
109
+ * @param {string} email - The user's email
110
+ * @returns {Promise<Object>} - The account creation response
111
+ */
112
+ exports.getApiUrl = getApiUrl;
113
+ const createAccount = async (othentSub, pin, socialAccounts, email) => {
114
+ try {
115
+ const api = await createApiInstance();
116
+ const response = await api.post('/createAccount', {
117
+ othentSub,
118
+ pin,
119
+ socialAccounts,
120
+ email
121
+ });
122
+ return response.data;
123
+ } catch (error) {
124
+ console.error('Error creating account:', error);
125
+ throw error;
126
+ }
127
+ };
128
+ exports.createAccount = createAccount;
129
+ //# sourceMappingURL=api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_axios","_interopRequireDefault","require","_asyncStorage","e","__esModule","default","API_URL","createApiInstance","token","AsyncStorage","getItem","axios","create","baseURL","headers","exports","validateDomain","api","response","post","data","error","console","status","fetchAccountInfo","identifier","isEmail","jsonData","Info","userName","endpoint","getApiUrl","approvedRequests","pin","othentSub","EncryptedUserPin","confirmations","web3Type","Domain","Platform","OS","proofMode","OthentSub","createAccount","socialAccounts","email"],"sourceRoot":"..\\..\\..\\src","sources":["utils/api.js"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,aAAA,GAAAF,sBAAA,CAAAC,OAAA;AAAqE,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAErE,MAAMG,OAAO,GAAG,yBAAyB;;AAEzC;AACA;AACA;AACA;AACO,MAAMC,iBAAiB,GAAG,MAAAA,CAAA,KAAY;EAC3C,MAAMC,KAAK,GAAG,MAAMC,qBAAY,CAACC,OAAO,CAAC,c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CAAC,CAAC,OAAOC,KAAK,EAAE;IACdC,OAAO,CAACD,KAAK,CAAC,yBAAyB,EAAEA,KAAK,CAAC;IAC/C,MAAMA,KAAK;EACb;AACF,CAAC;AAACN,OAAA,CAAA4B,aAAA,GAAAA,aAAA","ignoreList":[]}
@@ -0,0 +1,111 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.verifyToken = exports.storeAuthData = exports.getStoredAuthData = exports.getPin = exports.clearAuthData = void 0;
7
+ var _axios = _interopRequireDefault(require("axios"));
8
+ var _asyncStorage = _interopRequireDefault(require("@react-native-async-storage/async-storage"));
9
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
+ const API_URL = 'https://api2.onairos.uk';
11
+
12
+ /**
13
+ * Get the encrypted PIN for a user
14
+ * @param {string} hashedOthentSub - The hashed Othent sub
15
+ * @returns {Promise<Object>} - The response containing the encrypted PIN
16
+ */
17
+ const getPin = async hashedOthentSub => {
18
+ try {
19
+ const response = await _axios.default.post(`${API_URL}/getPin`, {
20
+ hashedOthentSub
21
+ });
22
+ return response.data;
23
+ } catch (error) {
24
+ console.error('Error getting PIN:', error);
25
+ throw error;
26
+ }
27
+ };
28
+
29
+ /**
30
+ * Verify a token with the Onairos API
31
+ * @param {string} token - The token to verify
32
+ * @returns {Promise<boolean>} - Whether the token is valid
33
+ */
34
+ exports.getPin = getPin;
35
+ const verifyToken = async token => {
36
+ try {
37
+ const response = await _axios.default.post(`${API_URL}/verifyToken`, {}, {
38
+ headers: {
39
+ 'Authorization': `Bearer ${token}`
40
+ }
41
+ });
42
+ return response.data.valid;
43
+ } catch (error) {
44
+ console.error('Error verifying token:', error);
45
+ return false;
46
+ }
47
+ };
48
+
49
+ /**
50
+ * Store authentication data
51
+ * @param {string} token - The authentication token
52
+ * @param {string} username - The username
53
+ * @param {Object} othentData - The Othent user data
54
+ */
55
+ exports.verifyToken = verifyToken;
56
+ const storeAuthData = async (token, username = null, othentData = null) => {
57
+ try {
58
+ await _asyncStorage.default.setItem('onairosToken', token);
59
+ if (username) {
60
+ await _asyncStorage.default.setItem('username', username);
61
+ }
62
+ if (othentData) {
63
+ await _asyncStorage.default.setItem('othentToken', JSON.stringify(othentData));
64
+ }
65
+ } catch (error) {
66
+ console.error('Error storing auth data:', error);
67
+ throw error;
68
+ }
69
+ };
70
+
71
+ /**
72
+ * Clear authentication data
73
+ */
74
+ exports.storeAuthData = storeAuthData;
75
+ const clearAuthData = async () => {
76
+ try {
77
+ await _asyncStorage.default.removeItem('onairosToken');
78
+ await _asyncStorage.default.removeItem('username');
79
+ await _asyncStorage.default.removeItem('othentToken');
80
+ } catch (error) {
81
+ console.error('Error clearing auth data:', error);
82
+ throw error;
83
+ }
84
+ };
85
+
86
+ /**
87
+ * Get stored authentication data
88
+ * @returns {Promise<Object>} - The stored authentication data
89
+ */
90
+ exports.clearAuthData = clearAuthData;
91
+ const getStoredAuthData = async () => {
92
+ try {
93
+ const token = await _asyncStorage.default.getItem('onairosToken');
94
+ const username = await _asyncStorage.default.getItem('username');
95
+ const othentToken = await _asyncStorage.default.getItem('othentToken');
96
+ return {
97
+ token,
98
+ username,
99
+ othentToken: othentToken ? JSON.parse(othentToken) : null
100
+ };
101
+ } catch (error) {
102
+ console.error('Error getting stored auth data:', error);
103
+ return {
104
+ token: null,
105
+ username: null,
106
+ othentToken: null
107
+ };
108
+ }
109
+ };
110
+ exports.getStoredAuthData = getStoredAuthData;
111
+ //# sourceMappingURL=auth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_axios","_interopRequireDefault","require","_asyncStorage","e","__esModule","default","API_URL","getPin","hashedOthentSub","response","axios","post","data","error","console","exports","verifyToken","token","headers","valid","storeAuthData","username","othentData","AsyncStorage","setItem","JSON","stringify","clearAuthData","removeItem","getStoredAuthData","getItem","othentToken","parse"],"sourceRoot":"..\\..\\..\\src","sources":["utils/auth.js"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAA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AG;IACvD,CAAC;EACH,CAAC,CAAC,OAAOlB,KAAK,EAAE;IACdC,OAAO,CAACD,KAAK,CAAC,iCAAiC,EAAEA,KAAK,CAAC;IACvD,OAAO;MACLI,KAAK,EAAE,IAAI;MACXI,QAAQ,EAAE,IAAI;MACdU,WAAW,EAAE;IACf,CAAC;EACH;AACF,CAAC;AAAChB,OAAA,CAAAc,iBAAA,GAAAA,iBAAA","ignoreList":[]}
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.sha256 = exports.rsaEncrypt = exports.base64ToBuffer = void 0;
7
+ var _reactNativeRsaNative = require("react-native-rsa-native");
8
+ var _reactNativeCryptoJs = require("react-native-crypto-js");
9
+ /**
10
+ * Encrypt data using RSA
11
+ * @param {string} publicKey - The RSA public key
12
+ * @param {string} data - The data to encrypt
13
+ * @returns {Promise<string>} - The encrypted data
14
+ */
15
+ const rsaEncrypt = async (publicKey, data) => {
16
+ try {
17
+ // Clean the public key format
18
+ const cleanedKey = publicKey.replace(/\\n/g, '').replace(/^\s+|\s+$/g, '').replace('-----BEGIN PUBLIC KEY-----', '').replace('-----END PUBLIC KEY-----', '').trim();
19
+
20
+ // Format the key properly for the library
21
+ const formattedKey = `-----BEGIN PUBLIC KEY-----\n${cleanedKey}\n-----END PUBLIC KEY-----`;
22
+
23
+ // Encrypt the data
24
+ const encrypted = await _reactNativeRsaNative.RSA.encrypt(data, formattedKey);
25
+ return encrypted;
26
+ } catch (error) {
27
+ console.error('RSA encryption failed:', error);
28
+ throw error;
29
+ }
30
+ };
31
+
32
+ /**
33
+ * Hash data using SHA-256
34
+ * @param {string} data - The data to hash
35
+ * @returns {string} - The hashed data
36
+ */
37
+ exports.rsaEncrypt = rsaEncrypt;
38
+ const sha256 = data => {
39
+ return (0, _reactNativeCryptoJs.sha256)(data).toString();
40
+ };
41
+
42
+ /**
43
+ * Convert a base64 string to a buffer
44
+ * @param {string} base64String - The base64 string to convert
45
+ * @returns {ArrayBuffer} - The converted buffer
46
+ */
47
+ exports.sha256 = sha256;
48
+ const base64ToBuffer = base64String => {
49
+ try {
50
+ const binaryString = Buffer.from(base64String, 'base64').toString('binary');
51
+ const bytes = new Uint8Array(binaryString.length);
52
+ for (let i = 0; i < binaryString.length; i++) {
53
+ bytes[i] = binaryString.charCodeAt(i);
54
+ }
55
+ return bytes.buffer;
56
+ } catch (error) {
57
+ console.error('Error converting base64 to buffer:', error);
58
+ throw error;
59
+ }
60
+ };
61
+ exports.base64ToBuffer = base64ToBuffer;
62
+ //# sourceMappingURL=crypto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_reactNativeRsaNative","require","_reactNativeCryptoJs","rsaEncrypt","publicKey","data","cleanedKey","replace","trim","formattedKey","encrypted","RSA","encrypt","error","console","exports","sha256","cryptoSha256","toString","base64ToBuffer","base64String","binaryString","Buffer","from","bytes","Uint8Array","length","i","charCodeAt","buffer"],"sourceRoot":"..\\..\\..\\src","sources":["utils/crypto.js"],"mappings":";;;;;;AAAA,IAAAA,qBAAA,GAAAC,OAAA;AACA,IAAAC,oBAAA,GAAAD,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,MAAME,UAAU,GAAG,MAAAA,CAAOC,SAAS,EAAEC,IAAI,KAAK;EACnD,IAAI;IACF;IACA,MAAMC,UAAU,GAAGF,SAAS,CACzBG,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CACnBA,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CACzBA,OAAO,CAAC,4BAA4B,EAAE,EAAE,CAAC,CACzCA,OAAO,CAAC,0BAA0B,EAAE,EAAE,CAAC,CACvCC,IAAI,CAAC,CAAC;;IAET;IACA,MAAMC,YAAY,GAAG,+BAA+BH,UAAU,4BAA4B;;IAE1F;IACA,MAAMI,SAAS,GAAG,MAAMC,yBAAG,CAACC,OAAO,CAACP,IAAI,EAAEI,YAAY,CAAC;IACvD,OAAOC,SAAS;EAClB,CAAC,CAAC,OAAOG,KAAK,EAAE;IACdC,OAAO,CAACD,KAAK,CAAC,wBAAwB,EAAEA,KAAK,CAAC;IAC9C,MAAMA,KAAK;EACb;AACF,CAAC;;AAED;AACA;AACA;AACA;AACA;AAJAE,OAAA,CAAAZ,UAAA,GAAAA,UAAA;AAKO,MAAMa,MAAM,GAAIX,IAAI,IAAK;EAC9B,OAAO,IAAAY,2BAAY,EAACZ,IAAI,CAAC,CAACa,QAAQ,CAAC,CAAC;AACtC,CAAC;;AAED;AACA;AACA;AACA;AACA;AAJAH,OAAA,CAAAC,MAAA,GAAAA,MAAA;AAKO,MAAMG,cAAc,GAAIC,YAAY,IAAK;EAC9C,IAAI;IACF,MAAMC,YAAY,GAAGC,MAAM,CAACC,IAAI,CAACH,YAAY,EAAE,QAAQ,CAAC,CAACF,QAAQ,CAAC,QAAQ,CAAC;IAC3E,MAAMM,KAAK,GAAG,IAAIC,UAAU,CAACJ,YAAY,CAACK,MAAM,CAAC;IAEjD,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGN,YAAY,CAACK,MAAM,EAAEC,CAAC,EAAE,EAAE;MAC5CH,KAAK,CAACG,CAAC,CAAC,GAAGN,YAAY,CAACO,UAAU,CAACD,CAAC,CAAC;IACvC;IAEA,OAAOH,KAAK,CAACK,MAAM;EACrB,CAAC,CAAC,OAAOhB,KAAK,EAAE;IACdC,OAAO,CAACD,KAAK,CAAC,oCAAoC,EAAEA,KAAK,CAAC;IAC1D,MAAMA,KAAK;EACb;AACF,CAAC;AAACE,OAAA,CAAAI,cAAA,GAAAA,cAAA","ignoreList":[]}
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.logError = exports.logDebug = exports.logApiRequest = exports.isDebugMode = void 0;
7
+ /**
8
+ * Debug utility functions for Onairos React Native SDK
9
+ */
10
+
11
+ // Determine if we're in dev mode
12
+ const __DEV__ = process.env.NODE_ENV !== 'production';
13
+
14
+ /**
15
+ * Log debug message to console when in development mode
16
+ * @param label Label for the debug message
17
+ * @param data Data to log
18
+ */
19
+ const logDebug = (label, data) => {
20
+ if (__DEV__) {
21
+ console.log(`[Onairos Debug] ${label}:`, data || '');
22
+ }
23
+ };
24
+
25
+ /**
26
+ * Log error message to console
27
+ * @param label Label for the error message
28
+ * @param error Error object or message
29
+ */
30
+ exports.logDebug = logDebug;
31
+ const logError = (label, error) => {
32
+ if (__DEV__) {
33
+ console.error(`[Onairos Error] ${label}:`, error);
34
+ }
35
+ };
36
+
37
+ /**
38
+ * Check if debug mode is enabled
39
+ * @param debug Debug flag passed to component
40
+ * @returns Whether debug mode is enabled
41
+ */
42
+ exports.logError = logError;
43
+ const isDebugMode = debug => {
44
+ return debug === true || __DEV__;
45
+ };
46
+
47
+ /**
48
+ * Format and log API request details
49
+ * @param method HTTP method
50
+ * @param url API URL
51
+ * @param data Request data
52
+ */
53
+ exports.isDebugMode = isDebugMode;
54
+ const logApiRequest = (method, url, data) => {
55
+ if (__DEV__) {
56
+ logDebug('API Request', {
57
+ method,
58
+ url,
59
+ data: data || {}
60
+ });
61
+ }
62
+ };
63
+ exports.logApiRequest = logApiRequest;
64
+ //# sourceMappingURL=debugHelper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["__DEV__","process","env","NODE_ENV","logDebug","label","data","console","log","exports","logError","error","isDebugMode","debug","logApiRequest","method","url"],"sourceRoot":"..\\..\\..\\src","sources":["utils/debugHelper.ts"],"mappings":";;;;;;AAAA;AACA;AACA;;AAEA;AACA,MAAMA,OAAO,GAAGC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY;;AAErD;AACA;AACA;AACA;AACA;AACO,MAAMC,QAAQ,GAAGA,CAACC,KAAa,EAAEC,IAAU,KAAW;EAC3D,IAAIN,OAAO,EAAE;IACXO,OAAO,CAACC,GAAG,CAAC,mBAAmBH,KAAK,GAAG,EAAEC,IAAI,IAAI,EAAE,CAAC;EACtD;AACF,CAAC;;AAED;AACA;AACA;AACA;AACA;AAJAG,OAAA,CAAAL,QAAA,GAAAA,QAAA;AAKO,MAAMM,QAAQ,GAAGA,CAACL,KAAa,EAAEM,KAAU,KAAW;EAC3D,IAAIX,OAAO,EAAE;IACXO,OAAO,CAACI,KAAK,CAAC,mBAAmBN,KAAK,GAAG,EAAEM,KAAK,CAAC;EACnD;AACF,CAAC;;AAED;AACA;AACA;AACA;AACA;AAJAF,OAAA,CAAAC,QAAA,GAAAA,QAAA;AAKO,MAAME,WAAW,GAAIC,KAAe,IAAc;EACvD,OAAOA,KAAK,KAAK,IAAI,IAAIb,OAAO;AAClC,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AALAS,OAAA,CAAAG,WAAA,GAAAA,WAAA;AAMO,MAAME,aAAa,GAAGA,CAACC,MAAc,EAAEC,GAAW,EAAEV,IAAU,KAAW;EAC9E,IAAIN,OAAO,EAAE;IACXI,QAAQ,CAAC,aAAa,EAAE;MACtBW,MAAM;MACNC,GAAG;MACHV,IAAI,EAAEA,IAAI,IAAI,CAAC;IACjB,CAAC,CAAC;EACJ;AACF,CAAC;AAACG,OAAA,CAAAK,aAAA,GAAAA,aAAA","ignoreList":[]}
@@ -0,0 +1,270 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.validateCredentials = exports.updatePlatformConnections = exports.refreshToken = exports.getUserProfile = exports.getPlatformData = exports.createAccount = exports.authenticate = exports.ApiError = void 0;
7
+ var _reactNative = require("react-native");
8
+ var _netinfo = _interopRequireDefault(require("@react-native-community/netinfo"));
9
+ var _debugHelper = require("./debugHelper");
10
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
+ // API configuration
12
+ const API_CONFIG = {
13
+ baseUrl: 'https://api2.onairos.uk',
14
+ version: 'v1',
15
+ timeout: 30000 // 30 seconds
16
+ };
17
+
18
+ // API response types
19
+
20
+ // Error types
21
+
22
+ // API error structure
23
+ class ApiError extends Error {
24
+ constructor(message, type, code, details) {
25
+ super(message);
26
+ this.type = type;
27
+ this.code = code;
28
+ this.details = details;
29
+ this.name = 'ApiError';
30
+ }
31
+ }
32
+
33
+ /**
34
+ * Check if the device has an active network connection
35
+ */
36
+ exports.ApiError = ApiError;
37
+ const checkNetworkConnection = async () => {
38
+ const networkState = await _netinfo.default.fetch();
39
+ return networkState.isConnected === true;
40
+ };
41
+
42
+ /**
43
+ * Build API request headers
44
+ */
45
+ const buildHeaders = (accessToken, additionalHeaders = {}) => {
46
+ const headers = {
47
+ 'Content-Type': 'application/json',
48
+ 'Accept': 'application/json',
49
+ 'User-Agent': `OnairosReactNative/${_reactNative.Platform.OS}/${_reactNative.Platform.Version}`,
50
+ ...additionalHeaders
51
+ };
52
+ if (accessToken) {
53
+ headers['Authorization'] = `Bearer ${accessToken}`;
54
+ }
55
+ return headers;
56
+ };
57
+
58
+ /**
59
+ * Make API request with proper error handling
60
+ */
61
+ const apiRequest = async (endpoint, method, options = {}) => {
62
+ const {
63
+ data,
64
+ accessToken,
65
+ headers = {},
66
+ timeout = API_CONFIG.timeout,
67
+ debug = false
68
+ } = options;
69
+ try {
70
+ // Check for network connectivity
71
+ const isConnected = await checkNetworkConnection();
72
+ if (!isConnected) {
73
+ throw new ApiError('No network connection available', 'network_error');
74
+ }
75
+
76
+ // Build request URL
77
+ const url = `${API_CONFIG.baseUrl}/${API_CONFIG.version}/${endpoint}`;
78
+
79
+ // Log request information if debug mode is enabled
80
+ if (debug) {
81
+ (0, _debugHelper.logDebug)('API Request', {
82
+ url,
83
+ method,
84
+ headers: {
85
+ ...buildHeaders(accessToken, headers),
86
+ Authorization: accessToken ? '[REDACTED]' : undefined
87
+ },
88
+ data: data || null
89
+ });
90
+ }
91
+
92
+ // Set up request options
93
+ const fetchOptions = {
94
+ method,
95
+ headers: buildHeaders(accessToken, headers),
96
+ ...(data ? {
97
+ body: JSON.stringify(data)
98
+ } : {})
99
+ };
100
+
101
+ // Create fetch request with timeout
102
+ const controller = new AbortController();
103
+ const timeoutId = setTimeout(() => controller.abort(), timeout);
104
+
105
+ // Execute request
106
+ const response = await fetch(url, {
107
+ ...fetchOptions,
108
+ signal: controller.signal
109
+ });
110
+
111
+ // Clear timeout
112
+ clearTimeout(timeoutId);
113
+
114
+ // Parse response as JSON
115
+ const responseData = await response.json();
116
+
117
+ // Log response if debug mode is enabled
118
+ if (debug) {
119
+ (0, _debugHelper.logDebug)('API Response', {
120
+ status: response.status,
121
+ data: responseData
122
+ });
123
+ }
124
+
125
+ // Handle API error responses
126
+ if (!response.ok) {
127
+ var _responseData$error, _responseData$error2, _responseData$error3;
128
+ const errorType = response.status === 401 || response.status === 403 ? 'auth_error' : response.status === 400 ? 'validation_error' : response.status >= 500 ? 'server_error' : 'unknown_error';
129
+ throw new ApiError(((_responseData$error = responseData.error) === null || _responseData$error === void 0 ? void 0 : _responseData$error.message) || 'API request failed', errorType, (_responseData$error2 = responseData.error) === null || _responseData$error2 === void 0 ? void 0 : _responseData$error2.code, (_responseData$error3 = responseData.error) === null || _responseData$error3 === void 0 ? void 0 : _responseData$error3.details);
130
+ }
131
+ return responseData;
132
+ } catch (error) {
133
+ // Handle specific error types
134
+ if (error instanceof ApiError) {
135
+ throw error;
136
+ }
137
+ if (error.name === 'AbortError') {
138
+ throw new ApiError('Request timed out', 'timeout_error');
139
+ }
140
+
141
+ // Log error if debug mode is enabled
142
+ if (debug) {
143
+ (0, _debugHelper.logDebug)('API Error', {
144
+ endpoint,
145
+ method,
146
+ error: error.message || 'Unknown error'
147
+ });
148
+ }
149
+
150
+ // Return a generic error for all other cases
151
+ throw new ApiError(error.message || 'An unexpected error occurred', 'unknown_error');
152
+ }
153
+ };
154
+
155
+ /**
156
+ * Validate user credentials with the API
157
+ */
158
+ const validateCredentials = async (username, options = {
159
+ debug: false
160
+ }) => {
161
+ try {
162
+ var _response$data, _response$error;
163
+ const response = await apiRequest('auth/validate', 'POST', {
164
+ data: {
165
+ username
166
+ },
167
+ debug: options.debug
168
+ });
169
+ return {
170
+ isValid: response.success && ((_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.isValid) === true,
171
+ message: (_response$error = response.error) === null || _response$error === void 0 ? void 0 : _response$error.message
172
+ };
173
+ } catch (error) {
174
+ return {
175
+ isValid: false,
176
+ message: error.message
177
+ };
178
+ }
179
+ };
180
+
181
+ /**
182
+ * Create a new user account
183
+ */
184
+ exports.validateCredentials = validateCredentials;
185
+ const createAccount = async (credentials, options = {
186
+ debug: false
187
+ }) => {
188
+ return apiRequest('auth/register', 'POST', {
189
+ data: {
190
+ username: credentials.username,
191
+ platforms: credentials.platforms
192
+ },
193
+ debug: options.debug
194
+ });
195
+ };
196
+
197
+ /**
198
+ * Authenticate with the API using credentials
199
+ */
200
+ exports.createAccount = createAccount;
201
+ const authenticate = async (credentials, options = {
202
+ debug: false
203
+ }) => {
204
+ return apiRequest('auth/login', 'POST', {
205
+ data: {
206
+ username: credentials.username,
207
+ pin: credentials.userPin
208
+ },
209
+ debug: options.debug
210
+ });
211
+ };
212
+
213
+ /**
214
+ * Refresh authentication token
215
+ */
216
+ exports.authenticate = authenticate;
217
+ const refreshToken = async (refreshToken, options = {
218
+ debug: false
219
+ }) => {
220
+ return apiRequest('auth/refresh', 'POST', {
221
+ data: {
222
+ refreshToken
223
+ },
224
+ debug: options.debug
225
+ });
226
+ };
227
+
228
+ /**
229
+ * Get user's connected platform data
230
+ */
231
+ exports.refreshToken = refreshToken;
232
+ const getPlatformData = async (accessToken, platform, options = {
233
+ debug: false
234
+ }) => {
235
+ return apiRequest(`platforms/${platform}/data`, 'GET', {
236
+ accessToken,
237
+ debug: options.debug
238
+ });
239
+ };
240
+
241
+ /**
242
+ * Get user profile information
243
+ */
244
+ exports.getPlatformData = getPlatformData;
245
+ const getUserProfile = async (accessToken, options = {
246
+ debug: false
247
+ }) => {
248
+ return apiRequest('user/profile', 'GET', {
249
+ accessToken,
250
+ debug: options.debug
251
+ });
252
+ };
253
+
254
+ /**
255
+ * Update user platform connections
256
+ */
257
+ exports.getUserProfile = getUserProfile;
258
+ const updatePlatformConnections = async (accessToken, platforms, options = {
259
+ debug: false
260
+ }) => {
261
+ return apiRequest('user/platforms', 'PUT', {
262
+ accessToken,
263
+ data: {
264
+ platforms
265
+ },
266
+ debug: options.debug
267
+ });
268
+ };
269
+ exports.updatePlatformConnections = updatePlatformConnections;
270
+ //# sourceMappingURL=onairosApi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_reactNative","require","_netinfo","_interopRequireDefault","_debugHelper","e","__esModule","default","API_CONFIG","baseUrl","version","timeout","ApiError","Error","constructor","message","type","code","details","name","exports","checkNetworkConnection","networkState","NetInfo","fetch","isConnected","buildHeaders","accessToken","additionalHeaders","headers","Platform","OS","Version","apiRequest","endpoint","method","options","data","debug","url","logDebug","Authorization","undefined","fetchOptions","body","JSON","stringify","controller","AbortController","timeoutId","setTimeout","abort","response","signal","clearTimeout","responseData","json","status","ok","_responseData$error","_responseData$error2","_responseData$error3","errorType","error","validateCredentials","username","_response$data","_response$error","isValid","success","createAccount","credentials","platforms","authenticate","pin","userPin","refreshToken","getPlatformData","platform","getUserProfile","updatePlatformConnections"],"sourceRoot":"..\\..\\..\\src","sources":["utils/onairosApi.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAC,sBAAA,CAAAF,OAAA;AAEA,IAAAG,YAAA,GAAAH,OAAA;AAAyC,SAAAE,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAEzC;AACA,MAAMG,UAAU,GAAG;EACjBC,OAAO,EAAE,yBAAyB;EAClCC,OAAO,EAAE,IAAI;EACbC,OAAO,EAAE,KAAK,CAAE;AAClB,CAAC;;AAED;;AAWA;;AASA;AACO,MAAMC,QAAQ,SAASC,KAAK,CAAC;EAKlCC,WAAWA,CAACC,OA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