@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
|
@@ -18,23 +18,23 @@ let ApiKeyType = exports.ApiKeyType = /*#__PURE__*/function (ApiKeyType) {
|
|
|
18
18
|
}({}); // JWT token storage key
|
|
19
19
|
const JWT_TOKEN_KEY = 'onairos_jwt_token';
|
|
20
20
|
|
|
21
|
-
/**
|
|
22
|
-
* Two-Tier Authentication Service for Onairos React Native SDK
|
|
23
|
-
*
|
|
24
|
-
* This service implements the two-tier authentication system:
|
|
25
|
-
* 1. Developer API Keys: For app-level operations (email verification, app registration)
|
|
26
|
-
* 2. JWT User Tokens: For user-level operations (PIN storage, user profile)
|
|
27
|
-
*
|
|
28
|
-
* How it works:
|
|
29
|
-
* 1. Initialize with developer API key
|
|
30
|
-
* 2. Use API key for email verification requests
|
|
31
|
-
* 3. Store JWT token from email verification response
|
|
32
|
-
* 4. Use JWT token for user-authenticated requests
|
|
33
|
-
* 5. Handle token expiration gracefully
|
|
34
|
-
*
|
|
35
|
-
* Backend Integration:
|
|
36
|
-
* - Developer routes: Authorization: Bearer ${API_KEY}
|
|
37
|
-
* - User routes: Authorization: Bearer ${JWT_TOKEN}
|
|
21
|
+
/**
|
|
22
|
+
* Two-Tier Authentication Service for Onairos React Native SDK
|
|
23
|
+
*
|
|
24
|
+
* This service implements the two-tier authentication system:
|
|
25
|
+
* 1. Developer API Keys: For app-level operations (email verification, app registration)
|
|
26
|
+
* 2. JWT User Tokens: For user-level operations (PIN storage, user profile)
|
|
27
|
+
*
|
|
28
|
+
* How it works:
|
|
29
|
+
* 1. Initialize with developer API key
|
|
30
|
+
* 2. Use API key for email verification requests
|
|
31
|
+
* 3. Store JWT token from email verification response
|
|
32
|
+
* 4. Use JWT token for user-authenticated requests
|
|
33
|
+
* 5. Handle token expiration gracefully
|
|
34
|
+
*
|
|
35
|
+
* Backend Integration:
|
|
36
|
+
* - Developer routes: Authorization: Bearer ${API_KEY}
|
|
37
|
+
* - User routes: Authorization: Bearer ${JWT_TOKEN}
|
|
38
38
|
*/
|
|
39
39
|
|
|
40
40
|
// Global configuration state
|
|
@@ -53,9 +53,9 @@ const API_ENDPOINTS = {
|
|
|
53
53
|
development: 'https://dev-api.onairos.uk'
|
|
54
54
|
};
|
|
55
55
|
|
|
56
|
-
/**
|
|
57
|
-
* Initialize the SDK with developer API key
|
|
58
|
-
* @param config API configuration including developer API key
|
|
56
|
+
/**
|
|
57
|
+
* Initialize the SDK with developer API key
|
|
58
|
+
* @param config API configuration including developer API key
|
|
59
59
|
*/
|
|
60
60
|
const initializeApiKey = async config => {
|
|
61
61
|
try {
|
|
@@ -128,10 +128,10 @@ const initializeApiKey = async config => {
|
|
|
128
128
|
}
|
|
129
129
|
};
|
|
130
130
|
|
|
131
|
-
/**
|
|
132
|
-
* Determine API key type
|
|
133
|
-
* @param apiKey The API key to check
|
|
134
|
-
* @returns The type of API key
|
|
131
|
+
/**
|
|
132
|
+
* Determine API key type
|
|
133
|
+
* @param apiKey The API key to check
|
|
134
|
+
* @returns The type of API key
|
|
135
135
|
*/
|
|
136
136
|
exports.initializeApiKey = initializeApiKey;
|
|
137
137
|
const getApiKeyType = apiKey => {
|
|
@@ -146,20 +146,20 @@ const getApiKeyType = apiKey => {
|
|
|
146
146
|
return ApiKeyType.INVALID;
|
|
147
147
|
};
|
|
148
148
|
|
|
149
|
-
/**
|
|
150
|
-
* Check if API key is admin key
|
|
151
|
-
* @param apiKey The API key to check
|
|
152
|
-
* @returns True if admin key
|
|
149
|
+
/**
|
|
150
|
+
* Check if API key is admin key
|
|
151
|
+
* @param apiKey The API key to check
|
|
152
|
+
* @returns True if admin key
|
|
153
153
|
*/
|
|
154
154
|
exports.getApiKeyType = getApiKeyType;
|
|
155
155
|
const isAdminKey = apiKey => {
|
|
156
156
|
return apiKey === ADMIN_API_KEY;
|
|
157
157
|
};
|
|
158
158
|
|
|
159
|
-
/**
|
|
160
|
-
* Validate an API key with the Onairos backend
|
|
161
|
-
* @param apiKey The API key to validate
|
|
162
|
-
* @returns Validation result with permissions and rate limits
|
|
159
|
+
/**
|
|
160
|
+
* Validate an API key with the Onairos backend
|
|
161
|
+
* @param apiKey The API key to validate
|
|
162
|
+
* @returns Validation result with permissions and rate limits
|
|
163
163
|
*/
|
|
164
164
|
exports.isAdminKey = isAdminKey;
|
|
165
165
|
const validateApiKey = async apiKey => {
|
|
@@ -396,18 +396,18 @@ const validateApiKey = async apiKey => {
|
|
|
396
396
|
}
|
|
397
397
|
};
|
|
398
398
|
|
|
399
|
-
/**
|
|
400
|
-
* Get the current API configuration
|
|
401
|
-
* @returns Current API configuration or null if not initialized
|
|
399
|
+
/**
|
|
400
|
+
* Get the current API configuration
|
|
401
|
+
* @returns Current API configuration or null if not initialized
|
|
402
402
|
*/
|
|
403
403
|
exports.validateApiKey = validateApiKey;
|
|
404
404
|
const getApiConfig = () => {
|
|
405
405
|
return globalConfig;
|
|
406
406
|
};
|
|
407
407
|
|
|
408
|
-
/**
|
|
409
|
-
* Get the current API key
|
|
410
|
-
* @returns Current API key or null if not initialized
|
|
408
|
+
/**
|
|
409
|
+
* Get the current API key
|
|
410
|
+
* @returns Current API key or null if not initialized
|
|
411
411
|
*/
|
|
412
412
|
exports.getApiConfig = getApiConfig;
|
|
413
413
|
const getApiKey = () => {
|
|
@@ -415,18 +415,18 @@ const getApiKey = () => {
|
|
|
415
415
|
return ((_globalConfig9 = globalConfig) === null || _globalConfig9 === void 0 ? void 0 : _globalConfig9.apiKey) || null;
|
|
416
416
|
};
|
|
417
417
|
|
|
418
|
-
/**
|
|
419
|
-
* Check if the SDK is properly initialized
|
|
420
|
-
* @returns True if initialized with valid API key
|
|
418
|
+
/**
|
|
419
|
+
* Check if the SDK is properly initialized
|
|
420
|
+
* @returns True if initialized with valid API key
|
|
421
421
|
*/
|
|
422
422
|
exports.getApiKey = getApiKey;
|
|
423
423
|
const isApiKeyInitialized = () => {
|
|
424
424
|
return isInitialized && globalConfig !== null;
|
|
425
425
|
};
|
|
426
426
|
|
|
427
|
-
/**
|
|
428
|
-
* Store JWT token securely after email verification
|
|
429
|
-
* @param token JWT token from email verification response
|
|
427
|
+
/**
|
|
428
|
+
* Store JWT token securely after email verification
|
|
429
|
+
* @param token JWT token from email verification response
|
|
430
430
|
*/
|
|
431
431
|
exports.isApiKeyInitialized = isApiKeyInitialized;
|
|
432
432
|
const storeJWT = async token => {
|
|
@@ -443,9 +443,9 @@ const storeJWT = async token => {
|
|
|
443
443
|
}
|
|
444
444
|
};
|
|
445
445
|
|
|
446
|
-
/**
|
|
447
|
-
* Load JWT token from storage
|
|
448
|
-
* @returns JWT token or null if not found
|
|
446
|
+
/**
|
|
447
|
+
* Load JWT token from storage
|
|
448
|
+
* @returns JWT token or null if not found
|
|
449
449
|
*/
|
|
450
450
|
exports.storeJWT = storeJWT;
|
|
451
451
|
const loadJWT = async () => {
|
|
@@ -459,17 +459,17 @@ const loadJWT = async () => {
|
|
|
459
459
|
}
|
|
460
460
|
};
|
|
461
461
|
|
|
462
|
-
/**
|
|
463
|
-
* Get current JWT token
|
|
464
|
-
* @returns JWT token or null if not available
|
|
462
|
+
/**
|
|
463
|
+
* Get current JWT token
|
|
464
|
+
* @returns JWT token or null if not available
|
|
465
465
|
*/
|
|
466
466
|
exports.loadJWT = loadJWT;
|
|
467
467
|
const getJWT = () => {
|
|
468
468
|
return userToken;
|
|
469
469
|
};
|
|
470
470
|
|
|
471
|
-
/**
|
|
472
|
-
* Clear JWT token (on logout or token expiration)
|
|
471
|
+
/**
|
|
472
|
+
* Clear JWT token (on logout or token expiration)
|
|
473
473
|
*/
|
|
474
474
|
exports.getJWT = getJWT;
|
|
475
475
|
const clearJWT = async () => {
|
|
@@ -485,10 +485,10 @@ const clearJWT = async () => {
|
|
|
485
485
|
}
|
|
486
486
|
};
|
|
487
487
|
|
|
488
|
-
/**
|
|
489
|
-
* React Native compatible base64 decoder
|
|
490
|
-
* @param str Base64 encoded string
|
|
491
|
-
* @returns Decoded string
|
|
488
|
+
/**
|
|
489
|
+
* React Native compatible base64 decoder
|
|
490
|
+
* @param str Base64 encoded string
|
|
491
|
+
* @returns Decoded string
|
|
492
492
|
*/
|
|
493
493
|
exports.clearJWT = clearJWT;
|
|
494
494
|
const base64Decode = str => {
|
|
@@ -510,10 +510,10 @@ const base64Decode = str => {
|
|
|
510
510
|
return result;
|
|
511
511
|
};
|
|
512
512
|
|
|
513
|
-
/**
|
|
514
|
-
* Decode JWT token payload (React Native compatible)
|
|
515
|
-
* @param token JWT token string
|
|
516
|
-
* @returns Decoded payload or null if invalid
|
|
513
|
+
/**
|
|
514
|
+
* Decode JWT token payload (React Native compatible)
|
|
515
|
+
* @param token JWT token string
|
|
516
|
+
* @returns Decoded payload or null if invalid
|
|
517
517
|
*/
|
|
518
518
|
const decodeJWTPayload = token => {
|
|
519
519
|
try {
|
|
@@ -540,10 +540,10 @@ const decodeJWTPayload = token => {
|
|
|
540
540
|
}
|
|
541
541
|
};
|
|
542
542
|
|
|
543
|
-
/**
|
|
544
|
-
* Extract username from JWT token
|
|
545
|
-
* @param token JWT token (optional, uses stored token if not provided)
|
|
546
|
-
* @returns Username or null if not found
|
|
543
|
+
/**
|
|
544
|
+
* Extract username from JWT token
|
|
545
|
+
* @param token JWT token (optional, uses stored token if not provided)
|
|
546
|
+
* @returns Username or null if not found
|
|
547
547
|
*/
|
|
548
548
|
exports.decodeJWTPayload = decodeJWTPayload;
|
|
549
549
|
const extractUsernameFromJWT = token => {
|
|
@@ -571,10 +571,10 @@ const extractUsernameFromJWT = token => {
|
|
|
571
571
|
}
|
|
572
572
|
};
|
|
573
573
|
|
|
574
|
-
/**
|
|
575
|
-
* Extract user data from JWT token
|
|
576
|
-
* @param token JWT token (optional, uses stored token if not provided)
|
|
577
|
-
* @returns User data object or null if not found
|
|
574
|
+
/**
|
|
575
|
+
* Extract user data from JWT token
|
|
576
|
+
* @param token JWT token (optional, uses stored token if not provided)
|
|
577
|
+
* @returns User data object or null if not found
|
|
578
578
|
*/
|
|
579
579
|
exports.extractUsernameFromJWT = extractUsernameFromJWT;
|
|
580
580
|
const extractUserDataFromJWT = token => {
|
|
@@ -608,18 +608,18 @@ const extractUserDataFromJWT = token => {
|
|
|
608
608
|
}
|
|
609
609
|
};
|
|
610
610
|
|
|
611
|
-
/**
|
|
612
|
-
* Check if user is authenticated with JWT token
|
|
613
|
-
* @returns True if user has valid JWT token
|
|
611
|
+
/**
|
|
612
|
+
* Check if user is authenticated with JWT token
|
|
613
|
+
* @returns True if user has valid JWT token
|
|
614
614
|
*/
|
|
615
615
|
exports.extractUserDataFromJWT = extractUserDataFromJWT;
|
|
616
616
|
const isUserAuthenticated = () => {
|
|
617
617
|
return !!userToken;
|
|
618
618
|
};
|
|
619
619
|
|
|
620
|
-
/**
|
|
621
|
-
* Get authenticated headers for API requests
|
|
622
|
-
* @returns Headers object with Authorization and other required headers
|
|
620
|
+
/**
|
|
621
|
+
* Get authenticated headers for API requests
|
|
622
|
+
* @returns Headers object with Authorization and other required headers
|
|
623
623
|
*/
|
|
624
624
|
exports.isUserAuthenticated = isUserAuthenticated;
|
|
625
625
|
const getAuthHeaders = () => {
|
|
@@ -639,9 +639,9 @@ const getAuthHeaders = () => {
|
|
|
639
639
|
};
|
|
640
640
|
};
|
|
641
641
|
|
|
642
|
-
/**
|
|
643
|
-
* Get authentication headers for developer API requests
|
|
644
|
-
* @returns Headers with developer API key
|
|
642
|
+
/**
|
|
643
|
+
* Get authentication headers for developer API requests
|
|
644
|
+
* @returns Headers with developer API key
|
|
645
645
|
*/
|
|
646
646
|
exports.getAuthHeaders = getAuthHeaders;
|
|
647
647
|
const getDeveloperAuthHeaders = () => {
|
|
@@ -661,9 +661,9 @@ const getDeveloperAuthHeaders = () => {
|
|
|
661
661
|
};
|
|
662
662
|
};
|
|
663
663
|
|
|
664
|
-
/**
|
|
665
|
-
* Get authentication headers for user JWT requests
|
|
666
|
-
* @returns Headers with user JWT token
|
|
664
|
+
/**
|
|
665
|
+
* Get authentication headers for user JWT requests
|
|
666
|
+
* @returns Headers with user JWT token
|
|
667
667
|
*/
|
|
668
668
|
exports.getDeveloperAuthHeaders = getDeveloperAuthHeaders;
|
|
669
669
|
const getUserAuthHeaders = () => {
|
|
@@ -680,11 +680,11 @@ const getUserAuthHeaders = () => {
|
|
|
680
680
|
};
|
|
681
681
|
};
|
|
682
682
|
|
|
683
|
-
/**
|
|
684
|
-
* Make an authenticated API request
|
|
685
|
-
* @param endpoint The API endpoint (relative to base URL)
|
|
686
|
-
* @param options Fetch options
|
|
687
|
-
* @returns Response promise
|
|
683
|
+
/**
|
|
684
|
+
* Make an authenticated API request
|
|
685
|
+
* @param endpoint The API endpoint (relative to base URL)
|
|
686
|
+
* @param options Fetch options
|
|
687
|
+
* @returns Response promise
|
|
688
688
|
*/
|
|
689
689
|
exports.getUserAuthHeaders = getUserAuthHeaders;
|
|
690
690
|
const makeAuthenticatedRequest = async (endpoint, options = {}) => {
|
|
@@ -742,11 +742,11 @@ const makeAuthenticatedRequest = async (endpoint, options = {}) => {
|
|
|
742
742
|
}
|
|
743
743
|
};
|
|
744
744
|
|
|
745
|
-
/**
|
|
746
|
-
* Make authenticated request with developer API key
|
|
747
|
-
* @param endpoint The API endpoint
|
|
748
|
-
* @param options Fetch options
|
|
749
|
-
* @returns Response promise
|
|
745
|
+
/**
|
|
746
|
+
* Make authenticated request with developer API key
|
|
747
|
+
* @param endpoint The API endpoint
|
|
748
|
+
* @param options Fetch options
|
|
749
|
+
* @returns Response promise
|
|
750
750
|
*/
|
|
751
751
|
exports.makeAuthenticatedRequest = makeAuthenticatedRequest;
|
|
752
752
|
const makeDeveloperRequest = async (endpoint, options = {}) => {
|
|
@@ -804,11 +804,11 @@ const makeDeveloperRequest = async (endpoint, options = {}) => {
|
|
|
804
804
|
}
|
|
805
805
|
};
|
|
806
806
|
|
|
807
|
-
/**
|
|
808
|
-
* Make authenticated request with user JWT token
|
|
809
|
-
* @param endpoint The API endpoint
|
|
810
|
-
* @param options Fetch options
|
|
811
|
-
* @returns Response promise
|
|
807
|
+
/**
|
|
808
|
+
* Make authenticated request with user JWT token
|
|
809
|
+
* @param endpoint The API endpoint
|
|
810
|
+
* @param options Fetch options
|
|
811
|
+
* @returns Response promise
|
|
812
812
|
*/
|
|
813
813
|
exports.makeDeveloperRequest = makeDeveloperRequest;
|
|
814
814
|
const makeUserRequest = async (endpoint, options = {}) => {
|
|
@@ -870,8 +870,8 @@ const makeUserRequest = async (endpoint, options = {}) => {
|
|
|
870
870
|
}
|
|
871
871
|
};
|
|
872
872
|
|
|
873
|
-
/**
|
|
874
|
-
* Clear the API key validation cache
|
|
873
|
+
/**
|
|
874
|
+
* Clear the API key validation cache
|
|
875
875
|
*/
|
|
876
876
|
exports.makeUserRequest = makeUserRequest;
|
|
877
877
|
const clearValidationCache = () => {
|
|
@@ -882,8 +882,8 @@ const clearValidationCache = () => {
|
|
|
882
882
|
}
|
|
883
883
|
};
|
|
884
884
|
|
|
885
|
-
/**
|
|
886
|
-
* Reset the SDK initialization state
|
|
885
|
+
/**
|
|
886
|
+
* Reset the SDK initialization state
|
|
887
887
|
*/
|
|
888
888
|
exports.clearValidationCache = clearValidationCache;
|
|
889
889
|
const resetApiKeyService = () => {
|
|
@@ -15,27 +15,27 @@ const API_BASE_URL = _api.API_CONFIG.BASE_URL;
|
|
|
15
15
|
|
|
16
16
|
// Interface for Apple authentication payload
|
|
17
17
|
|
|
18
|
-
/**
|
|
19
|
-
* Interface for the timer response from backend
|
|
18
|
+
/**
|
|
19
|
+
* Interface for the timer response from backend
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
-
/**
|
|
23
|
-
* Interface for the profile response from backend
|
|
22
|
+
/**
|
|
23
|
+
* Interface for the profile response from backend
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
/**
|
|
27
|
-
* Interface for creating/updating user profile
|
|
26
|
+
/**
|
|
27
|
+
* Interface for creating/updating user profile
|
|
28
28
|
*/
|
|
29
29
|
|
|
30
|
-
/**
|
|
31
|
-
* Authenticate with Apple
|
|
32
|
-
* @param appleAuthData Data from Apple authentication
|
|
33
|
-
* @returns Authentication response with token and user data
|
|
30
|
+
/**
|
|
31
|
+
* Authenticate with Apple
|
|
32
|
+
* @param appleAuthData Data from Apple authentication
|
|
33
|
+
* @returns Authentication response with token and user data
|
|
34
34
|
*/
|
|
35
|
-
/**
|
|
36
|
-
* Authenticate with Onairos (similar to Apple authentication)
|
|
37
|
-
* @param onairosAuthData Data from Onairos authentication
|
|
38
|
-
* @returns Authentication response with token and user data
|
|
35
|
+
/**
|
|
36
|
+
* Authenticate with Onairos (similar to Apple authentication)
|
|
37
|
+
* @param onairosAuthData Data from Onairos authentication
|
|
38
|
+
* @returns Authentication response with token and user data
|
|
39
39
|
*/
|
|
40
40
|
const authenticateWithOnairos = async onairosAuthData => {
|
|
41
41
|
try {
|
|
@@ -85,10 +85,10 @@ const authenticateWithOnairos = async onairosAuthData => {
|
|
|
85
85
|
}
|
|
86
86
|
};
|
|
87
87
|
|
|
88
|
-
/**
|
|
89
|
-
* Authenticate with Onairos using the standardized /login/signin endpoint
|
|
90
|
-
* @param credentials Email and password for Onairos sign-in
|
|
91
|
-
* @returns Authentication response with token and user data
|
|
88
|
+
/**
|
|
89
|
+
* Authenticate with Onairos using the standardized /login/signin endpoint
|
|
90
|
+
* @param credentials Email and password for Onairos sign-in
|
|
91
|
+
* @returns Authentication response with token and user data
|
|
92
92
|
*/
|
|
93
93
|
exports.authenticateWithOnairos = authenticateWithOnairos;
|
|
94
94
|
const authenticateWithOnairosSignIn = async credentials => {
|
|
@@ -271,9 +271,9 @@ const authenticateWithApple = async appleAuthData => {
|
|
|
271
271
|
}
|
|
272
272
|
};
|
|
273
273
|
|
|
274
|
-
/**
|
|
275
|
-
* Save authentication token
|
|
276
|
-
* @param token JWT token
|
|
274
|
+
/**
|
|
275
|
+
* Save authentication token
|
|
276
|
+
* @param token JWT token
|
|
277
277
|
*/
|
|
278
278
|
exports.authenticateWithApple = authenticateWithApple;
|
|
279
279
|
const saveAuthToken = async token => {
|
|
@@ -285,8 +285,8 @@ const saveAuthToken = async token => {
|
|
|
285
285
|
}
|
|
286
286
|
};
|
|
287
287
|
|
|
288
|
-
/**
|
|
289
|
-
* Debug function to check all auth-related storage
|
|
288
|
+
/**
|
|
289
|
+
* Debug function to check all auth-related storage
|
|
290
290
|
*/
|
|
291
291
|
exports.saveAuthToken = saveAuthToken;
|
|
292
292
|
const debugAuthStorage = async () => {
|
|
@@ -314,8 +314,8 @@ const debugAuthStorage = async () => {
|
|
|
314
314
|
});
|
|
315
315
|
};
|
|
316
316
|
|
|
317
|
-
/**
|
|
318
|
-
* Clear all auth tokens and start fresh
|
|
317
|
+
/**
|
|
318
|
+
* Clear all auth tokens and start fresh
|
|
319
319
|
*/
|
|
320
320
|
exports.debugAuthStorage = debugAuthStorage;
|
|
321
321
|
const clearAllAuthTokens = async () => {
|
|
@@ -332,9 +332,9 @@ const clearAllAuthTokens = async () => {
|
|
|
332
332
|
console.log('✅ [AUTH DEBUG] All auth tokens and data cleared');
|
|
333
333
|
};
|
|
334
334
|
|
|
335
|
-
/**
|
|
336
|
-
* Get saved authentication token - CRITICAL FIX: Try all token types
|
|
337
|
-
* @returns Saved JWT token or null if not found
|
|
335
|
+
/**
|
|
336
|
+
* Get saved authentication token - CRITICAL FIX: Try all token types
|
|
337
|
+
* @returns Saved JWT token or null if not found
|
|
338
338
|
*/
|
|
339
339
|
exports.clearAllAuthTokens = clearAllAuthTokens;
|
|
340
340
|
const getAuthToken = async () => {
|
|
@@ -375,8 +375,8 @@ const getAuthToken = async () => {
|
|
|
375
375
|
}
|
|
376
376
|
};
|
|
377
377
|
|
|
378
|
-
/**
|
|
379
|
-
* Remove authentication token (logout)
|
|
378
|
+
/**
|
|
379
|
+
* Remove authentication token (logout)
|
|
380
380
|
*/
|
|
381
381
|
exports.getAuthToken = getAuthToken;
|
|
382
382
|
const removeAuthToken = async () => {
|
|
@@ -387,9 +387,9 @@ const removeAuthToken = async () => {
|
|
|
387
387
|
}
|
|
388
388
|
};
|
|
389
389
|
|
|
390
|
-
/**
|
|
391
|
-
* Validate if user is properly authenticated
|
|
392
|
-
* @returns boolean indicating if user has valid authentication
|
|
390
|
+
/**
|
|
391
|
+
* Validate if user is properly authenticated
|
|
392
|
+
* @returns boolean indicating if user has valid authentication
|
|
393
393
|
*/
|
|
394
394
|
exports.removeAuthToken = removeAuthToken;
|
|
395
395
|
const isAuthenticated = async () => {
|
|
@@ -402,10 +402,10 @@ const isAuthenticated = async () => {
|
|
|
402
402
|
}
|
|
403
403
|
};
|
|
404
404
|
|
|
405
|
-
/**
|
|
406
|
-
* Ensure authentication is available before making API calls
|
|
407
|
-
* @param apiName - Name of the API being called (for logging)
|
|
408
|
-
* @returns boolean indicating if authentication is available
|
|
405
|
+
/**
|
|
406
|
+
* Ensure authentication is available before making API calls
|
|
407
|
+
* @param apiName - Name of the API being called (for logging)
|
|
408
|
+
* @returns boolean indicating if authentication is available
|
|
409
409
|
*/
|
|
410
410
|
exports.isAuthenticated = isAuthenticated;
|
|
411
411
|
const ensureAuthentication = async apiName => {
|
|
@@ -418,9 +418,9 @@ const ensureAuthentication = async apiName => {
|
|
|
418
418
|
return isAuth;
|
|
419
419
|
};
|
|
420
420
|
|
|
421
|
-
/**
|
|
422
|
-
* Get saved Enoch authentication token specifically
|
|
423
|
-
* @returns Saved Enoch JWT token or null if not found
|
|
421
|
+
/**
|
|
422
|
+
* Get saved Enoch authentication token specifically
|
|
423
|
+
* @returns Saved Enoch JWT token or null if not found
|
|
424
424
|
*/
|
|
425
425
|
exports.ensureAuthentication = ensureAuthentication;
|
|
426
426
|
const getEnochToken = async () => {
|
|
@@ -432,9 +432,9 @@ const getEnochToken = async () => {
|
|
|
432
432
|
}
|
|
433
433
|
};
|
|
434
434
|
|
|
435
|
-
/**
|
|
436
|
-
* Save Enoch authentication token specifically
|
|
437
|
-
* @param token Enoch JWT token
|
|
435
|
+
/**
|
|
436
|
+
* Save Enoch authentication token specifically
|
|
437
|
+
* @param token Enoch JWT token
|
|
438
438
|
*/
|
|
439
439
|
exports.getEnochToken = getEnochToken;
|
|
440
440
|
const saveEnochToken = async token => {
|
|
@@ -447,9 +447,9 @@ const saveEnochToken = async token => {
|
|
|
447
447
|
}
|
|
448
448
|
};
|
|
449
449
|
|
|
450
|
-
/**
|
|
451
|
-
* Verify token with backend
|
|
452
|
-
* @returns Boolean indicating if token is valid
|
|
450
|
+
/**
|
|
451
|
+
* Verify token with backend
|
|
452
|
+
* @returns Boolean indicating if token is valid
|
|
453
453
|
*/
|
|
454
454
|
exports.saveEnochToken = saveEnochToken;
|
|
455
455
|
const verifyToken = async () => {
|
|
@@ -480,10 +480,10 @@ const verifyToken = async () => {
|
|
|
480
480
|
}
|
|
481
481
|
};
|
|
482
482
|
|
|
483
|
-
/**
|
|
484
|
-
* Get user profile from backend using stored token
|
|
485
|
-
* Note: This endpoint doesn't exist as GET, so we'll try to fetch via other means
|
|
486
|
-
* @returns User profile data
|
|
483
|
+
/**
|
|
484
|
+
* Get user profile from backend using stored token
|
|
485
|
+
* Note: This endpoint doesn't exist as GET, so we'll try to fetch via other means
|
|
486
|
+
* @returns User profile data
|
|
487
487
|
*/
|
|
488
488
|
exports.verifyToken = verifyToken;
|
|
489
489
|
const getUserProfile = async () => {
|
|
@@ -595,10 +595,10 @@ const getUserProfile = async () => {
|
|
|
595
595
|
}
|
|
596
596
|
};
|
|
597
597
|
|
|
598
|
-
/**
|
|
599
|
-
* Create or update user profile
|
|
600
|
-
* @param profileData Profile data to create/update
|
|
601
|
-
* @returns Profile response from backend
|
|
598
|
+
/**
|
|
599
|
+
* Create or update user profile
|
|
600
|
+
* @param profileData Profile data to create/update
|
|
601
|
+
* @returns Profile response from backend
|
|
602
602
|
*/
|
|
603
603
|
exports.getUserProfile = getUserProfile;
|
|
604
604
|
const createOrUpdateProfile = async profileData => {
|
|
@@ -624,9 +624,9 @@ const createOrUpdateProfile = async profileData => {
|
|
|
624
624
|
}
|
|
625
625
|
};
|
|
626
626
|
|
|
627
|
-
/**
|
|
628
|
-
* Update user's onboarded status
|
|
629
|
-
* @returns Promise that resolves when update is successful
|
|
627
|
+
/**
|
|
628
|
+
* Update user's onboarded status
|
|
629
|
+
* @returns Promise that resolves when update is successful
|
|
630
630
|
*/
|
|
631
631
|
exports.createOrUpdateProfile = createOrUpdateProfile;
|
|
632
632
|
const updateUserOnboardedStatus = async () => {
|
|
@@ -651,9 +651,9 @@ const updateUserOnboardedStatus = async () => {
|
|
|
651
651
|
}
|
|
652
652
|
};
|
|
653
653
|
|
|
654
|
-
/**
|
|
655
|
-
* Fetch the current timer status from the backend
|
|
656
|
-
* @returns Timer information including expiry and duration
|
|
654
|
+
/**
|
|
655
|
+
* Fetch the current timer status from the backend
|
|
656
|
+
* @returns Timer information including expiry and duration
|
|
657
657
|
*/
|
|
658
658
|
exports.updateUserOnboardedStatus = updateUserOnboardedStatus;
|
|
659
659
|
const getEventTimer = async () => {
|
|
@@ -810,10 +810,10 @@ const getEventTimer = async () => {
|
|
|
810
810
|
}
|
|
811
811
|
};
|
|
812
812
|
|
|
813
|
-
/**
|
|
814
|
-
* Check if a user email has admin privileges
|
|
815
|
-
* @param email User email to check
|
|
816
|
-
* @returns True if user is an admin
|
|
813
|
+
/**
|
|
814
|
+
* Check if a user email has admin privileges
|
|
815
|
+
* @param email User email to check
|
|
816
|
+
* @returns True if user is an admin
|
|
817
817
|
*/
|
|
818
818
|
exports.getEventTimer = getEventTimer;
|
|
819
819
|
const isAdminEmail = email => {
|
|
@@ -831,9 +831,9 @@ const isAdminEmail = email => {
|
|
|
831
831
|
return isAdmin;
|
|
832
832
|
};
|
|
833
833
|
|
|
834
|
-
/**
|
|
835
|
-
* Get the current admin status from AsyncStorage
|
|
836
|
-
* This could be used for caching admin status between sessions
|
|
834
|
+
/**
|
|
835
|
+
* Get the current admin status from AsyncStorage
|
|
836
|
+
* This could be used for caching admin status between sessions
|
|
837
837
|
*/
|
|
838
838
|
exports.isAdminEmail = isAdminEmail;
|
|
839
839
|
const getAdminStatus = async () => {
|
|
@@ -846,9 +846,9 @@ const getAdminStatus = async () => {
|
|
|
846
846
|
}
|
|
847
847
|
};
|
|
848
848
|
|
|
849
|
-
/**
|
|
850
|
-
* Save admin status to AsyncStorage
|
|
851
|
-
* @param isAdmin Whether the user is an admin
|
|
849
|
+
/**
|
|
850
|
+
* Save admin status to AsyncStorage
|
|
851
|
+
* @param isAdmin Whether the user is an admin
|
|
852
852
|
*/
|
|
853
853
|
exports.getAdminStatus = getAdminStatus;
|
|
854
854
|
const saveAdminStatus = async isAdmin => {
|
|
@@ -859,10 +859,10 @@ const saveAdminStatus = async isAdmin => {
|
|
|
859
859
|
}
|
|
860
860
|
};
|
|
861
861
|
|
|
862
|
-
/**
|
|
863
|
-
* Get stored Onairos username for API calls
|
|
864
|
-
* This is used for data connector APIs (Reddit, etc.) that need the username
|
|
865
|
-
* @returns Stored username or null if not found
|
|
862
|
+
/**
|
|
863
|
+
* Get stored Onairos username for API calls
|
|
864
|
+
* This is used for data connector APIs (Reddit, etc.) that need the username
|
|
865
|
+
* @returns Stored username or null if not found
|
|
866
866
|
*/
|
|
867
867
|
exports.saveAdminStatus = saveAdminStatus;
|
|
868
868
|
const getOnairosUsername = async () => {
|
|
@@ -874,9 +874,9 @@ const getOnairosUsername = async () => {
|
|
|
874
874
|
}
|
|
875
875
|
};
|
|
876
876
|
|
|
877
|
-
/**
|
|
878
|
-
* Save Onairos username for API calls
|
|
879
|
-
* @param username Username to store
|
|
877
|
+
/**
|
|
878
|
+
* Save Onairos username for API calls
|
|
879
|
+
* @param username Username to store
|
|
880
880
|
*/
|
|
881
881
|
exports.getOnairosUsername = getOnairosUsername;
|
|
882
882
|
const saveOnairosUsername = async username => {
|
|
@@ -887,11 +887,11 @@ const saveOnairosUsername = async username => {
|
|
|
887
887
|
}
|
|
888
888
|
};
|
|
889
889
|
|
|
890
|
-
/**
|
|
891
|
-
* Check if user has connected Onairos to Enoch before
|
|
892
|
-
* This checks for actual usage/training data, not just account existence
|
|
893
|
-
* @param userIdentifier - Email, username, or user ID to check
|
|
894
|
-
* @returns Promise<boolean> - true if user has connected Onairos features to Enoch
|
|
890
|
+
/**
|
|
891
|
+
* Check if user has connected Onairos to Enoch before
|
|
892
|
+
* This checks for actual usage/training data, not just account existence
|
|
893
|
+
* @param userIdentifier - Email, username, or user ID to check
|
|
894
|
+
* @returns Promise<boolean> - true if user has connected Onairos features to Enoch
|
|
895
895
|
*/
|
|
896
896
|
exports.saveOnairosUsername = saveOnairosUsername;
|
|
897
897
|
const checkEnochOnairosConnection = async userIdentifier => {
|