@onairos/react-native 3.1.15 → 3.1.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +404 -0
- package/lib/commonjs/assets/images/Checkbox.svg +3 -3
- package/lib/commonjs/assets/images/EnochE.svg +19 -19
- package/lib/commonjs/assets/images/Personalityprofile.svg +3 -3
- package/lib/commonjs/assets/images/Personalitytraits.svg +3 -3
- package/lib/commonjs/assets/images/Userpreferences.svg +3 -3
- package/lib/commonjs/assets/images/arrow.svg +20 -20
- package/lib/commonjs/assets/images/basicproficon.svg +43 -43
- package/lib/commonjs/assets/images/basicprofile.svg +3 -3
- package/lib/commonjs/assets/images/checkmark.svg +4 -4
- package/lib/commonjs/assets/images/contentanalysis.svg +3 -3
- package/lib/commonjs/assets/images/contenticon.svg +23 -23
- package/lib/commonjs/assets/images/personalityicon.svg +18 -18
- package/lib/commonjs/assets/images/x-close.svg +3 -3
- package/lib/commonjs/components/OnairosSignInButton.js +32 -74
- package/lib/commonjs/components/OnairosSignInButton.js.map +1 -1
- package/lib/commonjs/components/UniversalOnboarding.js +4 -4
- package/lib/commonjs/config/api.js +2 -2
- package/lib/commonjs/hooks/useConnections.js +6 -6
- package/lib/commonjs/hooks/useUserConnections.js +10 -10
- package/lib/commonjs/index.js +5 -12
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/services/apiClient.js +35 -35
- package/lib/commonjs/services/apiKeyService.js +99 -99
- package/lib/commonjs/services/authService.js +82 -82
- package/lib/commonjs/services/biometricPinService.js +10 -10
- package/lib/commonjs/services/connectedAccountsService.js +32 -32
- package/lib/commonjs/services/googleAuthService.js +15 -15
- package/lib/commonjs/services/imageCompressionService.js +15 -15
- package/lib/commonjs/services/jwtStorageService.js +59 -59
- package/lib/commonjs/services/mobileTrainingService.js +14 -14
- package/lib/commonjs/services/pinEncryptionService.js +10 -10
- package/lib/commonjs/services/pinStorageUtils.js +15 -15
- package/lib/commonjs/services/platformAuthService.js +47 -47
- package/lib/commonjs/services/storageService.js +31 -31
- package/lib/commonjs/services/trainingApiHelpers.js +33 -33
- package/lib/commonjs/services/userConnectionsService.js +24 -24
- package/lib/commonjs/utils/Portal.js +4 -4
- package/lib/commonjs/utils/api.js +24 -24
- package/lib/commonjs/utils/auth.js +18 -18
- package/lib/commonjs/utils/crypto.js +13 -13
- package/lib/commonjs/utils/encryption.js +12 -12
- package/lib/commonjs/utils/eventUtils.js +52 -52
- package/lib/commonjs/utils/programmaticFlow.js +16 -16
- package/lib/commonjs/utils/retryHelper.js +27 -27
- package/lib/module/assets/images/Checkbox.svg +3 -3
- package/lib/module/assets/images/EnochE.svg +19 -19
- package/lib/module/assets/images/Personalityprofile.svg +3 -3
- package/lib/module/assets/images/Personalitytraits.svg +3 -3
- package/lib/module/assets/images/Userpreferences.svg +3 -3
- package/lib/module/assets/images/arrow.svg +20 -20
- package/lib/module/assets/images/basicproficon.svg +43 -43
- package/lib/module/assets/images/basicprofile.svg +3 -3
- package/lib/module/assets/images/checkmark.svg +4 -4
- package/lib/module/assets/images/contentanalysis.svg +3 -3
- package/lib/module/assets/images/contenticon.svg +23 -23
- package/lib/module/assets/images/personalityicon.svg +18 -18
- package/lib/module/assets/images/x-close.svg +3 -3
- package/lib/module/components/OnairosSignInButton.js +32 -74
- package/lib/module/components/OnairosSignInButton.js.map +1 -1
- package/lib/module/components/UniversalOnboarding.js +4 -4
- package/lib/module/config/api.js +2 -2
- package/lib/module/hooks/useConnections.js +6 -6
- package/lib/module/hooks/useUserConnections.js +10 -10
- package/lib/module/index.js +5 -6
- package/lib/module/index.js.map +1 -1
- package/lib/module/services/apiClient.js +35 -35
- package/lib/module/services/apiKeyService.js +99 -99
- package/lib/module/services/authService.js +82 -82
- package/lib/module/services/biometricPinService.js +10 -10
- package/lib/module/services/connectedAccountsService.js +32 -32
- package/lib/module/services/googleAuthService.js +15 -15
- package/lib/module/services/imageCompressionService.js +15 -15
- package/lib/module/services/jwtStorageService.js +59 -59
- package/lib/module/services/mobileTrainingService.js +14 -14
- package/lib/module/services/pinEncryptionService.js +10 -10
- package/lib/module/services/pinStorageUtils.js +15 -15
- package/lib/module/services/platformAuthService.js +47 -47
- package/lib/module/services/storageService.js +31 -31
- package/lib/module/services/trainingApiHelpers.js +33 -33
- package/lib/module/services/userConnectionsService.js +24 -24
- package/lib/module/utils/Portal.js +4 -4
- package/lib/module/utils/api.js +24 -24
- package/lib/module/utils/auth.js +18 -18
- package/lib/module/utils/crypto.js +13 -13
- package/lib/module/utils/encryption.js +12 -12
- package/lib/module/utils/eventUtils.js +52 -52
- package/lib/module/utils/programmaticFlow.js +16 -16
- package/lib/module/utils/retryHelper.js +27 -27
- package/lib/typescript/components/OnairosSignInButton.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +0 -1
- package/lib/typescript/index.d.ts.map +1 -1
- package/package.json +163 -163
- package/src/api/index.ts +151 -151
- package/src/assets/images/Checkbox.svg +3 -3
- package/src/assets/images/EnochE.svg +19 -19
- package/src/assets/images/Personalityprofile.svg +3 -3
- package/src/assets/images/Personalitytraits.svg +3 -3
- package/src/assets/images/Userpreferences.svg +3 -3
- package/src/assets/images/arrow.svg +20 -20
- package/src/assets/images/basicproficon.svg +43 -43
- package/src/assets/images/basicprofile.svg +3 -3
- package/src/assets/images/checkmark.svg +4 -4
- package/src/assets/images/contentanalysis.svg +3 -3
- package/src/assets/images/contenticon.svg +23 -23
- package/src/assets/images/personalityicon.svg +18 -18
- package/src/assets/images/x-close.svg +3 -3
- package/src/components/BodyText.tsx +33 -33
- package/src/components/BrandMark.tsx +62 -62
- package/src/components/CodeInput.tsx +32 -32
- package/src/components/DataRequestScreen.tsx +355 -355
- package/src/components/EmailInput.tsx +31 -31
- package/src/components/EmailVerificationModal.tsx +363 -363
- package/src/components/ExistingUserDataConfirmation.tsx +506 -506
- package/src/components/GoogleButton.tsx +55 -55
- package/src/components/HeadingGroup.tsx +49 -49
- package/src/components/ModalHeader.tsx +125 -125
- package/src/components/ModalSheet.tsx +57 -57
- package/src/components/Onairos.tsx +422 -422
- package/src/components/OnairosButton.tsx +339 -339
- package/src/components/OnairosSignInButton.tsx +130 -166
- package/src/components/Overlay.tsx +506 -506
- package/src/components/PersonaImage.tsx +79 -79
- package/src/components/PersonaLoadingScreen.tsx +201 -201
- package/src/components/PersonalizationConsentScreen.tsx +410 -410
- package/src/components/PinCreationScreen.tsx +492 -492
- package/src/components/PinInput.tsx +555 -555
- package/src/components/PlatformConnectorsStep.tsx +891 -891
- package/src/components/PlatformList.tsx +144 -144
- package/src/components/PlatformToggle.tsx +226 -226
- package/src/components/PrimaryButton.tsx +213 -213
- package/src/components/SignInMatchAnimation.tsx +225 -225
- package/src/components/SignInStep.tsx +217 -217
- package/src/components/TrainingModal.tsx +1047 -1047
- package/src/components/UniversalOnboarding.tsx +2887 -2887
- package/src/components/VerificationStep.tsx +198 -198
- package/src/components/WelcomeScreen.tsx +473 -473
- package/src/components/icons/Basicproficon.tsx +30 -30
- package/src/components/icons/Basicprofile.tsx +17 -17
- package/src/components/icons/Checkbox.tsx +17 -17
- package/src/components/icons/Checkmark.tsx +24 -24
- package/src/components/icons/Contentanalysis.tsx +17 -17
- package/src/components/icons/Contenticon.tsx +30 -30
- package/src/components/icons/EnochE.tsx +39 -39
- package/src/components/icons/Personalityicon.tsx +22 -22
- package/src/components/icons/Personalityprofile.tsx +17 -17
- package/src/components/icons/Personalitytraits.tsx +17 -17
- package/src/components/icons/Userpreferences.tsx +17 -17
- package/src/components/icons/index.ts +12 -12
- package/src/components/onboarding/OAuthWebView.tsx +232 -232
- package/src/config/api.ts +25 -25
- package/src/context/AuthContext.tsx +393 -393
- package/src/hooks/useConnectedAccounts.ts +138 -138
- package/src/hooks/useConnections.ts +161 -161
- package/src/hooks/useCredentials.ts +174 -174
- package/src/hooks/useUserConnections.ts +165 -165
- package/src/index.js +14 -14
- package/src/index.ts +94 -95
- package/src/services/apiClient.ts +336 -336
- package/src/services/apiKeyService.ts +919 -919
- package/src/services/authService.ts +1008 -1008
- package/src/services/biometricPinService.ts +192 -192
- package/src/services/connectedAccountsService.ts +289 -289
- package/src/services/googleAuthService.ts +279 -279
- package/src/services/imageCompressionService.ts +302 -302
- package/src/services/jwtStorageService.ts +256 -256
- package/src/services/mobileTrainingService.ts +203 -203
- package/src/services/pinEncryptionService.ts +75 -75
- package/src/services/pinStorageUtils.ts +96 -96
- package/src/services/platformAuthService.ts +1346 -1346
- package/src/services/storageService.ts +451 -451
- package/src/services/trainingApiHelpers.ts +66 -66
- package/src/services/userConnectionsService.ts +556 -556
- package/src/services/youtubeMigrationService.ts +453 -453
- package/src/theme/index.ts +239 -239
- package/src/types/ambient.d.ts +28 -28
- package/src/types/index.ts +265 -265
- package/src/types/node-fix.d.ts +18 -18
- package/src/types/node-override.d.ts +23 -23
- package/src/types/opacity.d.ts +15 -15
- package/src/types/types.d.ts +17 -17
- package/src/utils/Portal.tsx +82 -82
- package/src/utils/api.js +111 -111
- package/src/utils/auth.js +103 -103
- package/src/utils/crypto.js +59 -59
- package/src/utils/encryption.ts +68 -68
- package/src/utils/eventUtils.ts +302 -302
- package/src/utils/haptics.ts +58 -58
- package/src/utils/imagePreloader.ts +2 -2
- package/src/utils/programmaticFlow.ts +112 -112
- package/src/utils/retryHelper.ts +274 -274
|
@@ -14,23 +14,23 @@ export let ApiKeyType = /*#__PURE__*/function (ApiKeyType) {
|
|
|
14
14
|
// JWT token storage key
|
|
15
15
|
const JWT_TOKEN_KEY = 'onairos_jwt_token';
|
|
16
16
|
|
|
17
|
-
/**
|
|
18
|
-
* Two-Tier Authentication Service for Onairos React Native SDK
|
|
19
|
-
*
|
|
20
|
-
* This service implements the two-tier authentication system:
|
|
21
|
-
* 1. Developer API Keys: For app-level operations (email verification, app registration)
|
|
22
|
-
* 2. JWT User Tokens: For user-level operations (PIN storage, user profile)
|
|
23
|
-
*
|
|
24
|
-
* How it works:
|
|
25
|
-
* 1. Initialize with developer API key
|
|
26
|
-
* 2. Use API key for email verification requests
|
|
27
|
-
* 3. Store JWT token from email verification response
|
|
28
|
-
* 4. Use JWT token for user-authenticated requests
|
|
29
|
-
* 5. Handle token expiration gracefully
|
|
30
|
-
*
|
|
31
|
-
* Backend Integration:
|
|
32
|
-
* - Developer routes: Authorization: Bearer ${API_KEY}
|
|
33
|
-
* - User routes: Authorization: Bearer ${JWT_TOKEN}
|
|
17
|
+
/**
|
|
18
|
+
* Two-Tier Authentication Service for Onairos React Native SDK
|
|
19
|
+
*
|
|
20
|
+
* This service implements the two-tier authentication system:
|
|
21
|
+
* 1. Developer API Keys: For app-level operations (email verification, app registration)
|
|
22
|
+
* 2. JWT User Tokens: For user-level operations (PIN storage, user profile)
|
|
23
|
+
*
|
|
24
|
+
* How it works:
|
|
25
|
+
* 1. Initialize with developer API key
|
|
26
|
+
* 2. Use API key for email verification requests
|
|
27
|
+
* 3. Store JWT token from email verification response
|
|
28
|
+
* 4. Use JWT token for user-authenticated requests
|
|
29
|
+
* 5. Handle token expiration gracefully
|
|
30
|
+
*
|
|
31
|
+
* Backend Integration:
|
|
32
|
+
* - Developer routes: Authorization: Bearer ${API_KEY}
|
|
33
|
+
* - User routes: Authorization: Bearer ${JWT_TOKEN}
|
|
34
34
|
*/
|
|
35
35
|
|
|
36
36
|
// Global configuration state
|
|
@@ -49,9 +49,9 @@ const API_ENDPOINTS = {
|
|
|
49
49
|
development: 'https://dev-api.onairos.uk'
|
|
50
50
|
};
|
|
51
51
|
|
|
52
|
-
/**
|
|
53
|
-
* Initialize the SDK with developer API key
|
|
54
|
-
* @param config API configuration including developer API key
|
|
52
|
+
/**
|
|
53
|
+
* Initialize the SDK with developer API key
|
|
54
|
+
* @param config API configuration including developer API key
|
|
55
55
|
*/
|
|
56
56
|
export const initializeApiKey = async config => {
|
|
57
57
|
try {
|
|
@@ -124,10 +124,10 @@ export const initializeApiKey = async config => {
|
|
|
124
124
|
}
|
|
125
125
|
};
|
|
126
126
|
|
|
127
|
-
/**
|
|
128
|
-
* Determine API key type
|
|
129
|
-
* @param apiKey The API key to check
|
|
130
|
-
* @returns The type of API key
|
|
127
|
+
/**
|
|
128
|
+
* Determine API key type
|
|
129
|
+
* @param apiKey The API key to check
|
|
130
|
+
* @returns The type of API key
|
|
131
131
|
*/
|
|
132
132
|
export const getApiKeyType = apiKey => {
|
|
133
133
|
if (apiKey === ADMIN_API_KEY) {
|
|
@@ -141,19 +141,19 @@ export const getApiKeyType = apiKey => {
|
|
|
141
141
|
return ApiKeyType.INVALID;
|
|
142
142
|
};
|
|
143
143
|
|
|
144
|
-
/**
|
|
145
|
-
* Check if API key is admin key
|
|
146
|
-
* @param apiKey The API key to check
|
|
147
|
-
* @returns True if admin key
|
|
144
|
+
/**
|
|
145
|
+
* Check if API key is admin key
|
|
146
|
+
* @param apiKey The API key to check
|
|
147
|
+
* @returns True if admin key
|
|
148
148
|
*/
|
|
149
149
|
export const isAdminKey = apiKey => {
|
|
150
150
|
return apiKey === ADMIN_API_KEY;
|
|
151
151
|
};
|
|
152
152
|
|
|
153
|
-
/**
|
|
154
|
-
* Validate an API key with the Onairos backend
|
|
155
|
-
* @param apiKey The API key to validate
|
|
156
|
-
* @returns Validation result with permissions and rate limits
|
|
153
|
+
/**
|
|
154
|
+
* Validate an API key with the Onairos backend
|
|
155
|
+
* @param apiKey The API key to validate
|
|
156
|
+
* @returns Validation result with permissions and rate limits
|
|
157
157
|
*/
|
|
158
158
|
export const validateApiKey = async apiKey => {
|
|
159
159
|
try {
|
|
@@ -389,34 +389,34 @@ export const validateApiKey = async apiKey => {
|
|
|
389
389
|
}
|
|
390
390
|
};
|
|
391
391
|
|
|
392
|
-
/**
|
|
393
|
-
* Get the current API configuration
|
|
394
|
-
* @returns Current API configuration or null if not initialized
|
|
392
|
+
/**
|
|
393
|
+
* Get the current API configuration
|
|
394
|
+
* @returns Current API configuration or null if not initialized
|
|
395
395
|
*/
|
|
396
396
|
export const getApiConfig = () => {
|
|
397
397
|
return globalConfig;
|
|
398
398
|
};
|
|
399
399
|
|
|
400
|
-
/**
|
|
401
|
-
* Get the current API key
|
|
402
|
-
* @returns Current API key or null if not initialized
|
|
400
|
+
/**
|
|
401
|
+
* Get the current API key
|
|
402
|
+
* @returns Current API key or null if not initialized
|
|
403
403
|
*/
|
|
404
404
|
export const getApiKey = () => {
|
|
405
405
|
var _globalConfig9;
|
|
406
406
|
return ((_globalConfig9 = globalConfig) === null || _globalConfig9 === void 0 ? void 0 : _globalConfig9.apiKey) || null;
|
|
407
407
|
};
|
|
408
408
|
|
|
409
|
-
/**
|
|
410
|
-
* Check if the SDK is properly initialized
|
|
411
|
-
* @returns True if initialized with valid API key
|
|
409
|
+
/**
|
|
410
|
+
* Check if the SDK is properly initialized
|
|
411
|
+
* @returns True if initialized with valid API key
|
|
412
412
|
*/
|
|
413
413
|
export const isApiKeyInitialized = () => {
|
|
414
414
|
return isInitialized && globalConfig !== null;
|
|
415
415
|
};
|
|
416
416
|
|
|
417
|
-
/**
|
|
418
|
-
* Store JWT token securely after email verification
|
|
419
|
-
* @param token JWT token from email verification response
|
|
417
|
+
/**
|
|
418
|
+
* Store JWT token securely after email verification
|
|
419
|
+
* @param token JWT token from email verification response
|
|
420
420
|
*/
|
|
421
421
|
export const storeJWT = async token => {
|
|
422
422
|
try {
|
|
@@ -432,9 +432,9 @@ export const storeJWT = async token => {
|
|
|
432
432
|
}
|
|
433
433
|
};
|
|
434
434
|
|
|
435
|
-
/**
|
|
436
|
-
* Load JWT token from storage
|
|
437
|
-
* @returns JWT token or null if not found
|
|
435
|
+
/**
|
|
436
|
+
* Load JWT token from storage
|
|
437
|
+
* @returns JWT token or null if not found
|
|
438
438
|
*/
|
|
439
439
|
export const loadJWT = async () => {
|
|
440
440
|
try {
|
|
@@ -447,16 +447,16 @@ export const loadJWT = async () => {
|
|
|
447
447
|
}
|
|
448
448
|
};
|
|
449
449
|
|
|
450
|
-
/**
|
|
451
|
-
* Get current JWT token
|
|
452
|
-
* @returns JWT token or null if not available
|
|
450
|
+
/**
|
|
451
|
+
* Get current JWT token
|
|
452
|
+
* @returns JWT token or null if not available
|
|
453
453
|
*/
|
|
454
454
|
export const getJWT = () => {
|
|
455
455
|
return userToken;
|
|
456
456
|
};
|
|
457
457
|
|
|
458
|
-
/**
|
|
459
|
-
* Clear JWT token (on logout or token expiration)
|
|
458
|
+
/**
|
|
459
|
+
* Clear JWT token (on logout or token expiration)
|
|
460
460
|
*/
|
|
461
461
|
export const clearJWT = async () => {
|
|
462
462
|
try {
|
|
@@ -471,10 +471,10 @@ export const clearJWT = async () => {
|
|
|
471
471
|
}
|
|
472
472
|
};
|
|
473
473
|
|
|
474
|
-
/**
|
|
475
|
-
* React Native compatible base64 decoder
|
|
476
|
-
* @param str Base64 encoded string
|
|
477
|
-
* @returns Decoded string
|
|
474
|
+
/**
|
|
475
|
+
* React Native compatible base64 decoder
|
|
476
|
+
* @param str Base64 encoded string
|
|
477
|
+
* @returns Decoded string
|
|
478
478
|
*/
|
|
479
479
|
const base64Decode = str => {
|
|
480
480
|
// Simple base64 decoding for React Native
|
|
@@ -495,10 +495,10 @@ const base64Decode = str => {
|
|
|
495
495
|
return result;
|
|
496
496
|
};
|
|
497
497
|
|
|
498
|
-
/**
|
|
499
|
-
* Decode JWT token payload (React Native compatible)
|
|
500
|
-
* @param token JWT token string
|
|
501
|
-
* @returns Decoded payload or null if invalid
|
|
498
|
+
/**
|
|
499
|
+
* Decode JWT token payload (React Native compatible)
|
|
500
|
+
* @param token JWT token string
|
|
501
|
+
* @returns Decoded payload or null if invalid
|
|
502
502
|
*/
|
|
503
503
|
export const decodeJWTPayload = token => {
|
|
504
504
|
try {
|
|
@@ -525,10 +525,10 @@ export const decodeJWTPayload = token => {
|
|
|
525
525
|
}
|
|
526
526
|
};
|
|
527
527
|
|
|
528
|
-
/**
|
|
529
|
-
* Extract username from JWT token
|
|
530
|
-
* @param token JWT token (optional, uses stored token if not provided)
|
|
531
|
-
* @returns Username or null if not found
|
|
528
|
+
/**
|
|
529
|
+
* Extract username from JWT token
|
|
530
|
+
* @param token JWT token (optional, uses stored token if not provided)
|
|
531
|
+
* @returns Username or null if not found
|
|
532
532
|
*/
|
|
533
533
|
export const extractUsernameFromJWT = token => {
|
|
534
534
|
try {
|
|
@@ -555,10 +555,10 @@ export const extractUsernameFromJWT = token => {
|
|
|
555
555
|
}
|
|
556
556
|
};
|
|
557
557
|
|
|
558
|
-
/**
|
|
559
|
-
* Extract user data from JWT token
|
|
560
|
-
* @param token JWT token (optional, uses stored token if not provided)
|
|
561
|
-
* @returns User data object or null if not found
|
|
558
|
+
/**
|
|
559
|
+
* Extract user data from JWT token
|
|
560
|
+
* @param token JWT token (optional, uses stored token if not provided)
|
|
561
|
+
* @returns User data object or null if not found
|
|
562
562
|
*/
|
|
563
563
|
export const extractUserDataFromJWT = token => {
|
|
564
564
|
try {
|
|
@@ -591,17 +591,17 @@ export const extractUserDataFromJWT = token => {
|
|
|
591
591
|
}
|
|
592
592
|
};
|
|
593
593
|
|
|
594
|
-
/**
|
|
595
|
-
* Check if user is authenticated with JWT token
|
|
596
|
-
* @returns True if user has valid JWT token
|
|
594
|
+
/**
|
|
595
|
+
* Check if user is authenticated with JWT token
|
|
596
|
+
* @returns True if user has valid JWT token
|
|
597
597
|
*/
|
|
598
598
|
export const isUserAuthenticated = () => {
|
|
599
599
|
return !!userToken;
|
|
600
600
|
};
|
|
601
601
|
|
|
602
|
-
/**
|
|
603
|
-
* Get authenticated headers for API requests
|
|
604
|
-
* @returns Headers object with Authorization and other required headers
|
|
602
|
+
/**
|
|
603
|
+
* Get authenticated headers for API requests
|
|
604
|
+
* @returns Headers object with Authorization and other required headers
|
|
605
605
|
*/
|
|
606
606
|
export const getAuthHeaders = () => {
|
|
607
607
|
var _globalConfig12;
|
|
@@ -620,9 +620,9 @@ export const getAuthHeaders = () => {
|
|
|
620
620
|
};
|
|
621
621
|
};
|
|
622
622
|
|
|
623
|
-
/**
|
|
624
|
-
* Get authentication headers for developer API requests
|
|
625
|
-
* @returns Headers with developer API key
|
|
623
|
+
/**
|
|
624
|
+
* Get authentication headers for developer API requests
|
|
625
|
+
* @returns Headers with developer API key
|
|
626
626
|
*/
|
|
627
627
|
export const getDeveloperAuthHeaders = () => {
|
|
628
628
|
var _globalConfig13;
|
|
@@ -641,9 +641,9 @@ export const getDeveloperAuthHeaders = () => {
|
|
|
641
641
|
};
|
|
642
642
|
};
|
|
643
643
|
|
|
644
|
-
/**
|
|
645
|
-
* Get authentication headers for user JWT requests
|
|
646
|
-
* @returns Headers with user JWT token
|
|
644
|
+
/**
|
|
645
|
+
* Get authentication headers for user JWT requests
|
|
646
|
+
* @returns Headers with user JWT token
|
|
647
647
|
*/
|
|
648
648
|
export const getUserAuthHeaders = () => {
|
|
649
649
|
var _globalConfig14;
|
|
@@ -659,11 +659,11 @@ export const getUserAuthHeaders = () => {
|
|
|
659
659
|
};
|
|
660
660
|
};
|
|
661
661
|
|
|
662
|
-
/**
|
|
663
|
-
* Make an authenticated API request
|
|
664
|
-
* @param endpoint The API endpoint (relative to base URL)
|
|
665
|
-
* @param options Fetch options
|
|
666
|
-
* @returns Response promise
|
|
662
|
+
/**
|
|
663
|
+
* Make an authenticated API request
|
|
664
|
+
* @param endpoint The API endpoint (relative to base URL)
|
|
665
|
+
* @param options Fetch options
|
|
666
|
+
* @returns Response promise
|
|
667
667
|
*/
|
|
668
668
|
export const makeAuthenticatedRequest = async (endpoint, options = {}) => {
|
|
669
669
|
if (!isApiKeyInitialized()) {
|
|
@@ -720,11 +720,11 @@ export const makeAuthenticatedRequest = async (endpoint, options = {}) => {
|
|
|
720
720
|
}
|
|
721
721
|
};
|
|
722
722
|
|
|
723
|
-
/**
|
|
724
|
-
* Make authenticated request with developer API key
|
|
725
|
-
* @param endpoint The API endpoint
|
|
726
|
-
* @param options Fetch options
|
|
727
|
-
* @returns Response promise
|
|
723
|
+
/**
|
|
724
|
+
* Make authenticated request with developer API key
|
|
725
|
+
* @param endpoint The API endpoint
|
|
726
|
+
* @param options Fetch options
|
|
727
|
+
* @returns Response promise
|
|
728
728
|
*/
|
|
729
729
|
export const makeDeveloperRequest = async (endpoint, options = {}) => {
|
|
730
730
|
if (!isApiKeyInitialized()) {
|
|
@@ -781,11 +781,11 @@ export const makeDeveloperRequest = async (endpoint, options = {}) => {
|
|
|
781
781
|
}
|
|
782
782
|
};
|
|
783
783
|
|
|
784
|
-
/**
|
|
785
|
-
* Make authenticated request with user JWT token
|
|
786
|
-
* @param endpoint The API endpoint
|
|
787
|
-
* @param options Fetch options
|
|
788
|
-
* @returns Response promise
|
|
784
|
+
/**
|
|
785
|
+
* Make authenticated request with user JWT token
|
|
786
|
+
* @param endpoint The API endpoint
|
|
787
|
+
* @param options Fetch options
|
|
788
|
+
* @returns Response promise
|
|
789
789
|
*/
|
|
790
790
|
export const makeUserRequest = async (endpoint, options = {}) => {
|
|
791
791
|
if (!isUserAuthenticated()) {
|
|
@@ -846,8 +846,8 @@ export const makeUserRequest = async (endpoint, options = {}) => {
|
|
|
846
846
|
}
|
|
847
847
|
};
|
|
848
848
|
|
|
849
|
-
/**
|
|
850
|
-
* Clear the API key validation cache
|
|
849
|
+
/**
|
|
850
|
+
* Clear the API key validation cache
|
|
851
851
|
*/
|
|
852
852
|
export const clearValidationCache = () => {
|
|
853
853
|
var _globalConfig15;
|
|
@@ -857,8 +857,8 @@ export const clearValidationCache = () => {
|
|
|
857
857
|
}
|
|
858
858
|
};
|
|
859
859
|
|
|
860
|
-
/**
|
|
861
|
-
* Reset the SDK initialization state
|
|
860
|
+
/**
|
|
861
|
+
* Reset the SDK initialization state
|
|
862
862
|
*/
|
|
863
863
|
export const resetApiKeyService = () => {
|
|
864
864
|
globalConfig = null;
|
|
@@ -8,27 +8,27 @@ const API_BASE_URL = API_CONFIG.BASE_URL;
|
|
|
8
8
|
|
|
9
9
|
// Interface for Apple authentication payload
|
|
10
10
|
|
|
11
|
-
/**
|
|
12
|
-
* Interface for the timer response from backend
|
|
11
|
+
/**
|
|
12
|
+
* Interface for the timer response from backend
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
/**
|
|
16
|
-
* Interface for the profile response from backend
|
|
15
|
+
/**
|
|
16
|
+
* Interface for the profile response from backend
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
/**
|
|
20
|
-
* Interface for creating/updating user profile
|
|
19
|
+
/**
|
|
20
|
+
* Interface for creating/updating user profile
|
|
21
21
|
*/
|
|
22
22
|
|
|
23
|
-
/**
|
|
24
|
-
* Authenticate with Apple
|
|
25
|
-
* @param appleAuthData Data from Apple authentication
|
|
26
|
-
* @returns Authentication response with token and user data
|
|
23
|
+
/**
|
|
24
|
+
* Authenticate with Apple
|
|
25
|
+
* @param appleAuthData Data from Apple authentication
|
|
26
|
+
* @returns Authentication response with token and user data
|
|
27
27
|
*/
|
|
28
|
-
/**
|
|
29
|
-
* Authenticate with Onairos (similar to Apple authentication)
|
|
30
|
-
* @param onairosAuthData Data from Onairos authentication
|
|
31
|
-
* @returns Authentication response with token and user data
|
|
28
|
+
/**
|
|
29
|
+
* Authenticate with Onairos (similar to Apple authentication)
|
|
30
|
+
* @param onairosAuthData Data from Onairos authentication
|
|
31
|
+
* @returns Authentication response with token and user data
|
|
32
32
|
*/
|
|
33
33
|
export const authenticateWithOnairos = async onairosAuthData => {
|
|
34
34
|
try {
|
|
@@ -78,10 +78,10 @@ export const authenticateWithOnairos = async onairosAuthData => {
|
|
|
78
78
|
}
|
|
79
79
|
};
|
|
80
80
|
|
|
81
|
-
/**
|
|
82
|
-
* Authenticate with Onairos using the standardized /login/signin endpoint
|
|
83
|
-
* @param credentials Email and password for Onairos sign-in
|
|
84
|
-
* @returns Authentication response with token and user data
|
|
81
|
+
/**
|
|
82
|
+
* Authenticate with Onairos using the standardized /login/signin endpoint
|
|
83
|
+
* @param credentials Email and password for Onairos sign-in
|
|
84
|
+
* @returns Authentication response with token and user data
|
|
85
85
|
*/
|
|
86
86
|
export const authenticateWithOnairosSignIn = async credentials => {
|
|
87
87
|
try {
|
|
@@ -262,9 +262,9 @@ export const authenticateWithApple = async appleAuthData => {
|
|
|
262
262
|
}
|
|
263
263
|
};
|
|
264
264
|
|
|
265
|
-
/**
|
|
266
|
-
* Save authentication token
|
|
267
|
-
* @param token JWT token
|
|
265
|
+
/**
|
|
266
|
+
* Save authentication token
|
|
267
|
+
* @param token JWT token
|
|
268
268
|
*/
|
|
269
269
|
export const saveAuthToken = async token => {
|
|
270
270
|
try {
|
|
@@ -275,8 +275,8 @@ export const saveAuthToken = async token => {
|
|
|
275
275
|
}
|
|
276
276
|
};
|
|
277
277
|
|
|
278
|
-
/**
|
|
279
|
-
* Debug function to check all auth-related storage
|
|
278
|
+
/**
|
|
279
|
+
* Debug function to check all auth-related storage
|
|
280
280
|
*/
|
|
281
281
|
export const debugAuthStorage = async () => {
|
|
282
282
|
console.log('🔍 [AUTH STORAGE DEBUG] Checking all auth-related storage:');
|
|
@@ -303,8 +303,8 @@ export const debugAuthStorage = async () => {
|
|
|
303
303
|
});
|
|
304
304
|
};
|
|
305
305
|
|
|
306
|
-
/**
|
|
307
|
-
* Clear all auth tokens and start fresh
|
|
306
|
+
/**
|
|
307
|
+
* Clear all auth tokens and start fresh
|
|
308
308
|
*/
|
|
309
309
|
export const clearAllAuthTokens = async () => {
|
|
310
310
|
console.log('🧹 [AUTH DEBUG] Clearing all auth tokens via centralized service...');
|
|
@@ -320,9 +320,9 @@ export const clearAllAuthTokens = async () => {
|
|
|
320
320
|
console.log('✅ [AUTH DEBUG] All auth tokens and data cleared');
|
|
321
321
|
};
|
|
322
322
|
|
|
323
|
-
/**
|
|
324
|
-
* Get saved authentication token - CRITICAL FIX: Try all token types
|
|
325
|
-
* @returns Saved JWT token or null if not found
|
|
323
|
+
/**
|
|
324
|
+
* Get saved authentication token - CRITICAL FIX: Try all token types
|
|
325
|
+
* @returns Saved JWT token or null if not found
|
|
326
326
|
*/
|
|
327
327
|
export const getAuthToken = async () => {
|
|
328
328
|
try {
|
|
@@ -362,8 +362,8 @@ export const getAuthToken = async () => {
|
|
|
362
362
|
}
|
|
363
363
|
};
|
|
364
364
|
|
|
365
|
-
/**
|
|
366
|
-
* Remove authentication token (logout)
|
|
365
|
+
/**
|
|
366
|
+
* Remove authentication token (logout)
|
|
367
367
|
*/
|
|
368
368
|
export const removeAuthToken = async () => {
|
|
369
369
|
try {
|
|
@@ -373,9 +373,9 @@ export const removeAuthToken = async () => {
|
|
|
373
373
|
}
|
|
374
374
|
};
|
|
375
375
|
|
|
376
|
-
/**
|
|
377
|
-
* Validate if user is properly authenticated
|
|
378
|
-
* @returns boolean indicating if user has valid authentication
|
|
376
|
+
/**
|
|
377
|
+
* Validate if user is properly authenticated
|
|
378
|
+
* @returns boolean indicating if user has valid authentication
|
|
379
379
|
*/
|
|
380
380
|
export const isAuthenticated = async () => {
|
|
381
381
|
try {
|
|
@@ -387,10 +387,10 @@ export const isAuthenticated = async () => {
|
|
|
387
387
|
}
|
|
388
388
|
};
|
|
389
389
|
|
|
390
|
-
/**
|
|
391
|
-
* Ensure authentication is available before making API calls
|
|
392
|
-
* @param apiName - Name of the API being called (for logging)
|
|
393
|
-
* @returns boolean indicating if authentication is available
|
|
390
|
+
/**
|
|
391
|
+
* Ensure authentication is available before making API calls
|
|
392
|
+
* @param apiName - Name of the API being called (for logging)
|
|
393
|
+
* @returns boolean indicating if authentication is available
|
|
394
394
|
*/
|
|
395
395
|
export const ensureAuthentication = async apiName => {
|
|
396
396
|
const isAuth = await isAuthenticated();
|
|
@@ -402,9 +402,9 @@ export const ensureAuthentication = async apiName => {
|
|
|
402
402
|
return isAuth;
|
|
403
403
|
};
|
|
404
404
|
|
|
405
|
-
/**
|
|
406
|
-
* Get saved Enoch authentication token specifically
|
|
407
|
-
* @returns Saved Enoch JWT token or null if not found
|
|
405
|
+
/**
|
|
406
|
+
* Get saved Enoch authentication token specifically
|
|
407
|
+
* @returns Saved Enoch JWT token or null if not found
|
|
408
408
|
*/
|
|
409
409
|
export const getEnochToken = async () => {
|
|
410
410
|
try {
|
|
@@ -415,9 +415,9 @@ export const getEnochToken = async () => {
|
|
|
415
415
|
}
|
|
416
416
|
};
|
|
417
417
|
|
|
418
|
-
/**
|
|
419
|
-
* Save Enoch authentication token specifically
|
|
420
|
-
* @param token Enoch JWT token
|
|
418
|
+
/**
|
|
419
|
+
* Save Enoch authentication token specifically
|
|
420
|
+
* @param token Enoch JWT token
|
|
421
421
|
*/
|
|
422
422
|
export const saveEnochToken = async token => {
|
|
423
423
|
try {
|
|
@@ -429,9 +429,9 @@ export const saveEnochToken = async token => {
|
|
|
429
429
|
}
|
|
430
430
|
};
|
|
431
431
|
|
|
432
|
-
/**
|
|
433
|
-
* Verify token with backend
|
|
434
|
-
* @returns Boolean indicating if token is valid
|
|
432
|
+
/**
|
|
433
|
+
* Verify token with backend
|
|
434
|
+
* @returns Boolean indicating if token is valid
|
|
435
435
|
*/
|
|
436
436
|
export const verifyToken = async () => {
|
|
437
437
|
try {
|
|
@@ -461,10 +461,10 @@ export const verifyToken = async () => {
|
|
|
461
461
|
}
|
|
462
462
|
};
|
|
463
463
|
|
|
464
|
-
/**
|
|
465
|
-
* Get user profile from backend using stored token
|
|
466
|
-
* Note: This endpoint doesn't exist as GET, so we'll try to fetch via other means
|
|
467
|
-
* @returns User profile data
|
|
464
|
+
/**
|
|
465
|
+
* Get user profile from backend using stored token
|
|
466
|
+
* Note: This endpoint doesn't exist as GET, so we'll try to fetch via other means
|
|
467
|
+
* @returns User profile data
|
|
468
468
|
*/
|
|
469
469
|
export const getUserProfile = async () => {
|
|
470
470
|
try {
|
|
@@ -575,10 +575,10 @@ export const getUserProfile = async () => {
|
|
|
575
575
|
}
|
|
576
576
|
};
|
|
577
577
|
|
|
578
|
-
/**
|
|
579
|
-
* Create or update user profile
|
|
580
|
-
* @param profileData Profile data to create/update
|
|
581
|
-
* @returns Profile response from backend
|
|
578
|
+
/**
|
|
579
|
+
* Create or update user profile
|
|
580
|
+
* @param profileData Profile data to create/update
|
|
581
|
+
* @returns Profile response from backend
|
|
582
582
|
*/
|
|
583
583
|
export const createOrUpdateProfile = async profileData => {
|
|
584
584
|
try {
|
|
@@ -603,9 +603,9 @@ export const createOrUpdateProfile = async profileData => {
|
|
|
603
603
|
}
|
|
604
604
|
};
|
|
605
605
|
|
|
606
|
-
/**
|
|
607
|
-
* Update user's onboarded status
|
|
608
|
-
* @returns Promise that resolves when update is successful
|
|
606
|
+
/**
|
|
607
|
+
* Update user's onboarded status
|
|
608
|
+
* @returns Promise that resolves when update is successful
|
|
609
609
|
*/
|
|
610
610
|
export const updateUserOnboardedStatus = async () => {
|
|
611
611
|
try {
|
|
@@ -629,9 +629,9 @@ export const updateUserOnboardedStatus = async () => {
|
|
|
629
629
|
}
|
|
630
630
|
};
|
|
631
631
|
|
|
632
|
-
/**
|
|
633
|
-
* Fetch the current timer status from the backend
|
|
634
|
-
* @returns Timer information including expiry and duration
|
|
632
|
+
/**
|
|
633
|
+
* Fetch the current timer status from the backend
|
|
634
|
+
* @returns Timer information including expiry and duration
|
|
635
635
|
*/
|
|
636
636
|
export const getEventTimer = async () => {
|
|
637
637
|
try {
|
|
@@ -787,10 +787,10 @@ export const getEventTimer = async () => {
|
|
|
787
787
|
}
|
|
788
788
|
};
|
|
789
789
|
|
|
790
|
-
/**
|
|
791
|
-
* Check if a user email has admin privileges
|
|
792
|
-
* @param email User email to check
|
|
793
|
-
* @returns True if user is an admin
|
|
790
|
+
/**
|
|
791
|
+
* Check if a user email has admin privileges
|
|
792
|
+
* @param email User email to check
|
|
793
|
+
* @returns True if user is an admin
|
|
794
794
|
*/
|
|
795
795
|
export const isAdminEmail = email => {
|
|
796
796
|
if (!email) {
|
|
@@ -807,9 +807,9 @@ export const isAdminEmail = email => {
|
|
|
807
807
|
return isAdmin;
|
|
808
808
|
};
|
|
809
809
|
|
|
810
|
-
/**
|
|
811
|
-
* Get the current admin status from AsyncStorage
|
|
812
|
-
* This could be used for caching admin status between sessions
|
|
810
|
+
/**
|
|
811
|
+
* Get the current admin status from AsyncStorage
|
|
812
|
+
* This could be used for caching admin status between sessions
|
|
813
813
|
*/
|
|
814
814
|
export const getAdminStatus = async () => {
|
|
815
815
|
try {
|
|
@@ -821,9 +821,9 @@ export const getAdminStatus = async () => {
|
|
|
821
821
|
}
|
|
822
822
|
};
|
|
823
823
|
|
|
824
|
-
/**
|
|
825
|
-
* Save admin status to AsyncStorage
|
|
826
|
-
* @param isAdmin Whether the user is an admin
|
|
824
|
+
/**
|
|
825
|
+
* Save admin status to AsyncStorage
|
|
826
|
+
* @param isAdmin Whether the user is an admin
|
|
827
827
|
*/
|
|
828
828
|
export const saveAdminStatus = async isAdmin => {
|
|
829
829
|
try {
|
|
@@ -833,10 +833,10 @@ export const saveAdminStatus = async isAdmin => {
|
|
|
833
833
|
}
|
|
834
834
|
};
|
|
835
835
|
|
|
836
|
-
/**
|
|
837
|
-
* Get stored Onairos username for API calls
|
|
838
|
-
* This is used for data connector APIs (Reddit, etc.) that need the username
|
|
839
|
-
* @returns Stored username or null if not found
|
|
836
|
+
/**
|
|
837
|
+
* Get stored Onairos username for API calls
|
|
838
|
+
* This is used for data connector APIs (Reddit, etc.) that need the username
|
|
839
|
+
* @returns Stored username or null if not found
|
|
840
840
|
*/
|
|
841
841
|
export const getOnairosUsername = async () => {
|
|
842
842
|
try {
|
|
@@ -847,9 +847,9 @@ export const getOnairosUsername = async () => {
|
|
|
847
847
|
}
|
|
848
848
|
};
|
|
849
849
|
|
|
850
|
-
/**
|
|
851
|
-
* Save Onairos username for API calls
|
|
852
|
-
* @param username Username to store
|
|
850
|
+
/**
|
|
851
|
+
* Save Onairos username for API calls
|
|
852
|
+
* @param username Username to store
|
|
853
853
|
*/
|
|
854
854
|
export const saveOnairosUsername = async username => {
|
|
855
855
|
try {
|
|
@@ -859,11 +859,11 @@ export const saveOnairosUsername = async username => {
|
|
|
859
859
|
}
|
|
860
860
|
};
|
|
861
861
|
|
|
862
|
-
/**
|
|
863
|
-
* Check if user has connected Onairos to Enoch before
|
|
864
|
-
* This checks for actual usage/training data, not just account existence
|
|
865
|
-
* @param userIdentifier - Email, username, or user ID to check
|
|
866
|
-
* @returns Promise<boolean> - true if user has connected Onairos features to Enoch
|
|
862
|
+
/**
|
|
863
|
+
* Check if user has connected Onairos to Enoch before
|
|
864
|
+
* This checks for actual usage/training data, not just account existence
|
|
865
|
+
* @param userIdentifier - Email, username, or user ID to check
|
|
866
|
+
* @returns Promise<boolean> - true if user has connected Onairos features to Enoch
|
|
867
867
|
*/
|
|
868
868
|
export const checkEnochOnairosConnection = async userIdentifier => {
|
|
869
869
|
try {
|