@onairos/react-native 3.4.1 → 3.6.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 (574) hide show
  1. package/README.md +423 -374
  2. package/lib/commonjs/api/index.js +9 -145
  3. package/lib/commonjs/assets/animations/loaderani.json +1 -0
  4. package/lib/commonjs/assets/animations/persona-animation.json +1 -0
  5. package/lib/commonjs/assets/fonts/EBGaramond-VariableFont_wght.ttf +0 -0
  6. package/lib/commonjs/assets/fonts/IBMPlexSans-VariableFont_wdth,wght.ttf +0 -0
  7. package/lib/commonjs/assets/icons/Facebookicon.png +0 -0
  8. package/lib/commonjs/assets/icons/Gmail.png +0 -0
  9. package/lib/commonjs/assets/icons/Linkedinicon.png +0 -0
  10. package/lib/commonjs/assets/icons/Redditicon.png +0 -0
  11. package/lib/commonjs/assets/icons/YouTubeicon2.png +0 -0
  12. package/lib/commonjs/assets/icons/YouTubeicon3.png +0 -0
  13. package/lib/commonjs/assets/icons/chatgpt.png +0 -0
  14. package/lib/commonjs/assets/icons/claude.png +0 -0
  15. package/lib/commonjs/assets/icons/gemini.png +0 -0
  16. package/lib/commonjs/assets/icons/grok.png +0 -0
  17. package/lib/commonjs/assets/images/Checkbox.svg +3 -0
  18. package/lib/commonjs/assets/images/EnochE.svg +19 -0
  19. package/lib/commonjs/assets/images/Enochicon1.png +0 -0
  20. package/lib/commonjs/assets/images/Face_ID_logo.png +0 -0
  21. package/lib/commonjs/assets/images/Facebookicon.png +0 -0
  22. package/lib/commonjs/assets/images/Gmail.png +0 -0
  23. package/lib/commonjs/assets/images/Googlelogo.png +0 -0
  24. package/lib/commonjs/assets/images/Linkedinicon.png +0 -0
  25. package/lib/commonjs/assets/images/OnairosNewLogo.png +0 -0
  26. package/lib/commonjs/assets/images/Onairoslogo.png +0 -0
  27. package/lib/commonjs/assets/images/Personalityprofile.svg +3 -0
  28. package/lib/commonjs/assets/images/Personalitytraits.svg +3 -0
  29. package/lib/commonjs/assets/images/Redditicon.png +0 -0
  30. package/lib/commonjs/assets/images/Userpreferences.svg +3 -0
  31. package/lib/commonjs/assets/images/YouTubeicon3.png +0 -0
  32. package/lib/commonjs/assets/images/arrow.svg +20 -0
  33. package/lib/commonjs/assets/images/basicproficon.svg +43 -0
  34. package/lib/commonjs/assets/images/basicprofile.svg +3 -0
  35. package/lib/commonjs/assets/images/chatgpt.png +0 -0
  36. package/lib/commonjs/assets/images/checkmark.svg +4 -0
  37. package/lib/commonjs/assets/images/claude.png +0 -0
  38. package/lib/commonjs/assets/images/contentanalysis.svg +3 -0
  39. package/lib/commonjs/assets/images/contenticon.svg +23 -0
  40. package/lib/commonjs/assets/images/gemini.png +0 -0
  41. package/lib/commonjs/assets/images/grok.png +0 -0
  42. package/lib/commonjs/assets/images/persona1.png +0 -0
  43. package/lib/commonjs/assets/images/persona2.png +0 -0
  44. package/lib/commonjs/assets/images/persona3.png +0 -0
  45. package/lib/commonjs/assets/images/persona4.png +0 -0
  46. package/lib/commonjs/assets/images/persona5.png +0 -0
  47. package/lib/commonjs/assets/images/personalityicon.svg +18 -0
  48. package/lib/commonjs/assets/images/x-close.svg +3 -0
  49. package/lib/commonjs/components/BodyText.js +9 -0
  50. package/lib/commonjs/components/BrandMark.js +10 -0
  51. package/lib/commonjs/components/CodeInput.js +9 -0
  52. package/lib/commonjs/components/EmailInput.js +8 -0
  53. package/lib/commonjs/components/GoogleButton.js +9 -0
  54. package/lib/commonjs/components/HeadingGroup.js +9 -0
  55. package/lib/commonjs/components/LLMDataInputModal.js +14 -0
  56. package/lib/commonjs/components/ModalHeader.js +9 -0
  57. package/lib/commonjs/components/ModalSheet.js +9 -0
  58. package/lib/commonjs/components/Onairos.js +14 -374
  59. package/lib/commonjs/components/OnairosButton.js +13 -309
  60. package/lib/commonjs/components/OnairosSignInButton.js +12 -0
  61. package/lib/commonjs/components/Overlay.js +13 -483
  62. package/lib/commonjs/components/PersonaImage.js +10 -0
  63. package/lib/commonjs/components/PersonaLoadingScreen.js +12 -0
  64. package/lib/commonjs/components/PersonalizationConsentScreen.js +13 -0
  65. package/lib/commonjs/components/PinCreationScreen.js +12 -0
  66. package/lib/commonjs/components/PinInput.js +9 -302
  67. package/lib/commonjs/components/PlatformConnectorsStep.js +23 -0
  68. package/lib/commonjs/components/PlatformList.js +10 -137
  69. package/lib/commonjs/components/PlatformToggle.js +9 -0
  70. package/lib/commonjs/components/PrimaryButton.js +10 -0
  71. package/lib/commonjs/components/SignInMatchAnimation.js +9 -0
  72. package/lib/commonjs/components/SignInStep.js +12 -0
  73. package/lib/commonjs/components/UniversalOnboarding.js +30 -1702
  74. package/lib/commonjs/components/VerificationStep.js +11 -0
  75. package/lib/commonjs/components/WelcomeScreen.js +22 -0
  76. package/lib/commonjs/components/icons/Basicproficon.js +8 -0
  77. package/lib/commonjs/components/icons/Basicprofile.js +8 -0
  78. package/lib/commonjs/components/icons/Checkbox.js +8 -0
  79. package/lib/commonjs/components/icons/Checkmark.js +8 -0
  80. package/lib/commonjs/components/icons/Contentanalysis.js +8 -0
  81. package/lib/commonjs/components/icons/Contenticon.js +8 -0
  82. package/lib/commonjs/components/icons/EnochE.js +8 -0
  83. package/lib/commonjs/components/icons/Personalityicon.js +8 -0
  84. package/lib/commonjs/components/icons/Personalityprofile.js +8 -0
  85. package/lib/commonjs/components/icons/Personalitytraits.js +8 -0
  86. package/lib/commonjs/components/icons/Userpreferences.js +8 -0
  87. package/lib/commonjs/components/icons/index.js +17 -0
  88. package/lib/commonjs/components/onboarding/OAuthWebView.js +18 -827
  89. package/lib/commonjs/components/onboarding/OnboardingHeader.js +10 -74
  90. package/lib/commonjs/components/onboarding/PinInput.js +10 -283
  91. package/lib/commonjs/components/onboarding/PlatformConnector.js +11 -249
  92. package/lib/commonjs/config/api.js +7 -0
  93. package/lib/commonjs/constants/index.js +7 -83
  94. package/lib/commonjs/context/AuthContext.js +10 -0
  95. package/lib/commonjs/hooks/useConnectedAccounts.js +9 -0
  96. package/lib/commonjs/hooks/useConnections.js +8 -159
  97. package/lib/commonjs/hooks/useCredentials.js +10 -177
  98. package/lib/commonjs/hooks/useUserConnections.js +10 -0
  99. package/lib/commonjs/index.js +34 -106
  100. package/lib/commonjs/services/SDK_API_KEY_VALIDATION.md +421 -421
  101. package/lib/commonjs/services/apiClient.js +8 -0
  102. package/lib/commonjs/services/apiKeyService.js +9 -952
  103. package/lib/commonjs/services/authService.js +10 -0
  104. package/lib/commonjs/services/biometricPinService.js +8 -0
  105. package/lib/commonjs/services/chatGPTConversationExtractor.js +8 -0
  106. package/lib/commonjs/services/chatGPTConversationService.js +9 -0
  107. package/lib/commonjs/services/claudeConversationExtractor.js +8 -0
  108. package/lib/commonjs/services/claudeConversationService.js +9 -0
  109. package/lib/commonjs/services/connectedAccountsService.js +10 -0
  110. package/lib/commonjs/services/googleAuthService.js +11 -0
  111. package/lib/commonjs/services/hingeDataExtractor.js +8 -0
  112. package/lib/commonjs/services/hingeDataService.js +9 -0
  113. package/lib/commonjs/services/imageCompressionService.js +7 -0
  114. package/lib/commonjs/services/instagramDataExtractor.js +8 -0
  115. package/lib/commonjs/services/instagramDataService.js +9 -0
  116. package/lib/commonjs/services/jwtStorageService.js +7 -0
  117. package/lib/commonjs/services/linkedinDOMExtractor.js +7 -0
  118. package/lib/commonjs/services/linkedinProfileService.js +9 -0
  119. package/lib/commonjs/services/linkedinScrapingService.js +8 -0
  120. package/lib/commonjs/services/llmDataStorage.js +8 -0
  121. package/lib/commonjs/services/mobileTrainingService.js +8 -0
  122. package/lib/commonjs/services/oauthService.js +11 -390
  123. package/lib/commonjs/services/pinEncryptionService.js +8 -0
  124. package/lib/commonjs/services/pinStorageUtils.js +7 -0
  125. package/lib/commonjs/services/platformAuthService.js +12 -1067
  126. package/lib/commonjs/services/sephoraDataExtractor.js +8 -0
  127. package/lib/commonjs/services/sephoraDataService.js +9 -0
  128. package/lib/commonjs/services/storageService.js +8 -0
  129. package/lib/commonjs/services/telegramDataExtractor.js +8 -0
  130. package/lib/commonjs/services/telegramDataService.js +11 -0
  131. package/lib/commonjs/services/trainingApiHelpers.js +7 -0
  132. package/lib/commonjs/services/userConnectionsService.js +10 -0
  133. package/lib/commonjs/services/youtubeMigrationService.js +10 -0
  134. package/lib/commonjs/theme/index.js +7 -0
  135. package/lib/commonjs/types/ambient.d.js +1 -2
  136. package/lib/commonjs/types/declarations.d.js +1 -2
  137. package/lib/commonjs/types/index.js +1 -6
  138. package/lib/commonjs/types/node-fix.d.js +1 -2
  139. package/lib/commonjs/types/node-override.d.js +1 -2
  140. package/lib/commonjs/types/opacity.d.js +1 -2
  141. package/lib/commonjs/types.js +1 -14
  142. package/lib/commonjs/utils/Portal.js +8 -98
  143. package/lib/commonjs/utils/api.js +9 -129
  144. package/lib/commonjs/utils/assetRegistry.js +33 -0
  145. package/lib/commonjs/utils/auth.js +9 -111
  146. package/lib/commonjs/utils/connectorTests.js +29 -0
  147. package/lib/commonjs/utils/crypto.js +8 -62
  148. package/lib/commonjs/utils/debugHelper.js +1 -64
  149. package/lib/commonjs/utils/encryption.js +7 -76
  150. package/lib/commonjs/utils/eventUtils.js +1 -0
  151. package/lib/commonjs/utils/haptics.js +9 -0
  152. package/lib/commonjs/utils/imagePreloader.js +1 -0
  153. package/lib/commonjs/utils/networkDiagnostics.js +8 -0
  154. package/lib/commonjs/utils/onairosApi.js +9 -350
  155. package/lib/commonjs/utils/programmaticFlow.js +9 -117
  156. package/lib/commonjs/utils/retryHelper.js +1 -220
  157. package/lib/commonjs/utils/secureStorage.js +10 -349
  158. package/lib/commonjs/utils/webviewScripts/chatgpt.js +1 -0
  159. package/lib/commonjs/utils/webviewScripts/claude.js +1 -0
  160. package/lib/commonjs/utils/webviewScripts/hinge.js +1 -0
  161. package/lib/commonjs/utils/webviewScripts/index.js +13 -0
  162. package/lib/commonjs/utils/webviewScripts/instagram.js +1 -0
  163. package/lib/commonjs/utils/webviewScripts/linkedin.js +1 -0
  164. package/lib/commonjs/utils/webviewScripts/sephora.js +1 -0
  165. package/lib/commonjs/utils/webviewScripts/telegram.js +1 -0
  166. package/lib/module/api/index.js +1 -139
  167. package/lib/module/assets/animations/loaderani.json +1 -0
  168. package/lib/module/assets/animations/persona-animation.json +1 -0
  169. package/lib/module/assets/fonts/EBGaramond-VariableFont_wght.ttf +0 -0
  170. package/lib/module/assets/fonts/IBMPlexSans-VariableFont_wdth,wght.ttf +0 -0
  171. package/lib/module/assets/icons/Facebookicon.png +0 -0
  172. package/lib/module/assets/icons/Gmail.png +0 -0
  173. package/lib/module/assets/icons/Linkedinicon.png +0 -0
  174. package/lib/module/assets/icons/Redditicon.png +0 -0
  175. package/lib/module/assets/icons/YouTubeicon2.png +0 -0
  176. package/lib/module/assets/icons/YouTubeicon3.png +0 -0
  177. package/lib/module/assets/icons/chatgpt.png +0 -0
  178. package/lib/module/assets/icons/claude.png +0 -0
  179. package/lib/module/assets/icons/farcaster.png +0 -0
  180. package/lib/module/assets/icons/gemini.png +0 -0
  181. package/lib/module/assets/icons/grok.png +0 -0
  182. package/lib/module/assets/icons/instagram.png +0 -0
  183. package/lib/module/assets/icons/pinterest.png +0 -0
  184. package/lib/module/assets/icons/swerv_logo.png +0 -0
  185. package/lib/module/assets/icons/twitter.jpg +0 -0
  186. package/lib/module/assets/images/Checkbox.svg +3 -0
  187. package/lib/module/assets/images/EnochE.svg +19 -0
  188. package/lib/module/assets/images/Enochicon1.png +0 -0
  189. package/lib/module/assets/images/Face_ID_logo.png +0 -0
  190. package/lib/module/assets/images/Facebookicon.png +0 -0
  191. package/lib/module/assets/images/Gmail.png +0 -0
  192. package/lib/module/assets/images/Googlelogo.png +0 -0
  193. package/lib/module/assets/images/Linkedinicon.png +0 -0
  194. package/lib/module/assets/images/OnairosNewLogo.png +0 -0
  195. package/lib/module/assets/images/Onairoslogo.png +0 -0
  196. package/lib/module/assets/images/Personalityprofile.svg +3 -0
  197. package/lib/module/assets/images/Personalitytraits.svg +3 -0
  198. package/lib/module/assets/images/Redditicon.png +0 -0
  199. package/lib/module/assets/images/Userpreferences.svg +3 -0
  200. package/lib/module/assets/images/YouTubeicon3.png +0 -0
  201. package/lib/module/assets/images/arrow.svg +20 -0
  202. package/lib/module/assets/images/basicproficon.svg +43 -0
  203. package/lib/module/assets/images/basicprofile.svg +3 -0
  204. package/lib/module/assets/images/chatgpt.png +0 -0
  205. package/lib/module/assets/images/checkmark.svg +4 -0
  206. package/lib/module/assets/images/claude.png +0 -0
  207. package/lib/module/assets/images/contentanalysis.svg +3 -0
  208. package/lib/module/assets/images/contenticon.svg +23 -0
  209. package/lib/module/assets/images/gemini.png +0 -0
  210. package/lib/module/assets/images/grok.png +0 -0
  211. package/lib/module/assets/images/persona1.png +0 -0
  212. package/lib/module/assets/images/persona2.png +0 -0
  213. package/lib/module/assets/images/persona3.png +0 -0
  214. package/lib/module/assets/images/persona4.png +0 -0
  215. package/lib/module/assets/images/persona5.png +0 -0
  216. package/lib/module/assets/images/personalityicon.svg +18 -0
  217. package/lib/module/assets/images/x-close.svg +3 -0
  218. package/lib/module/components/BodyText.js +1 -0
  219. package/lib/module/components/BrandMark.js +1 -0
  220. package/lib/module/components/CodeInput.js +1 -0
  221. package/lib/module/components/EmailInput.js +1 -0
  222. package/lib/module/components/GoogleButton.js +1 -0
  223. package/lib/module/components/HeadingGroup.js +1 -0
  224. package/lib/module/components/LLMDataInputModal.js +8 -0
  225. package/lib/module/components/ModalHeader.js +1 -0
  226. package/lib/module/components/ModalSheet.js +1 -0
  227. package/lib/module/components/Onairos.js +1 -367
  228. package/lib/module/components/OnairosButton.js +1 -302
  229. package/lib/module/components/OnairosSignInButton.js +1 -0
  230. package/lib/module/components/Overlay.js +1 -474
  231. package/lib/module/components/PersonaImage.js +1 -0
  232. package/lib/module/components/PersonaLoadingScreen.js +1 -0
  233. package/lib/module/components/PersonalizationConsentScreen.js +1 -0
  234. package/lib/module/components/PinCreationScreen.js +1 -0
  235. package/lib/module/components/PinInput.js +1 -293
  236. package/lib/module/components/PlatformConnectorsStep.js +7 -0
  237. package/lib/module/components/PlatformList.js +1 -129
  238. package/lib/module/components/PlatformToggle.js +1 -0
  239. package/lib/module/components/PrimaryButton.js +1 -0
  240. package/lib/module/components/SignInMatchAnimation.js +1 -0
  241. package/lib/module/components/SignInStep.js +1 -0
  242. package/lib/module/components/UniversalOnboarding.js +1 -1693
  243. package/lib/module/components/VerificationStep.js +1 -0
  244. package/lib/module/components/WelcomeScreen.js +1 -0
  245. package/lib/module/components/icons/Basicproficon.js +1 -0
  246. package/lib/module/components/icons/Basicprofile.js +1 -0
  247. package/lib/module/components/icons/Checkbox.js +1 -0
  248. package/lib/module/components/icons/Checkmark.js +1 -0
  249. package/lib/module/components/icons/Contentanalysis.js +1 -0
  250. package/lib/module/components/icons/Contenticon.js +1 -0
  251. package/lib/module/components/icons/EnochE.js +1 -0
  252. package/lib/module/components/icons/Personalityicon.js +1 -0
  253. package/lib/module/components/icons/Personalityprofile.js +1 -0
  254. package/lib/module/components/icons/Personalitytraits.js +1 -0
  255. package/lib/module/components/icons/Userpreferences.js +1 -0
  256. package/lib/module/components/icons/index.js +1 -0
  257. package/lib/module/components/onboarding/OAuthWebView.js +1 -818
  258. package/lib/module/components/onboarding/OnboardingHeader.js +1 -66
  259. package/lib/module/components/onboarding/PinInput.js +1 -274
  260. package/lib/module/components/onboarding/PlatformConnector.js +1 -240
  261. package/lib/module/config/api.js +1 -0
  262. package/lib/module/constants/index.js +1 -77
  263. package/lib/module/context/AuthContext.js +1 -0
  264. package/lib/module/hooks/useConnectedAccounts.js +1 -0
  265. package/lib/module/hooks/useConnections.js +1 -152
  266. package/lib/module/hooks/useCredentials.js +6 -169
  267. package/lib/module/hooks/useUserConnections.js +1 -0
  268. package/lib/module/index.js +1 -32
  269. package/lib/module/services/SDK_API_KEY_VALIDATION.md +421 -421
  270. package/lib/module/services/apiClient.js +1 -0
  271. package/lib/module/services/apiKeyService.js +1 -925
  272. package/lib/module/services/authService.js +1 -0
  273. package/lib/module/services/biometricPinService.js +1 -0
  274. package/lib/module/services/chatGPTConversationExtractor.js +1 -0
  275. package/lib/module/services/chatGPTConversationService.js +1 -0
  276. package/lib/module/services/claudeConversationExtractor.js +1 -0
  277. package/lib/module/services/claudeConversationService.js +1 -0
  278. package/lib/module/services/connectedAccountsService.js +1 -0
  279. package/lib/module/services/googleAuthService.js +1 -0
  280. package/lib/module/services/hingeDataExtractor.js +1 -0
  281. package/lib/module/services/hingeDataService.js +1 -0
  282. package/lib/module/services/imageCompressionService.js +1 -0
  283. package/lib/module/services/instagramDataExtractor.js +1 -0
  284. package/lib/module/services/instagramDataService.js +1 -0
  285. package/lib/module/services/jwtStorageService.js +1 -0
  286. package/lib/module/services/linkedinDOMExtractor.js +1 -0
  287. package/lib/module/services/linkedinProfileService.js +1 -0
  288. package/lib/module/services/linkedinScrapingService.js +1 -0
  289. package/lib/module/services/llmDataStorage.js +1 -0
  290. package/lib/module/services/mobileTrainingService.js +1 -0
  291. package/lib/module/services/oauthService.js +1 -380
  292. package/lib/module/services/pinEncryptionService.js +7 -0
  293. package/lib/module/services/pinStorageUtils.js +1 -0
  294. package/lib/module/services/platformAuthService.js +1 -1041
  295. package/lib/module/services/sephoraDataExtractor.js +1 -0
  296. package/lib/module/services/sephoraDataService.js +1 -0
  297. package/lib/module/services/storageService.js +1 -0
  298. package/lib/module/services/telegramDataExtractor.js +1 -0
  299. package/lib/module/services/telegramDataService.js +8 -0
  300. package/lib/module/services/trainingApiHelpers.js +1 -0
  301. package/lib/module/services/userConnectionsService.js +1 -0
  302. package/lib/module/services/youtubeMigrationService.js +1 -0
  303. package/lib/module/theme/index.js +1 -0
  304. package/lib/module/types.js +1 -10
  305. package/lib/module/utils/Portal.js +1 -90
  306. package/lib/module/utils/api.js +1 -117
  307. package/lib/module/utils/assetRegistry.js +33 -0
  308. package/lib/module/utils/auth.js +1 -99
  309. package/lib/module/utils/connectorTests.js +28 -0
  310. package/lib/module/utils/crypto.js +1 -54
  311. package/lib/module/utils/debugHelper.js +1 -54
  312. package/lib/module/utils/encryption.js +1 -67
  313. package/lib/module/utils/eventUtils.js +1 -0
  314. package/lib/module/utils/haptics.js +8 -0
  315. package/lib/module/utils/imagePreloader.js +1 -0
  316. package/lib/module/utils/networkDiagnostics.js +1 -0
  317. package/lib/module/utils/onairosApi.js +1 -333
  318. package/lib/module/utils/programmaticFlow.js +1 -111
  319. package/lib/module/utils/retryHelper.js +1 -211
  320. package/lib/module/utils/secureStorage.js +6 -330
  321. package/lib/module/utils/webviewScripts/chatgpt.js +1 -0
  322. package/lib/module/utils/webviewScripts/claude.js +1 -0
  323. package/lib/module/utils/webviewScripts/hinge.js +1 -0
  324. package/lib/module/utils/webviewScripts/index.js +1 -0
  325. package/lib/module/utils/webviewScripts/instagram.js +1 -0
  326. package/lib/module/utils/webviewScripts/linkedin.js +1 -0
  327. package/lib/module/utils/webviewScripts/sephora.js +1 -0
  328. package/lib/module/utils/webviewScripts/telegram.js +1 -0
  329. package/package.json +62 -39
  330. package/lib/commonjs/api/index.js.map +0 -1
  331. package/lib/commonjs/assets/images/email.png +0 -0
  332. package/lib/commonjs/assets/images/linkedin.png +0 -0
  333. package/lib/commonjs/assets/images/reddit.png +0 -0
  334. package/lib/commonjs/assets/images/youtube.png +0 -0
  335. package/lib/commonjs/components/DataRequestModal.js +0 -228
  336. package/lib/commonjs/components/DataRequestModal.js.map +0 -1
  337. package/lib/commonjs/components/DataRequestScreen.js +0 -329
  338. package/lib/commonjs/components/DataRequestScreen.js.map +0 -1
  339. package/lib/commonjs/components/EmailVerificationModal.js +0 -320
  340. package/lib/commonjs/components/EmailVerificationModal.js.map +0 -1
  341. package/lib/commonjs/components/Onairos.js.map +0 -1
  342. package/lib/commonjs/components/OnairosButton.js.map +0 -1
  343. package/lib/commonjs/components/Overlay.js.map +0 -1
  344. package/lib/commonjs/components/PinInput.js.map +0 -1
  345. package/lib/commonjs/components/PlatformList.js.map +0 -1
  346. package/lib/commonjs/components/TrainingModal.js +0 -717
  347. package/lib/commonjs/components/TrainingModal.js.map +0 -1
  348. package/lib/commonjs/components/UniversalOnboarding.js.map +0 -1
  349. package/lib/commonjs/components/UniversalOnboarding.tsx.new +0 -455
  350. package/lib/commonjs/components/onboarding/OAuthWebView.js.map +0 -1
  351. package/lib/commonjs/components/onboarding/OnboardingHeader.js.map +0 -1
  352. package/lib/commonjs/components/onboarding/PinInput.js.map +0 -1
  353. package/lib/commonjs/components/onboarding/PlatformConnector.js.map +0 -1
  354. package/lib/commonjs/components/screens/ConnectorScreen.js +0 -146
  355. package/lib/commonjs/components/screens/ConnectorScreen.js.map +0 -1
  356. package/lib/commonjs/components/screens/LoadingScreen.js +0 -91
  357. package/lib/commonjs/components/screens/LoadingScreen.js.map +0 -1
  358. package/lib/commonjs/components/screens/PinCreationScreen.js +0 -61
  359. package/lib/commonjs/components/screens/PinCreationScreen.js.map +0 -1
  360. package/lib/commonjs/constants/index.js.map +0 -1
  361. package/lib/commonjs/hooks/useConnections.js.map +0 -1
  362. package/lib/commonjs/hooks/useCredentials.js.map +0 -1
  363. package/lib/commonjs/index.js.map +0 -1
  364. package/lib/commonjs/services/apiKeyService.js.map +0 -1
  365. package/lib/commonjs/services/oauthService.js.map +0 -1
  366. package/lib/commonjs/services/platformAuthService.js.map +0 -1
  367. package/lib/commonjs/types/ambient.d.js.map +0 -1
  368. package/lib/commonjs/types/declarations.d.js.map +0 -1
  369. package/lib/commonjs/types/index.d.js.map +0 -1
  370. package/lib/commonjs/types/index.js.map +0 -1
  371. package/lib/commonjs/types/node-fix.d.js.map +0 -1
  372. package/lib/commonjs/types/node-override.d.js.map +0 -1
  373. package/lib/commonjs/types/opacity.d.js.map +0 -1
  374. package/lib/commonjs/types/types.d.js.map +0 -1
  375. package/lib/commonjs/types.js.map +0 -1
  376. package/lib/commonjs/utils/Portal.js.map +0 -1
  377. package/lib/commonjs/utils/api.js.map +0 -1
  378. package/lib/commonjs/utils/auth.js.map +0 -1
  379. package/lib/commonjs/utils/crypto.js.map +0 -1
  380. package/lib/commonjs/utils/debugHelper.js.map +0 -1
  381. package/lib/commonjs/utils/encryption.js.map +0 -1
  382. package/lib/commonjs/utils/onairosApi.js.map +0 -1
  383. package/lib/commonjs/utils/programmaticFlow.js.map +0 -1
  384. package/lib/commonjs/utils/retryHelper.js.map +0 -1
  385. package/lib/commonjs/utils/secureStorage.js.map +0 -1
  386. package/lib/module/api/index.js.map +0 -1
  387. package/lib/module/assets/images/email.png +0 -0
  388. package/lib/module/assets/images/linkedin.png +0 -0
  389. package/lib/module/assets/images/reddit.png +0 -0
  390. package/lib/module/assets/images/youtube.png +0 -0
  391. package/lib/module/components/DataRequestModal.js +0 -220
  392. package/lib/module/components/DataRequestModal.js.map +0 -1
  393. package/lib/module/components/DataRequestScreen.js +0 -321
  394. package/lib/module/components/DataRequestScreen.js.map +0 -1
  395. package/lib/module/components/EmailVerificationModal.js +0 -311
  396. package/lib/module/components/EmailVerificationModal.js.map +0 -1
  397. package/lib/module/components/Onairos.js.map +0 -1
  398. package/lib/module/components/OnairosButton.js.map +0 -1
  399. package/lib/module/components/Overlay.js.map +0 -1
  400. package/lib/module/components/PinInput.js.map +0 -1
  401. package/lib/module/components/PlatformList.js.map +0 -1
  402. package/lib/module/components/TrainingModal.js +0 -708
  403. package/lib/module/components/TrainingModal.js.map +0 -1
  404. package/lib/module/components/UniversalOnboarding.js.map +0 -1
  405. package/lib/module/components/UniversalOnboarding.tsx.new +0 -455
  406. package/lib/module/components/onboarding/OAuthWebView.js.map +0 -1
  407. package/lib/module/components/onboarding/OnboardingHeader.js.map +0 -1
  408. package/lib/module/components/onboarding/PinInput.js.map +0 -1
  409. package/lib/module/components/onboarding/PlatformConnector.js.map +0 -1
  410. package/lib/module/components/screens/ConnectorScreen.js +0 -138
  411. package/lib/module/components/screens/ConnectorScreen.js.map +0 -1
  412. package/lib/module/components/screens/LoadingScreen.js +0 -83
  413. package/lib/module/components/screens/LoadingScreen.js.map +0 -1
  414. package/lib/module/components/screens/PinCreationScreen.js +0 -53
  415. package/lib/module/components/screens/PinCreationScreen.js.map +0 -1
  416. package/lib/module/constants/index.js.map +0 -1
  417. package/lib/module/hooks/useConnections.js.map +0 -1
  418. package/lib/module/hooks/useCredentials.js.map +0 -1
  419. package/lib/module/index.js.map +0 -1
  420. package/lib/module/services/apiKeyService.js.map +0 -1
  421. package/lib/module/services/oauthService.js.map +0 -1
  422. package/lib/module/services/platformAuthService.js.map +0 -1
  423. package/lib/module/types/ambient.d.js.map +0 -1
  424. package/lib/module/types/declarations.d.js.map +0 -1
  425. package/lib/module/types/index.d.js.map +0 -1
  426. package/lib/module/types/index.js.map +0 -1
  427. package/lib/module/types/node-fix.d.js.map +0 -1
  428. package/lib/module/types/node-override.d.js.map +0 -1
  429. package/lib/module/types/opacity.d.js.map +0 -1
  430. package/lib/module/types/types.d.js.map +0 -1
  431. package/lib/module/types.js.map +0 -1
  432. package/lib/module/utils/Portal.js.map +0 -1
  433. package/lib/module/utils/api.js.map +0 -1
  434. package/lib/module/utils/auth.js.map +0 -1
  435. package/lib/module/utils/crypto.js.map +0 -1
  436. package/lib/module/utils/debugHelper.js.map +0 -1
  437. package/lib/module/utils/encryption.js.map +0 -1
  438. package/lib/module/utils/onairosApi.js.map +0 -1
  439. package/lib/module/utils/programmaticFlow.js.map +0 -1
  440. package/lib/module/utils/retryHelper.js.map +0 -1
  441. package/lib/module/utils/secureStorage.js.map +0 -1
  442. package/lib/typescript/api/index.d.ts +0 -8
  443. package/lib/typescript/api/index.d.ts.map +0 -1
  444. package/lib/typescript/components/DataRequestModal.d.ts +0 -11
  445. package/lib/typescript/components/DataRequestModal.d.ts.map +0 -1
  446. package/lib/typescript/components/DataRequestScreen.d.ts +0 -11
  447. package/lib/typescript/components/DataRequestScreen.d.ts.map +0 -1
  448. package/lib/typescript/components/EmailVerificationModal.d.ts +0 -11
  449. package/lib/typescript/components/EmailVerificationModal.d.ts.map +0 -1
  450. package/lib/typescript/components/Onairos.d.ts +0 -4
  451. package/lib/typescript/components/Onairos.d.ts.map +0 -1
  452. package/lib/typescript/components/OnairosButton.d.ts +0 -12
  453. package/lib/typescript/components/OnairosButton.d.ts.map +0 -1
  454. package/lib/typescript/components/Overlay.d.ts +0 -4
  455. package/lib/typescript/components/Overlay.d.ts.map +0 -1
  456. package/lib/typescript/components/PinInput.d.ts +0 -4
  457. package/lib/typescript/components/PinInput.d.ts.map +0 -1
  458. package/lib/typescript/components/PlatformList.d.ts +0 -4
  459. package/lib/typescript/components/PlatformList.d.ts.map +0 -1
  460. package/lib/typescript/components/TrainingModal.d.ts +0 -4
  461. package/lib/typescript/components/TrainingModal.d.ts.map +0 -1
  462. package/lib/typescript/components/UniversalOnboarding.d.ts +0 -4
  463. package/lib/typescript/components/UniversalOnboarding.d.ts.map +0 -1
  464. package/lib/typescript/components/onboarding/OAuthWebView.d.ts +0 -10
  465. package/lib/typescript/components/onboarding/OAuthWebView.d.ts.map +0 -1
  466. package/lib/typescript/components/onboarding/OnboardingHeader.d.ts +0 -11
  467. package/lib/typescript/components/onboarding/OnboardingHeader.d.ts.map +0 -1
  468. package/lib/typescript/components/onboarding/PinInput.d.ts +0 -4
  469. package/lib/typescript/components/onboarding/PinInput.d.ts.map +0 -1
  470. package/lib/typescript/components/onboarding/PlatformConnector.d.ts +0 -13
  471. package/lib/typescript/components/onboarding/PlatformConnector.d.ts.map +0 -1
  472. package/lib/typescript/components/screens/ConnectorScreen.d.ts +0 -9
  473. package/lib/typescript/components/screens/ConnectorScreen.d.ts.map +0 -1
  474. package/lib/typescript/components/screens/LoadingScreen.d.ts +0 -9
  475. package/lib/typescript/components/screens/LoadingScreen.d.ts.map +0 -1
  476. package/lib/typescript/components/screens/PinCreationScreen.d.ts +0 -10
  477. package/lib/typescript/components/screens/PinCreationScreen.d.ts.map +0 -1
  478. package/lib/typescript/constants/index.d.ts +0 -53
  479. package/lib/typescript/constants/index.d.ts.map +0 -1
  480. package/lib/typescript/hooks/useConnections.d.ts +0 -9
  481. package/lib/typescript/hooks/useConnections.d.ts.map +0 -1
  482. package/lib/typescript/hooks/useCredentials.d.ts +0 -9
  483. package/lib/typescript/hooks/useCredentials.d.ts.map +0 -1
  484. package/lib/typescript/index.d.ts +0 -18
  485. package/lib/typescript/index.d.ts.map +0 -1
  486. package/lib/typescript/services/apiKeyService.d.ts +0 -132
  487. package/lib/typescript/services/apiKeyService.d.ts.map +0 -1
  488. package/lib/typescript/services/oauthService.d.ts +0 -50
  489. package/lib/typescript/services/oauthService.d.ts.map +0 -1
  490. package/lib/typescript/services/platformAuthService.d.ts +0 -144
  491. package/lib/typescript/services/platformAuthService.d.ts.map +0 -1
  492. package/lib/typescript/types/index.d.ts +0 -231
  493. package/lib/typescript/types/index.d.ts.map +0 -1
  494. package/lib/typescript/types.d.ts +0 -270
  495. package/lib/typescript/types.d.ts.map +0 -1
  496. package/lib/typescript/utils/Portal.d.ts +0 -14
  497. package/lib/typescript/utils/Portal.d.ts.map +0 -1
  498. package/lib/typescript/utils/api.d.ts +0 -6
  499. package/lib/typescript/utils/api.d.ts.map +0 -1
  500. package/lib/typescript/utils/auth.d.ts +0 -6
  501. package/lib/typescript/utils/auth.d.ts.map +0 -1
  502. package/lib/typescript/utils/crypto.d.ts +0 -4
  503. package/lib/typescript/utils/crypto.d.ts.map +0 -1
  504. package/lib/typescript/utils/debugHelper.d.ts +0 -29
  505. package/lib/typescript/utils/debugHelper.d.ts.map +0 -1
  506. package/lib/typescript/utils/encryption.d.ts +0 -19
  507. package/lib/typescript/utils/encryption.d.ts.map +0 -1
  508. package/lib/typescript/utils/onairosApi.d.ts +0 -87
  509. package/lib/typescript/utils/onairosApi.d.ts.map +0 -1
  510. package/lib/typescript/utils/programmaticFlow.d.ts +0 -23
  511. package/lib/typescript/utils/programmaticFlow.d.ts.map +0 -1
  512. package/lib/typescript/utils/retryHelper.d.ts +0 -69
  513. package/lib/typescript/utils/retryHelper.d.ts.map +0 -1
  514. package/lib/typescript/utils/secureStorage.d.ts +0 -94
  515. package/lib/typescript/utils/secureStorage.d.ts.map +0 -1
  516. package/src/api/index.ts +0 -111
  517. package/src/assets/images/email.png +0 -0
  518. package/src/assets/images/linkedin.png +0 -0
  519. package/src/assets/images/onairos_logo.png +0 -0
  520. package/src/assets/images/reddit.png +0 -0
  521. package/src/assets/images/youtube.png +0 -0
  522. package/src/components/DataRequestModal.tsx +0 -227
  523. package/src/components/DataRequestScreen.tsx +0 -356
  524. package/src/components/EmailVerificationModal.tsx +0 -364
  525. package/src/components/Onairos.tsx +0 -425
  526. package/src/components/OnairosButton.tsx +0 -359
  527. package/src/components/Overlay.tsx +0 -506
  528. package/src/components/PinInput.tsx +0 -343
  529. package/src/components/PlatformList.tsx +0 -145
  530. package/src/components/TrainingModal.tsx +0 -737
  531. package/src/components/UniversalOnboarding.tsx +0 -1839
  532. package/src/components/UniversalOnboarding.tsx.new +0 -455
  533. package/src/components/onboarding/OAuthWebView.tsx +0 -838
  534. package/src/components/onboarding/OnboardingHeader.tsx +0 -70
  535. package/src/components/onboarding/PinInput.tsx +0 -356
  536. package/src/components/onboarding/PlatformConnector.tsx +0 -302
  537. package/src/components/screens/ConnectorScreen.tsx +0 -153
  538. package/src/components/screens/LoadingScreen.tsx +0 -100
  539. package/src/components/screens/PinCreationScreen.tsx +0 -67
  540. package/src/constants/index.ts +0 -83
  541. package/src/hooks/useConnections.ts +0 -163
  542. package/src/hooks/useCredentials.ts +0 -175
  543. package/src/index.js +0 -14
  544. package/src/index.ts +0 -50
  545. package/src/services/SDK_API_KEY_VALIDATION.md +0 -421
  546. package/src/services/apiKeyService.ts +0 -984
  547. package/src/services/oauthService.ts +0 -412
  548. package/src/services/platformAuthService.ts +0 -1113
  549. package/src/types/ambient.d.ts +0 -29
  550. package/src/types/declarations.d.ts +0 -26
  551. package/src/types/index.d.ts +0 -274
  552. package/src/types/index.ts +0 -244
  553. package/src/types/node-fix.d.ts +0 -19
  554. package/src/types/node-override.d.ts +0 -24
  555. package/src/types/opacity.d.ts +0 -16
  556. package/src/types/types.d.ts +0 -18
  557. package/src/types.ts +0 -298
  558. package/src/utils/Portal.tsx +0 -83
  559. package/src/utils/api.js +0 -112
  560. package/src/utils/auth.js +0 -104
  561. package/src/utils/crypto.js +0 -60
  562. package/src/utils/debugHelper.ts +0 -53
  563. package/src/utils/encryption.ts +0 -69
  564. package/src/utils/onairosApi.ts +0 -391
  565. package/src/utils/programmaticFlow.ts +0 -113
  566. package/src/utils/retryHelper.ts +0 -275
  567. package/src/utils/secureStorage.ts +0 -361
  568. package/types/index.d.ts +0 -218
  569. package/types/node-env.d.ts +0 -15
  570. /package/{src/assets/images → lib/commonjs/assets/icons}/farcaster.png +0 -0
  571. /package/{src/assets/images → lib/commonjs/assets/icons}/instagram.png +0 -0
  572. /package/{src/assets/images → lib/commonjs/assets/icons}/pinterest.png +0 -0
  573. /package/{src/assets/images → lib/commonjs/assets/icons}/swerv_logo.png +0 -0
  574. /package/{src/assets/images → lib/commonjs/assets/icons}/twitter.jpg +0 -0
@@ -1,421 +1,421 @@
1
- # Onairos SDK API Key Validation - Standardized Documentation
2
-
3
- ## Overview
4
-
5
- This document outlines the standardized API key validation system for all Onairos SDKs (React Native, Web, Mobile, etc.). The system provides a unified interface for initializing and validating developer API keys across all platforms.
6
-
7
- ## 🔑 API Key Format
8
-
9
- ### Developer API Keys
10
- - **Format**: Must be at least 32 characters
11
- - **Prefixes**: `dev_`, `pk_`, or `ona_`
12
- - **Example**: `ona_1234567890abcdef1234567890abcdef12345678`
13
-
14
- ### Admin API Keys (Internal Use)
15
- - **Format**: Special admin keys for internal testing
16
- - **Permissions**: Full access (`*`)
17
-
18
- ## 🚀 SDK Initialization Standard
19
-
20
- ### Step 1: Initialize SDK (Required for all SDKs)
21
-
22
- All SDKs should implement an `initializeApiKey` function that validates the API key before allowing SDK usage.
23
-
24
- ```typescript
25
- import { initializeApiKey } from 'onairos';
26
-
27
- // Initialize SDK with developer API key
28
- try {
29
- await initializeApiKey({
30
- apiKey: 'ona_your_api_key_here', // Get from Onairos Dashboard
31
- environment: 'production', // 'production' | 'development'
32
- enableLogging: true,
33
- timeout: 30000,
34
- retryAttempts: 3
35
- });
36
-
37
- console.log('SDK initialized successfully!');
38
- } catch (error) {
39
- console.error('SDK initialization failed:', error.message);
40
- }
41
- ```
42
-
43
- ### Step 2: Use SDK Components
44
-
45
- After successful initialization, all SDK components work automatically:
46
-
47
- ```typescript
48
- import { OnairosButton } from 'onairos';
49
-
50
- // Components automatically handle authentication internally
51
- <OnairosButton
52
- requestData={{
53
- basic: { type: "basic", reward: "10 tokens" },
54
- personality: { type: "personality", reward: "25 tokens" },
55
- preferences: { type: "preferences", reward: "15 tokens" }
56
- }}
57
- webpageName="MyApp"
58
- testMode={false}
59
- autoFetch={true}
60
- onComplete={(result) => console.log(result)}
61
- />
62
- ```
63
-
64
- ## 🌐 API Endpoints
65
-
66
- ### Primary Validation Endpoint
67
-
68
- **POST** `/dev/validate`
69
-
70
- This is the main endpoint that all SDKs should use for API key validation.
71
-
72
- #### Request Headers
73
- ```http
74
- Authorization: Bearer ona_your_api_key_here
75
- Content-Type: application/json
76
- X-SDK-Platform: react-native|web|mobile (optional)
77
- User-Agent: OnairosReactNative/3.1.10 (optional)
78
- ```
79
-
80
- #### Request Body
81
- ```json
82
- {
83
- "environment": "production",
84
- "sdk_version": "3.1.10",
85
- "platform": "react-native",
86
- "keyType": "developer",
87
- "timestamp": "2024-01-01T00:00:00.000Z",
88
- "attempt": 1
89
- }
90
- ```
91
-
92
- #### Success Response (200)
93
- ```json
94
- {
95
- "valid": true,
96
- "apiKey": {
97
- "id": "68f7f1bef71b2523faade626",
98
- "name": "My App Key",
99
- "createdAt": "2025-10-21T20:49:02.205Z",
100
- "lastUsed": "2025-10-24T00:15:54.478Z",
101
- "usageCount": 13
102
- },
103
- "application": {
104
- "name": "My Application",
105
- "theme": "productivity",
106
- "description": "Application description"
107
- }
108
- }
109
- ```
110
-
111
- #### Error Response (401/400/500)
112
- ```json
113
- {
114
- "valid": false,
115
- "error": "Invalid API key format",
116
- "message": "Developer keys must be at least 32 characters and start with 'dev_', 'pk_', or 'ona_'",
117
- "code": "INVALID_API_KEY_FORMAT"
118
- }
119
- ```
120
-
121
- ### Alternative Endpoints
122
-
123
- #### Legacy Endpoints (Deprecated)
124
- - **POST** `/auth/validate-key` - Old validation endpoint (deprecated, use `/dev/validate`)
125
- - **GET** `/auth/validate-key?key=API_KEY` - Old GET validation (deprecated)
126
-
127
- ## 🛡️ Error Handling & Retry Logic
128
-
129
- ### Common Error Codes
130
-
131
- | Code | Description | Action |
132
- |------|-------------|--------|
133
- | `MISSING_API_KEY` | No API key provided | Provide API key in Authorization header |
134
- | `INVALID_API_KEY_FORMAT` | Invalid key format | Check key format (32+ chars, correct prefix) |
135
- | `INVALID_API_KEY` | Key not found/inactive | Verify key exists and is active |
136
- | `API_KEY_EXPIRED` | Key has expired | Renew or generate new API key |
137
- | `DEVELOPER_NOT_FOUND` | Developer account inactive | Contact support |
138
- | `RATE_LIMIT_EXCEEDED` | Too many requests | Wait and retry |
139
- | `INTERNAL_ERROR` | Server error | Retry with exponential backoff |
140
-
141
- ### Retry Strategy
142
-
143
- ```typescript
144
- const validateApiKey = async (apiKey: string, config: Config): Promise<ValidationResult> => {
145
- const maxRetries = config.retryAttempts || 3;
146
-
147
- for (let attempt = 1; attempt <= maxRetries; attempt++) {
148
- try {
149
- const response = await fetch(`${baseUrl}/auth/validate-key`, {
150
- method: 'POST',
151
- headers: {
152
- 'Authorization': `Bearer ${apiKey}`,
153
- 'Content-Type': 'application/json',
154
- 'X-SDK-Platform': config.platform || 'unknown'
155
- },
156
- body: JSON.stringify({
157
- environment: config.environment || 'production',
158
- sdk_version: config.sdkVersion,
159
- platform: config.platform,
160
- timestamp: new Date().toISOString(),
161
- attempt
162
- }),
163
- signal: AbortSignal.timeout(config.timeout || 30000)
164
- });
165
-
166
- if (response.ok) {
167
- return await response.json();
168
- }
169
-
170
- // Don't retry client errors (4xx)
171
- if (response.status >= 400 && response.status < 500) {
172
- throw new Error(`Client error: ${response.status}`);
173
- }
174
-
175
- // Retry server errors (5xx)
176
- if (attempt === maxRetries) {
177
- throw new Error(`Server error after ${maxRetries} attempts`);
178
- }
179
-
180
- } catch (error) {
181
- if (attempt === maxRetries) {
182
- throw error;
183
- }
184
-
185
- // Exponential backoff
186
- const delay = Math.min(1000 * Math.pow(2, attempt - 1), 5000);
187
- await new Promise(resolve => setTimeout(resolve, delay));
188
- }
189
- }
190
- };
191
- ```
192
-
193
- ## 📱 Platform-Specific Implementation
194
-
195
- ### React Native SDK
196
-
197
- ```typescript
198
- export const validateApiKey = async (apiKey: string): Promise<ApiKeyValidationResult> => {
199
- // Check admin keys first
200
- if (isAdminKey(apiKey)) {
201
- return {
202
- isValid: true,
203
- permissions: ['*'],
204
- rateLimits: { remaining: 999999, resetTime: Date.now() + 24*60*60*1000 },
205
- keyType: ApiKeyType.ADMIN
206
- };
207
- }
208
-
209
- // Validate format
210
- const keyType = getApiKeyType(apiKey);
211
- if (keyType === ApiKeyType.INVALID) {
212
- return {
213
- isValid: false,
214
- error: 'Invalid API key format',
215
- keyType: ApiKeyType.INVALID
216
- };
217
- }
218
-
219
- // Make API call
220
- const response = await fetch(`${baseUrl}/dev/validate`, {
221
- method: 'POST',
222
- headers: {
223
- 'Authorization': `Bearer ${apiKey}`,
224
- 'Content-Type': 'application/json',
225
- 'User-Agent': 'OnairosReactNative/3.3.1',
226
- 'X-API-Key-Type': keyType,
227
- 'X-SDK-Platform': 'react-native'
228
- },
229
- body: JSON.stringify({
230
- environment: globalConfig?.environment || 'production',
231
- sdk_version: '3.3.1',
232
- platform: 'react-native',
233
- keyType,
234
- timestamp: new Date().toISOString()
235
- })
236
- });
237
-
238
- const data = await response.json();
239
-
240
- if (data.valid || data.success) {
241
- return {
242
- isValid: true,
243
- permissions: data.permissions || [],
244
- rateLimits: data.rateLimits || null,
245
- keyType: keyType
246
- };
247
- } else {
248
- return {
249
- isValid: false,
250
- error: data.error || data.message,
251
- keyType: keyType
252
- };
253
- }
254
- };
255
- ```
256
-
257
- ### Web SDK
258
-
259
- ```typescript
260
- class OnairosSDK {
261
- private apiKey: string | null = null;
262
- private isInitialized: boolean = false;
263
-
264
- async initialize(config: InitConfig): Promise<void> {
265
- const validation = await this.validateApiKey(config.apiKey);
266
-
267
- if (!validation.isValid) {
268
- throw new Error(`SDK initialization failed: ${validation.error}`);
269
- }
270
-
271
- this.apiKey = config.apiKey;
272
- this.isInitialized = true;
273
-
274
- console.log('Onairos SDK initialized successfully');
275
- }
276
-
277
- private async validateApiKey(apiKey: string): Promise<ValidationResult> {
278
- // Similar implementation to React Native
279
- // ...
280
- }
281
- }
282
- ```
283
-
284
- ## 🔧 Configuration Options
285
-
286
- ### InitConfig Interface
287
-
288
- ```typescript
289
- interface InitConfig {
290
- apiKey: string; // Required: Developer API key
291
- environment?: 'production' | 'development'; // Default: 'production'
292
- enableLogging?: boolean; // Default: false
293
- timeout?: number; // Default: 30000ms
294
- retryAttempts?: number; // Default: 3
295
- baseUrl?: string; // Default: auto-detected
296
- }
297
- ```
298
-
299
- ### ValidationResult Interface
300
-
301
- ```typescript
302
- interface ValidationResult {
303
- isValid: boolean;
304
- permissions?: string[];
305
- rateLimits?: {
306
- remaining: number;
307
- resetTime: number;
308
- };
309
- keyType: 'admin' | 'developer' | 'invalid';
310
- error?: string;
311
- }
312
- ```
313
-
314
- ## 🌍 Environment Configuration
315
-
316
- ### Base URLs
317
-
318
- ```typescript
319
- const API_ENDPOINTS = {
320
- production: 'https://api2.onairos.uk',
321
- development: 'https://dev-api2.onairos.uk'
322
- };
323
- ```
324
-
325
- ### Environment Detection
326
-
327
- ```typescript
328
- const detectEnvironment = (): 'production' | 'development' => {
329
- if (typeof window !== 'undefined') {
330
- // Browser environment
331
- return window.location.hostname.includes('localhost') ? 'development' : 'production';
332
- } else {
333
- // Node.js/React Native environment
334
- return process.env.NODE_ENV === 'development' ? 'development' : 'production';
335
- }
336
- };
337
- ```
338
-
339
- ## 🚀 Quick Start Examples
340
-
341
- ### React Native
342
-
343
- ```typescript
344
- import { initializeApiKey, OnairosButton } from 'onairos-react-native';
345
-
346
- // 1. Initialize SDK
347
- await initializeApiKey({
348
- apiKey: 'ona_your_key_here',
349
- environment: 'production'
350
- });
351
-
352
- // 2. Use components
353
- <OnairosButton requestData={{...}} onComplete={handleResult} />
354
- ```
355
-
356
- ### Web/JavaScript
357
-
358
- ```typescript
359
- import { OnairosSDK } from 'onairos-web';
360
-
361
- // 1. Initialize SDK
362
- const sdk = new OnairosSDK();
363
- await sdk.initialize({
364
- apiKey: 'ona_your_key_here',
365
- environment: 'production'
366
- });
367
-
368
- // 2. Use SDK methods
369
- const result = await sdk.collectData({...});
370
- ```
371
-
372
- ### Node.js Backend
373
-
374
- ```typescript
375
- import { OnairosAPI } from 'onairos-node';
376
-
377
- // 1. Initialize API client
378
- const api = new OnairosAPI({
379
- apiKey: 'ona_your_key_here',
380
- environment: 'production'
381
- });
382
-
383
- // 2. Make API calls
384
- const validation = await api.validateKey();
385
- ```
386
-
387
- ## 🔍 Testing & Debugging
388
-
389
- ### Test API Key Validation
390
-
391
- ```bash
392
- # Test with curl
393
- curl -X POST https://api2.onairos.uk/dev/validate \
394
- -H "Authorization: Bearer ona_your_key_here" \
395
- -H "Content-Type: application/json" \
396
- -d '{
397
- "environment": "production",
398
- "platform": "test"
399
- }'
400
- ```
401
-
402
- ### Debug Mode
403
-
404
- Enable logging in SDK initialization:
405
-
406
- ```typescript
407
- await initializeApiKey({
408
- apiKey: 'ona_your_key_here',
409
- enableLogging: true // Shows detailed logs
410
- });
411
- ```
412
-
413
- ## 📞 Support
414
-
415
- - **Documentation**: https://docs.onairos.uk
416
- - **Dashboard**: https://dashboard.onairos.uk
417
- - **Support**: support@onairos.uk
418
-
419
- ---
420
-
421
- *Last updated: October 2024*
1
+ # Onairos SDK API Key Validation - Standardized Documentation
2
+
3
+ ## Overview
4
+
5
+ This document outlines the standardized API key validation system for all Onairos SDKs (React Native, Web, Mobile, etc.). The system provides a unified interface for initializing and validating developer API keys across all platforms.
6
+
7
+ ## 🔑 API Key Format
8
+
9
+ ### Developer API Keys
10
+ - **Format**: Must be at least 32 characters
11
+ - **Prefixes**: `dev_`, `pk_`, or `ona_`
12
+ - **Example**: `ona_1234567890abcdef1234567890abcdef12345678`
13
+
14
+ ### Admin API Keys (Internal Use)
15
+ - **Format**: Special admin keys for internal testing
16
+ - **Permissions**: Full access (`*`)
17
+
18
+ ## 🚀 SDK Initialization Standard
19
+
20
+ ### Step 1: Initialize SDK (Required for all SDKs)
21
+
22
+ All SDKs should implement an `initializeApiKey` function that validates the API key before allowing SDK usage.
23
+
24
+ ```typescript
25
+ import { initializeApiKey } from 'onairos';
26
+
27
+ // Initialize SDK with developer API key
28
+ try {
29
+ await initializeApiKey({
30
+ apiKey: 'ona_your_api_key_here', // Get from Onairos Dashboard
31
+ environment: 'production', // 'production' | 'development'
32
+ enableLogging: true,
33
+ timeout: 30000,
34
+ retryAttempts: 3
35
+ });
36
+
37
+ console.log('SDK initialized successfully!');
38
+ } catch (error) {
39
+ console.error('SDK initialization failed:', error.message);
40
+ }
41
+ ```
42
+
43
+ ### Step 2: Use SDK Components
44
+
45
+ After successful initialization, all SDK components work automatically:
46
+
47
+ ```typescript
48
+ import { OnairosButton } from 'onairos';
49
+
50
+ // Components automatically handle authentication internally
51
+ <OnairosButton
52
+ requestData={{
53
+ basic: { type: "basic", reward: "10 tokens" },
54
+ personality: { type: "personality", reward: "25 tokens" },
55
+ preferences: { type: "preferences", reward: "15 tokens" }
56
+ }}
57
+ webpageName="MyApp"
58
+ testMode={false}
59
+ autoFetch={true}
60
+ onComplete={(result) => console.log(result)}
61
+ />
62
+ ```
63
+
64
+ ## 🌐 API Endpoints
65
+
66
+ ### Primary Validation Endpoint
67
+
68
+ **POST** `/dev/validate`
69
+
70
+ This is the main endpoint that all SDKs should use for API key validation.
71
+
72
+ #### Request Headers
73
+ ```http
74
+ Authorization: Bearer ona_your_api_key_here
75
+ Content-Type: application/json
76
+ X-SDK-Platform: react-native|web|mobile (optional)
77
+ User-Agent: OnairosReactNative/3.1.10 (optional)
78
+ ```
79
+
80
+ #### Request Body
81
+ ```json
82
+ {
83
+ "environment": "production",
84
+ "sdk_version": "3.1.10",
85
+ "platform": "react-native",
86
+ "keyType": "developer",
87
+ "timestamp": "2024-01-01T00:00:00.000Z",
88
+ "attempt": 1
89
+ }
90
+ ```
91
+
92
+ #### Success Response (200)
93
+ ```json
94
+ {
95
+ "valid": true,
96
+ "apiKey": {
97
+ "id": "68f7f1bef71b2523faade626",
98
+ "name": "My App Key",
99
+ "createdAt": "2025-10-21T20:49:02.205Z",
100
+ "lastUsed": "2025-10-24T00:15:54.478Z",
101
+ "usageCount": 13
102
+ },
103
+ "application": {
104
+ "name": "My Application",
105
+ "theme": "productivity",
106
+ "description": "Application description"
107
+ }
108
+ }
109
+ ```
110
+
111
+ #### Error Response (401/400/500)
112
+ ```json
113
+ {
114
+ "valid": false,
115
+ "error": "Invalid API key format",
116
+ "message": "Developer keys must be at least 32 characters and start with 'dev_', 'pk_', or 'ona_'",
117
+ "code": "INVALID_API_KEY_FORMAT"
118
+ }
119
+ ```
120
+
121
+ ### Alternative Endpoints
122
+
123
+ #### Legacy Endpoints (Deprecated)
124
+ - **POST** `/auth/validate-key` - Old validation endpoint (deprecated, use `/dev/validate`)
125
+ - **GET** `/auth/validate-key?key=API_KEY` - Old GET validation (deprecated)
126
+
127
+ ## 🛡️ Error Handling & Retry Logic
128
+
129
+ ### Common Error Codes
130
+
131
+ | Code | Description | Action |
132
+ |------|-------------|--------|
133
+ | `MISSING_API_KEY` | No API key provided | Provide API key in Authorization header |
134
+ | `INVALID_API_KEY_FORMAT` | Invalid key format | Check key format (32+ chars, correct prefix) |
135
+ | `INVALID_API_KEY` | Key not found/inactive | Verify key exists and is active |
136
+ | `API_KEY_EXPIRED` | Key has expired | Renew or generate new API key |
137
+ | `DEVELOPER_NOT_FOUND` | Developer account inactive | Contact support |
138
+ | `RATE_LIMIT_EXCEEDED` | Too many requests | Wait and retry |
139
+ | `INTERNAL_ERROR` | Server error | Retry with exponential backoff |
140
+
141
+ ### Retry Strategy
142
+
143
+ ```typescript
144
+ const validateApiKey = async (apiKey: string, config: Config): Promise<ValidationResult> => {
145
+ const maxRetries = config.retryAttempts || 3;
146
+
147
+ for (let attempt = 1; attempt <= maxRetries; attempt++) {
148
+ try {
149
+ const response = await fetch(`${baseUrl}/auth/validate-key`, {
150
+ method: 'POST',
151
+ headers: {
152
+ 'Authorization': `Bearer ${apiKey}`,
153
+ 'Content-Type': 'application/json',
154
+ 'X-SDK-Platform': config.platform || 'unknown'
155
+ },
156
+ body: JSON.stringify({
157
+ environment: config.environment || 'production',
158
+ sdk_version: config.sdkVersion,
159
+ platform: config.platform,
160
+ timestamp: new Date().toISOString(),
161
+ attempt
162
+ }),
163
+ signal: AbortSignal.timeout(config.timeout || 30000)
164
+ });
165
+
166
+ if (response.ok) {
167
+ return await response.json();
168
+ }
169
+
170
+ // Don't retry client errors (4xx)
171
+ if (response.status >= 400 && response.status < 500) {
172
+ throw new Error(`Client error: ${response.status}`);
173
+ }
174
+
175
+ // Retry server errors (5xx)
176
+ if (attempt === maxRetries) {
177
+ throw new Error(`Server error after ${maxRetries} attempts`);
178
+ }
179
+
180
+ } catch (error) {
181
+ if (attempt === maxRetries) {
182
+ throw error;
183
+ }
184
+
185
+ // Exponential backoff
186
+ const delay = Math.min(1000 * Math.pow(2, attempt - 1), 5000);
187
+ await new Promise(resolve => setTimeout(resolve, delay));
188
+ }
189
+ }
190
+ };
191
+ ```
192
+
193
+ ## 📱 Platform-Specific Implementation
194
+
195
+ ### React Native SDK
196
+
197
+ ```typescript
198
+ export const validateApiKey = async (apiKey: string): Promise<ApiKeyValidationResult> => {
199
+ // Check admin keys first
200
+ if (isAdminKey(apiKey)) {
201
+ return {
202
+ isValid: true,
203
+ permissions: ['*'],
204
+ rateLimits: { remaining: 999999, resetTime: Date.now() + 24*60*60*1000 },
205
+ keyType: ApiKeyType.ADMIN
206
+ };
207
+ }
208
+
209
+ // Validate format
210
+ const keyType = getApiKeyType(apiKey);
211
+ if (keyType === ApiKeyType.INVALID) {
212
+ return {
213
+ isValid: false,
214
+ error: 'Invalid API key format',
215
+ keyType: ApiKeyType.INVALID
216
+ };
217
+ }
218
+
219
+ // Make API call
220
+ const response = await fetch(`${baseUrl}/dev/validate`, {
221
+ method: 'POST',
222
+ headers: {
223
+ 'Authorization': `Bearer ${apiKey}`,
224
+ 'Content-Type': 'application/json',
225
+ 'User-Agent': 'OnairosReactNative/3.3.1',
226
+ 'X-API-Key-Type': keyType,
227
+ 'X-SDK-Platform': 'react-native'
228
+ },
229
+ body: JSON.stringify({
230
+ environment: globalConfig?.environment || 'production',
231
+ sdk_version: '3.3.1',
232
+ platform: 'react-native',
233
+ keyType,
234
+ timestamp: new Date().toISOString()
235
+ })
236
+ });
237
+
238
+ const data = await response.json();
239
+
240
+ if (data.valid || data.success) {
241
+ return {
242
+ isValid: true,
243
+ permissions: data.permissions || [],
244
+ rateLimits: data.rateLimits || null,
245
+ keyType: keyType
246
+ };
247
+ } else {
248
+ return {
249
+ isValid: false,
250
+ error: data.error || data.message,
251
+ keyType: keyType
252
+ };
253
+ }
254
+ };
255
+ ```
256
+
257
+ ### Web SDK
258
+
259
+ ```typescript
260
+ class OnairosSDK {
261
+ private apiKey: string | null = null;
262
+ private isInitialized: boolean = false;
263
+
264
+ async initialize(config: InitConfig): Promise<void> {
265
+ const validation = await this.validateApiKey(config.apiKey);
266
+
267
+ if (!validation.isValid) {
268
+ throw new Error(`SDK initialization failed: ${validation.error}`);
269
+ }
270
+
271
+ this.apiKey = config.apiKey;
272
+ this.isInitialized = true;
273
+
274
+ console.log('Onairos SDK initialized successfully');
275
+ }
276
+
277
+ private async validateApiKey(apiKey: string): Promise<ValidationResult> {
278
+ // Similar implementation to React Native
279
+ // ...
280
+ }
281
+ }
282
+ ```
283
+
284
+ ## 🔧 Configuration Options
285
+
286
+ ### InitConfig Interface
287
+
288
+ ```typescript
289
+ interface InitConfig {
290
+ apiKey: string; // Required: Developer API key
291
+ environment?: 'production' | 'development'; // Default: 'production'
292
+ enableLogging?: boolean; // Default: false
293
+ timeout?: number; // Default: 30000ms
294
+ retryAttempts?: number; // Default: 3
295
+ baseUrl?: string; // Default: auto-detected
296
+ }
297
+ ```
298
+
299
+ ### ValidationResult Interface
300
+
301
+ ```typescript
302
+ interface ValidationResult {
303
+ isValid: boolean;
304
+ permissions?: string[];
305
+ rateLimits?: {
306
+ remaining: number;
307
+ resetTime: number;
308
+ };
309
+ keyType: 'admin' | 'developer' | 'invalid';
310
+ error?: string;
311
+ }
312
+ ```
313
+
314
+ ## 🌍 Environment Configuration
315
+
316
+ ### Base URLs
317
+
318
+ ```typescript
319
+ const API_ENDPOINTS = {
320
+ production: 'https://api2.onairos.uk',
321
+ development: 'https://dev-api2.onairos.uk'
322
+ };
323
+ ```
324
+
325
+ ### Environment Detection
326
+
327
+ ```typescript
328
+ const detectEnvironment = (): 'production' | 'development' => {
329
+ if (typeof window !== 'undefined') {
330
+ // Browser environment
331
+ return window.location.hostname.includes('localhost') ? 'development' : 'production';
332
+ } else {
333
+ // Node.js/React Native environment
334
+ return process.env.NODE_ENV === 'development' ? 'development' : 'production';
335
+ }
336
+ };
337
+ ```
338
+
339
+ ## 🚀 Quick Start Examples
340
+
341
+ ### React Native
342
+
343
+ ```typescript
344
+ import { initializeApiKey, OnairosButton } from 'onairos-react-native';
345
+
346
+ // 1. Initialize SDK
347
+ await initializeApiKey({
348
+ apiKey: 'ona_your_key_here',
349
+ environment: 'production'
350
+ });
351
+
352
+ // 2. Use components
353
+ <OnairosButton requestData={{...}} onComplete={handleResult} />
354
+ ```
355
+
356
+ ### Web/JavaScript
357
+
358
+ ```typescript
359
+ import { OnairosSDK } from 'onairos-web';
360
+
361
+ // 1. Initialize SDK
362
+ const sdk = new OnairosSDK();
363
+ await sdk.initialize({
364
+ apiKey: 'ona_your_key_here',
365
+ environment: 'production'
366
+ });
367
+
368
+ // 2. Use SDK methods
369
+ const result = await sdk.collectData({...});
370
+ ```
371
+
372
+ ### Node.js Backend
373
+
374
+ ```typescript
375
+ import { OnairosAPI } from 'onairos-node';
376
+
377
+ // 1. Initialize API client
378
+ const api = new OnairosAPI({
379
+ apiKey: 'ona_your_key_here',
380
+ environment: 'production'
381
+ });
382
+
383
+ // 2. Make API calls
384
+ const validation = await api.validateKey();
385
+ ```
386
+
387
+ ## 🔍 Testing & Debugging
388
+
389
+ ### Test API Key Validation
390
+
391
+ ```bash
392
+ # Test with curl
393
+ curl -X POST https://api2.onairos.uk/dev/validate \
394
+ -H "Authorization: Bearer ona_your_key_here" \
395
+ -H "Content-Type: application/json" \
396
+ -d '{
397
+ "environment": "production",
398
+ "platform": "test"
399
+ }'
400
+ ```
401
+
402
+ ### Debug Mode
403
+
404
+ Enable logging in SDK initialization:
405
+
406
+ ```typescript
407
+ await initializeApiKey({
408
+ apiKey: 'ona_your_key_here',
409
+ enableLogging: true // Shows detailed logs
410
+ });
411
+ ```
412
+
413
+ ## 📞 Support
414
+
415
+ - **Documentation**: https://docs.onairos.uk
416
+ - **Dashboard**: https://dashboard.onairos.uk
417
+ - **Support**: support@onairos.uk
418
+
419
+ ---
420
+
421
+ *Last updated: October 2024*