@onairos/react-native 3.0.2 → 3.0.5

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 (155) hide show
  1. package/README.md +23 -3
  2. package/lib/commonjs/api/index.js +5 -1
  3. package/lib/commonjs/api/index.js.map +1 -1
  4. package/lib/commonjs/components/OnairosButton.js +5 -3
  5. package/lib/commonjs/components/OnairosButton.js.map +1 -1
  6. package/lib/commonjs/components/Overlay.js +274 -104
  7. package/lib/commonjs/components/Overlay.js.map +1 -1
  8. package/lib/commonjs/components/UniversalOnboarding.js +12 -0
  9. package/lib/commonjs/components/UniversalOnboarding.js.map +1 -1
  10. package/lib/commonjs/components/onboarding/OAuthWebView.js +28 -9
  11. package/lib/commonjs/components/onboarding/OAuthWebView.js.map +1 -1
  12. package/lib/commonjs/components/onboarding/PlatformConnector.js +6 -1
  13. package/lib/commonjs/components/onboarding/PlatformConnector.js.map +1 -1
  14. package/lib/commonjs/components/screens/ConnectorScreen.js +3 -2
  15. package/lib/commonjs/components/screens/ConnectorScreen.js.map +1 -1
  16. package/lib/commonjs/constants/index.js +1 -1
  17. package/lib/commonjs/hooks/useConnections.js +77 -15
  18. package/lib/commonjs/hooks/useConnections.js.map +1 -1
  19. package/lib/commonjs/hooks/useCredentials.js +2 -0
  20. package/lib/commonjs/hooks/useCredentials.js.map +1 -1
  21. package/lib/commonjs/index.js +51 -56
  22. package/lib/commonjs/index.js.map +1 -1
  23. package/lib/commonjs/services/oauthService.js +26 -51
  24. package/lib/commonjs/services/oauthService.js.map +1 -1
  25. package/lib/commonjs/types/ambient.d.js +2 -0
  26. package/lib/commonjs/types/ambient.d.js.map +1 -0
  27. package/lib/commonjs/types/node-fix.d.js +2 -0
  28. package/lib/commonjs/types/node-fix.d.js.map +1 -0
  29. package/lib/commonjs/types/node-override.d.js +2 -0
  30. package/lib/commonjs/types/node-override.d.js.map +1 -0
  31. package/lib/commonjs/types/types.d.js +2 -0
  32. package/lib/commonjs/types/types.d.js.map +1 -0
  33. package/lib/commonjs/utils/encryption.js +8 -2
  34. package/lib/commonjs/utils/encryption.js.map +1 -1
  35. package/lib/commonjs/utils/secureStorage.js +23 -4
  36. package/lib/commonjs/utils/secureStorage.js.map +1 -1
  37. package/lib/module/api/index.js +5 -1
  38. package/lib/module/api/index.js.map +1 -1
  39. package/lib/module/components/OnairosButton.js +6 -4
  40. package/lib/module/components/OnairosButton.js.map +1 -1
  41. package/lib/module/components/Overlay.js +275 -107
  42. package/lib/module/components/Overlay.js.map +1 -1
  43. package/lib/module/components/UniversalOnboarding.js +12 -0
  44. package/lib/module/components/UniversalOnboarding.js.map +1 -1
  45. package/lib/module/components/onboarding/OAuthWebView.js +28 -9
  46. package/lib/module/components/onboarding/OAuthWebView.js.map +1 -1
  47. package/lib/module/components/onboarding/PlatformConnector.js +6 -1
  48. package/lib/module/components/onboarding/PlatformConnector.js.map +1 -1
  49. package/lib/module/components/screens/ConnectorScreen.js +3 -2
  50. package/lib/module/components/screens/ConnectorScreen.js.map +1 -1
  51. package/lib/module/constants/index.js +1 -1
  52. package/lib/module/hooks/useConnections.js +77 -14
  53. package/lib/module/hooks/useConnections.js.map +1 -1
  54. package/lib/module/hooks/useCredentials.js +2 -0
  55. package/lib/module/hooks/useCredentials.js.map +1 -1
  56. package/lib/module/index.js +27 -9
  57. package/lib/module/index.js.map +1 -1
  58. package/lib/module/services/oauthService.js +26 -33
  59. package/lib/module/services/oauthService.js.map +1 -1
  60. package/lib/module/types/ambient.d.js +2 -0
  61. package/lib/module/types/ambient.d.js.map +1 -0
  62. package/lib/module/types/node-fix.d.js +2 -0
  63. package/lib/module/types/node-fix.d.js.map +1 -0
  64. package/lib/module/types/node-override.d.js +2 -0
  65. package/lib/module/types/node-override.d.js.map +1 -0
  66. package/lib/module/types/types.d.js +2 -0
  67. package/lib/module/types/types.d.js.map +1 -0
  68. package/lib/module/utils/encryption.js +8 -2
  69. package/lib/module/utils/encryption.js.map +1 -1
  70. package/lib/module/utils/secureStorage.js +23 -3
  71. package/lib/module/utils/secureStorage.js.map +1 -1
  72. package/lib/typescript/api/index.d.ts +8 -0
  73. package/lib/typescript/api/index.d.ts.map +1 -0
  74. package/lib/typescript/components/DataRequestModal.d.ts +11 -0
  75. package/lib/typescript/components/DataRequestModal.d.ts.map +1 -0
  76. package/lib/typescript/components/Onairos.d.ts +29 -0
  77. package/lib/typescript/components/Onairos.d.ts.map +1 -0
  78. package/lib/typescript/components/OnairosButton.d.ts +7 -0
  79. package/lib/typescript/components/OnairosButton.d.ts.map +1 -0
  80. package/lib/typescript/components/Overlay.d.ts +18 -0
  81. package/lib/typescript/components/Overlay.d.ts.map +1 -0
  82. package/lib/typescript/components/PinInput.d.ts +4 -0
  83. package/lib/typescript/components/PinInput.d.ts.map +1 -0
  84. package/lib/typescript/components/PlatformList.d.ts +4 -0
  85. package/lib/typescript/components/PlatformList.d.ts.map +1 -0
  86. package/lib/typescript/components/TrainingModal.d.ts +4 -0
  87. package/lib/typescript/components/TrainingModal.d.ts.map +1 -0
  88. package/lib/typescript/components/UniversalOnboarding.d.ts +4 -0
  89. package/lib/typescript/components/UniversalOnboarding.d.ts.map +1 -0
  90. package/lib/typescript/components/onboarding/OAuthWebView.d.ts +4 -0
  91. package/lib/typescript/components/onboarding/OAuthWebView.d.ts.map +1 -0
  92. package/lib/typescript/components/onboarding/OnboardingHeader.d.ts +11 -0
  93. package/lib/typescript/components/onboarding/OnboardingHeader.d.ts.map +1 -0
  94. package/lib/typescript/components/onboarding/PinInput.d.ts +4 -0
  95. package/lib/typescript/components/onboarding/PinInput.d.ts.map +1 -0
  96. package/lib/typescript/components/onboarding/PlatformConnector.d.ts +13 -0
  97. package/lib/typescript/components/onboarding/PlatformConnector.d.ts.map +1 -0
  98. package/lib/typescript/components/screens/ConnectorScreen.d.ts +9 -0
  99. package/lib/typescript/components/screens/ConnectorScreen.d.ts.map +1 -0
  100. package/lib/typescript/components/screens/LoadingScreen.d.ts +9 -0
  101. package/lib/typescript/components/screens/LoadingScreen.d.ts.map +1 -0
  102. package/lib/typescript/components/screens/PinCreationScreen.d.ts +10 -0
  103. package/lib/typescript/components/screens/PinCreationScreen.d.ts.map +1 -0
  104. package/lib/typescript/constants/index.d.ts +52 -0
  105. package/lib/typescript/constants/index.d.ts.map +1 -0
  106. package/lib/typescript/hooks/useConnections.d.ts +9 -0
  107. package/lib/typescript/hooks/useConnections.d.ts.map +1 -0
  108. package/lib/typescript/hooks/useCredentials.d.ts +9 -0
  109. package/lib/typescript/hooks/useCredentials.d.ts.map +1 -0
  110. package/lib/typescript/index.d.ts +45 -0
  111. package/lib/typescript/index.d.ts.map +1 -0
  112. package/lib/typescript/services/oauthService.d.ts +50 -0
  113. package/lib/typescript/services/oauthService.d.ts.map +1 -0
  114. package/lib/typescript/types/index.d.ts +145 -0
  115. package/lib/typescript/types/index.d.ts.map +1 -0
  116. package/lib/typescript/types.d.ts +135 -0
  117. package/lib/typescript/types.d.ts.map +1 -0
  118. package/lib/typescript/utils/api.d.ts +6 -0
  119. package/lib/typescript/utils/api.d.ts.map +1 -0
  120. package/lib/typescript/utils/auth.d.ts +6 -0
  121. package/lib/typescript/utils/auth.d.ts.map +1 -0
  122. package/lib/typescript/utils/crypto.d.ts +4 -0
  123. package/lib/typescript/utils/crypto.d.ts.map +1 -0
  124. package/lib/typescript/utils/debugHelper.d.ts +29 -0
  125. package/lib/typescript/utils/debugHelper.d.ts.map +1 -0
  126. package/lib/typescript/utils/encryption.d.ts +19 -0
  127. package/lib/typescript/utils/encryption.d.ts.map +1 -0
  128. package/lib/typescript/utils/onairosApi.d.ts +72 -0
  129. package/lib/typescript/utils/onairosApi.d.ts.map +1 -0
  130. package/lib/typescript/utils/secureStorage.d.ts +63 -0
  131. package/lib/typescript/utils/secureStorage.d.ts.map +1 -0
  132. package/package.json +16 -4
  133. package/src/api/index.ts +11 -11
  134. package/src/components/OnairosButton.tsx +5 -3
  135. package/src/components/Overlay.tsx +319 -135
  136. package/src/components/UniversalOnboarding.tsx +12 -0
  137. package/src/components/onboarding/OAuthWebView.tsx +27 -7
  138. package/src/components/onboarding/PlatformConnector.tsx +5 -0
  139. package/src/components/screens/ConnectorScreen.tsx +3 -2
  140. package/src/constants/index.ts +81 -81
  141. package/src/hooks/useConnections.ts +76 -16
  142. package/src/hooks/useCredentials.ts +5 -1
  143. package/src/index.ts +29 -1
  144. package/src/services/oauthService.ts +412 -419
  145. package/src/types/ambient.d.ts +29 -0
  146. package/src/types/index.d.ts +48 -8
  147. package/src/types/index.ts +21 -15
  148. package/src/types/node-fix.d.ts +19 -0
  149. package/src/types/node-override.d.ts +24 -0
  150. package/src/types/types.d.ts +18 -0
  151. package/src/types.ts +121 -1
  152. package/src/utils/encryption.ts +7 -2
  153. package/src/utils/secureStorage.ts +25 -9
  154. package/types/index.d.ts +210 -0
  155. package/types/node-env.d.ts +15 -0
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Ambient type declarations to fix Node.js module conflicts
3
+ */
4
+
5
+ // These modules are not used directly in React Native, but are referenced by types
6
+ // Providing empty declarations prevents TypeScript from trying to use Node.js types
7
+ declare module 'https' {
8
+ interface Server {
9
+ prependListener(event: string, listener: (...args: any[]) => void): any;
10
+ once(event: string, listener: (...args: any[]) => void): any;
11
+ prependOnceListener(event: string, listener: (...args: any[]) => void): any;
12
+ }
13
+ }
14
+
15
+ declare module 'node:https' {}
16
+ declare module 'node:http' {}
17
+ declare module 'node:crypto' {}
18
+ declare module 'process' {
19
+ global {
20
+ namespace NodeJS {
21
+ interface Process {
22
+ env: {
23
+ NODE_ENV?: string;
24
+ [key: string]: string | undefined;
25
+ };
26
+ }
27
+ }
28
+ }
29
+ }
@@ -9,27 +9,47 @@ declare module '@onairos/react-native' {
9
9
  }
10
10
 
11
11
  export interface OnairosButtonProps {
12
+ /** Return link after authentication (used for web-based flows) */
12
13
  returnLink?: string;
14
+ /** Prefill URL for the authentication process */
13
15
  prefillUrl?: string;
14
- AppName: string;
16
+ /** Application name to display in dialogs */
17
+ AppName?: string;
18
+ /** Button type - 'normal' or 'pill' */
15
19
  buttonType?: 'normal' | 'pill';
20
+ /** Data requests for user consent */
16
21
  requestData?: {
17
- Small: DataTier;
18
- Medium: DataTier;
19
- Large: DataTier;
22
+ [key: string]: {
23
+ type: string;
24
+ descriptions: string;
25
+ reward: string;
26
+ };
20
27
  };
21
- buttonWidth?: number;
28
+ /** Button width in pixels or percentage */
29
+ buttonWidth?: number | string;
30
+ /** Button height in pixels */
22
31
  buttonHeight?: number;
32
+ /** Whether to show stroke/border around button */
23
33
  hasStroke?: boolean;
34
+ /** Whether the button is enabled */
24
35
  enabled?: boolean;
25
- buttonForm?: 'default' | 'login' | 'signup';
26
- onRejection?: () => void;
27
- onResolved?: (apiUrl: string, token: string, userData: any) => void;
36
+ /** Button form/shape style */
37
+ buttonForm?: 'default' | 'rounded' | 'square';
38
+ /** Callback when user rejects or cancels */
39
+ onRejection?: (reason: string) => void;
40
+ /** Callback when authentication is resolved */
41
+ onResolved?: (apiUrl: string, accessToken: string, data: any) => void;
42
+ /** Function to check before starting authentication */
28
43
  preCheck?: () => Promise<boolean>;
44
+ /** Button background color */
29
45
  color?: string;
46
+ /** Whether to apply a slight rotation effect */
30
47
  swerv?: boolean;
48
+ /** Enable debug mode */
31
49
  debug?: boolean;
50
+ /** Preferred platform for authentication */
32
51
  preferredPlatform?: string;
52
+ /** Enable test mode */
33
53
  testMode?: boolean;
34
54
  }
35
55
 
@@ -110,4 +130,24 @@ declare module '@onairos/react-native' {
110
130
  export class PinInput extends Component<PinInputProps> {}
111
131
  export class TrainingModal extends Component<TrainingModalProps> {}
112
132
  export class OAuthWebView extends Component<OAuthWebViewProps> {}
133
+ }
134
+
135
+ // Fix for Node.js type conflicts
136
+ declare module 'https' {
137
+ interface Server {
138
+ prependListener(event: string, listener: (...args: any[]) => void): this;
139
+ }
140
+ }
141
+
142
+ // Override any problematic Node.js types
143
+ declare module 'node:https' {
144
+ export * from 'https';
145
+ }
146
+
147
+ declare module 'node:http' {
148
+ export * from 'http';
149
+ }
150
+
151
+ declare module 'node:crypto' {
152
+ export * from 'crypto';
113
153
  }
@@ -7,14 +7,16 @@ export interface DataTier {
7
7
  export interface OnairosButtonProps {
8
8
  returnLink?: string;
9
9
  prefillUrl?: string;
10
- AppName: string;
10
+ AppName?: string;
11
11
  buttonType?: 'normal' | 'pill';
12
12
  requestData?: {
13
- Small: DataTier;
14
- Medium: DataTier;
15
- Large: DataTier;
13
+ [key: string]: {
14
+ type: string;
15
+ descriptions: string;
16
+ reward: string;
17
+ };
16
18
  };
17
- buttonWidth?: number;
19
+ buttonWidth?: number | string;
18
20
  buttonHeight?: number;
19
21
  hasStroke?: boolean;
20
22
  enabled?: boolean;
@@ -34,9 +36,11 @@ export interface UniversalOnboardingProps {
34
36
  onClose: () => void;
35
37
  AppName: string;
36
38
  requestData?: {
37
- Small: DataTier;
38
- Medium: DataTier;
39
- Large: DataTier;
39
+ [key: string]: {
40
+ type: string;
41
+ descriptions: string;
42
+ reward: string;
43
+ };
40
44
  };
41
45
  returnLink?: string;
42
46
  onComplete: (apiUrl: string, token: string, userData: any) => void;
@@ -81,6 +85,13 @@ export interface OAuthWebViewProps {
81
85
  onClose: () => void;
82
86
  }
83
87
 
88
+ export interface PlatformConfig {
89
+ name: string;
90
+ icon: string;
91
+ color: string;
92
+ description?: string;
93
+ }
94
+
84
95
  export interface OnairosCredentials {
85
96
  username: string;
86
97
  accessToken?: string;
@@ -106,13 +117,8 @@ export interface OverlayProps {
106
117
  username: string;
107
118
  modelKey: string;
108
119
  onResolved: (apiUrl: string, accessToken: string, loginDetails: any) => void;
109
- }
110
-
111
- export interface PlatformConfig {
112
- name: string;
113
- icon: string;
114
- color: string;
115
- description?: string;
120
+ appName?: string;
121
+ darkMode?: boolean;
116
122
  }
117
123
 
118
124
  export interface BiometricOptions {
@@ -0,0 +1,19 @@
1
+ // Fix for Node.js type conflicts
2
+ declare module 'https' {
3
+ interface Server {
4
+ prependListener(event: string, listener: (...args: any[]) => void): this;
5
+ }
6
+ }
7
+
8
+ // Override any problematic Node.js types
9
+ declare module 'node:https' {
10
+ export * from 'https';
11
+ }
12
+
13
+ declare module 'node:http' {
14
+ export * from 'http';
15
+ }
16
+
17
+ declare module 'node:crypto' {
18
+ export * from 'crypto';
19
+ }
@@ -0,0 +1,24 @@
1
+ // Override for Node.js HTTPS module to fix type errors
2
+ declare module 'node:https' {
3
+ import * as http from 'http';
4
+ import * as tls from 'tls';
5
+
6
+ interface ServerOptions {
7
+ // Define simplified options
8
+ }
9
+
10
+ class Server extends tls.Server {
11
+ // Override problematic methods with any type
12
+ prependListener(event: string, listener: any): this;
13
+ prependOnceListener(event: string, listener: any): this;
14
+ once(event: string, listener: any): this;
15
+ }
16
+
17
+ function createServer(options?: ServerOptions, requestListener?: any): Server;
18
+ function createServer(requestListener?: any): Server;
19
+ }
20
+
21
+ // Also override node:http
22
+ declare module 'node:http' {
23
+ export * from 'http';
24
+ }
@@ -0,0 +1,18 @@
1
+ declare module '@onairos/react-native' {
2
+ import { Component } from 'react';
3
+ import { ViewStyle } from 'react-native';
4
+
5
+ // Re-export all the types from our index.ts
6
+ export * from '../types';
7
+
8
+ // Components
9
+ export class Onairos extends Component<any> {}
10
+ export class OnairosButton extends Component<import('../types').OnairosButtonProps> {}
11
+ export class OnairosOverlay extends Component<import('../types').OverlayProps> {}
12
+ export class UniversalOnboarding extends Component<import('../types').UniversalOnboardingProps> {}
13
+ }
14
+
15
+ // Fix for Node.js type conflicts by providing empty declarations
16
+ declare module 'node:https' {}
17
+ declare module 'node:http' {}
18
+ declare module 'node:crypto' {}
package/src/types.ts CHANGED
@@ -20,10 +20,130 @@ export interface UniversalOnboardingProps {
20
20
  test?: boolean;
21
21
  buttonType?: 'default' | 'pill';
22
22
  buttonForm?: 'signup' | 'login';
23
+ preferredPlatform?: string;
23
24
  }
24
25
 
25
26
  export interface ConnectionStatus {
26
- [key: string]: boolean;
27
+ [key: string]: {
28
+ userName: string;
29
+ connected: boolean;
30
+ };
31
+ }
32
+
33
+ export interface OnairosButtonProps {
34
+ returnLink?: string;
35
+ prefillUrl?: string;
36
+ AppName: string;
37
+ buttonType?: 'normal' | 'pill';
38
+ requestData?: {
39
+ Small: DataTier;
40
+ Medium: DataTier;
41
+ Large: DataTier;
42
+ };
43
+ buttonWidth?: number;
44
+ buttonHeight?: number;
45
+ hasStroke?: boolean;
46
+ enabled?: boolean;
47
+ buttonForm?: 'default' | 'login' | 'signup';
48
+ onRejection?: (error?: string) => void;
49
+ onResolved?: (apiUrl: string, token: string, userData: any) => void;
50
+ preCheck?: () => Promise<boolean>;
51
+ color?: string;
52
+ swerv?: boolean;
53
+ debug?: boolean;
54
+ preferredPlatform?: string;
55
+ testMode?: boolean;
56
+ }
57
+
58
+ export interface PlatformListProps {
59
+ platforms?: string[];
60
+ onSelect?: (platform: string) => void;
61
+ selectedPlatform?: string;
62
+ connections?: ConnectionStatus;
63
+ onToggle?: (platform: string, connect: boolean) => void;
64
+ isLoading?: boolean;
65
+ canProceed?: boolean;
66
+ onProceed?: () => void;
67
+ }
68
+
69
+ export interface PinInputProps {
70
+ onComplete?: (pin: string) => void;
71
+ length?: number;
72
+ secure?: boolean;
73
+ title?: string;
74
+ subtitle?: string;
75
+ verification?: boolean;
76
+ initialPin?: string;
77
+ onSubmit: (pin: string) => void;
78
+ minLength?: number;
79
+ requireSpecialChar?: boolean;
80
+ requireNumber?: boolean;
81
+ }
82
+
83
+ export interface TrainingModalProps {
84
+ visible: boolean;
85
+ onClose: () => void;
86
+ onComplete: () => void;
87
+ modelKey: string;
88
+ username: string;
89
+ progress?: number;
90
+ eta?: string;
91
+ onCancel?: () => void;
92
+ }
93
+
94
+ export interface OAuthWebViewProps {
95
+ url: string;
96
+ onClose: () => void;
97
+ onSuccess: (code: string) => void;
98
+ platform?: string;
99
+ onComplete?: () => void;
100
+ }
101
+
102
+ export interface PlatformConfig {
103
+ name: string;
104
+ icon: string;
105
+ color: string;
106
+ description?: string;
107
+ }
108
+
109
+ export interface ApiResponse<T> {
110
+ success: boolean;
111
+ data?: T;
112
+ error?: string;
113
+ publicKey?: string;
114
+ }
115
+
116
+ export interface CredentialsResult {
117
+ success: boolean;
118
+ credentials?: any;
119
+ error?: string;
120
+ isValid?: boolean;
121
+ }
122
+
123
+ export interface OverlayProps {
124
+ data: {
125
+ [key: string]: {
126
+ type: string;
127
+ descriptions: string;
128
+ reward: string;
129
+ };
130
+ };
131
+ username: string;
132
+ modelKey: string;
133
+ onResolved: (apiUrl: string, accessToken: string, loginDetails: any) => void;
134
+ }
135
+
136
+ export interface BiometricOptions {
137
+ enableBiometrics?: boolean;
138
+ biometricPrompt?: string;
139
+ }
140
+
141
+ export interface PinRequirements {
142
+ minLength: number;
143
+ requireUppercase: boolean;
144
+ requireLowercase: boolean;
145
+ requireNumber: boolean;
146
+ requireSpecialChar: boolean;
27
147
  }
28
148
 
29
149
  // ... rest of the existing types ...
@@ -1,5 +1,6 @@
1
1
  import { onairosApi } from '../api';
2
2
  import RSA from 'react-native-rsa-native';
3
+ import { ApiResponse } from '../types';
3
4
 
4
5
  /**
5
6
  * Encrypt a model key using RSA with a public key
@@ -33,10 +34,14 @@ export const encryptModelKey = (publicKey: string, modelKey: string): string =>
33
34
  */
34
35
  export const getServerPublicKey = async (): Promise<string> => {
35
36
  try {
37
+ // Use the API without generics to prevent TypeScript errors
36
38
  const response = await onairosApi.get('public/getPublicKey');
37
39
 
38
- if (response && response.publicKey) {
39
- return response.publicKey;
40
+ // Check for the public key in the response data
41
+ if (response?.data?.data?.publicKey) {
42
+ return response.data.data.publicKey;
43
+ } else if (response?.data?.publicKey) {
44
+ return response.data.publicKey;
40
45
  } else {
41
46
  throw new Error('No public key found in response');
42
47
  }
@@ -1,4 +1,3 @@
1
- import * as Keychain from 'react-native-keychain';
2
1
  import { Platform } from 'react-native';
3
2
  import { sha256 } from './crypto';
4
3
  import { STORAGE_KEYS } from '../constants';
@@ -20,24 +19,41 @@ export interface OnairosCredentials {
20
19
 
21
20
  export interface StorageOptions {
22
21
  service?: string;
23
- accessControl?: Keychain.ACCESS_CONTROL;
24
- accessible?: Keychain.ACCESSIBLE;
22
+ accessControl?: any;
23
+ accessible?: any;
25
24
  }
26
25
 
27
26
  // Create a mock storage for environments without Keychain access (like Expo Go)
28
27
  const mockStorage: Record<string, { username: string; password: string }> = {};
29
28
 
30
- // Check if running in Expo Go or environments without native module access
29
+ // Try to import Keychain, but provide fallbacks if not available
30
+ let Keychain: any = null;
31
+ try {
32
+ // This import might fail in Expo Go or environments without native modules
33
+ Keychain = require('react-native-keychain');
34
+ } catch (error) {
35
+ console.warn('react-native-keychain module not available, using mock storage');
36
+ // Create minimal mock implementation
37
+ Keychain = {
38
+ ACCESS_CONTROL: { BIOMETRY_ANY_OR_DEVICE_PASSCODE: 'mock' },
39
+ ACCESSIBLE: { WHEN_UNLOCKED: 'mock' },
40
+ getGenericPassword: async () => null,
41
+ setGenericPassword: async () => true,
42
+ resetGenericPassword: async () => true,
43
+ };
44
+ }
45
+
46
+ // Check if Keychain is properly initialized and available
31
47
  const isKeychainAvailable = () => {
32
48
  try {
33
- return typeof Keychain.getGenericPassword === 'function';
49
+ return Keychain && typeof Keychain.getGenericPassword === 'function';
34
50
  } catch (e) {
35
51
  return false;
36
52
  }
37
53
  };
38
54
 
39
55
  // Wrapper for getGenericPassword that falls back to mock storage
40
- const safeGetGenericPassword = async (options: Keychain.Options) => {
56
+ const safeGetGenericPassword = async (options: any) => {
41
57
  try {
42
58
  if (isKeychainAvailable()) {
43
59
  return await Keychain.getGenericPassword(options);
@@ -58,7 +74,7 @@ const safeGetGenericPassword = async (options: Keychain.Options) => {
58
74
  const safeSetGenericPassword = async (
59
75
  username: string,
60
76
  password: string,
61
- options?: Keychain.Options
77
+ options?: any
62
78
  ) => {
63
79
  try {
64
80
  if (isKeychainAvailable()) {
@@ -79,7 +95,7 @@ const safeSetGenericPassword = async (
79
95
  };
80
96
 
81
97
  // Wrapper for resetGenericPassword that falls back to mock storage
82
- const safeResetGenericPassword = async (options?: Keychain.Options) => {
98
+ const safeResetGenericPassword = async (options?: any) => {
83
99
  try {
84
100
  if (isKeychainAvailable()) {
85
101
  return await Keychain.resetGenericPassword(options);
@@ -117,7 +133,7 @@ export const storeCredentials = async (
117
133
  throw new Error('Username is required for storing credentials');
118
134
  }
119
135
 
120
- const options: Keychain.Options = {
136
+ const options: any = {
121
137
  service: STORAGE_KEYS.credentials,
122
138
  };
123
139
 
@@ -0,0 +1,210 @@
1
+ /**
2
+ * Onairos React Native SDK Type Definitions
3
+ *
4
+ * @packageDocumentation
5
+ */
6
+
7
+ import * as React from 'react';
8
+ import { ViewStyle, TextStyle } from 'react-native';
9
+
10
+ /**
11
+ * Data tier configuration for permission requests
12
+ */
13
+ export interface DataTier {
14
+ /** Type label for the data tier */
15
+ type: string;
16
+ /** Description of what this tier includes */
17
+ descriptions: string;
18
+ /** What the user receives for granting this level of access */
19
+ reward: string;
20
+ }
21
+
22
+ /**
23
+ * Onairos API response wrapper
24
+ */
25
+ export interface ApiResponse<T> {
26
+ /** Whether the API call was successful */
27
+ success: boolean;
28
+ /** The data returned from the API (if successful) */
29
+ data?: T;
30
+ /** Error message (if not successful) */
31
+ error?: string;
32
+ }
33
+
34
+ /**
35
+ * Credentials for Onairos authentication
36
+ */
37
+ export interface OnairosCredentials {
38
+ /** User's unique username */
39
+ username: string;
40
+ /** Access token for API requests */
41
+ accessToken?: string;
42
+ /** Refresh token for obtaining new access tokens */
43
+ refreshToken?: string;
44
+ /** User's PIN for local authentication */
45
+ userPin?: string;
46
+ /** Connected platform tokens */
47
+ platforms?: {
48
+ instagram?: { token: string; username: string };
49
+ youtube?: { token: string; username: string };
50
+ pinterest?: { token: string; username: string };
51
+ reddit?: { token: string; username: string };
52
+ };
53
+ /** When the credentials were created */
54
+ createdAt: number;
55
+ }
56
+
57
+ /**
58
+ * Props for the OnairosButton component
59
+ */
60
+ export interface OnairosButtonProps {
61
+ /** The link to return to after OAuth flow completes */
62
+ returnLink?: string;
63
+ /** URL to prefill for authentication */
64
+ prefillUrl?: string;
65
+ /** Your application name */
66
+ AppName: string;
67
+ /** Button style: 'normal' or 'pill' */
68
+ buttonType?: 'normal' | 'pill';
69
+ /** Data request tiers */
70
+ requestData?: {
71
+ Small: DataTier;
72
+ Medium: DataTier;
73
+ Large: DataTier;
74
+ };
75
+ /** Button width in pixels */
76
+ buttonWidth?: number;
77
+ /** Button height in pixels */
78
+ buttonHeight?: number;
79
+ /** Whether to show a stroke around the button */
80
+ hasStroke?: boolean;
81
+ /** Whether the button is enabled */
82
+ enabled?: boolean;
83
+ /** Button form style */
84
+ buttonForm?: 'default' | 'login' | 'signup';
85
+ /** Called when authentication is rejected */
86
+ onRejection?: (error?: string) => void;
87
+ /** Called when authentication is completed successfully */
88
+ onResolved?: (apiUrl: string, token: string, userData: any) => void;
89
+ /** Function to run before starting the authentication flow */
90
+ preCheck?: () => Promise<boolean>;
91
+ /** Button color */
92
+ color?: string;
93
+ /** Whether to slightly rotate the button */
94
+ swerv?: boolean;
95
+ /** Enable debug logging */
96
+ debug?: boolean;
97
+ /** Preferred platform to highlight */
98
+ preferredPlatform?: string;
99
+ /** Whether to use test mode */
100
+ testMode?: boolean;
101
+ }
102
+
103
+ /**
104
+ * Universal onboarding props
105
+ */
106
+ export interface UniversalOnboardingProps {
107
+ visible: boolean;
108
+ onClose: () => void;
109
+ AppName: string;
110
+ requestData?: {
111
+ Small: DataTier;
112
+ Medium: DataTier;
113
+ Large: DataTier;
114
+ };
115
+ returnLink?: string;
116
+ onComplete: (apiUrl: string, token: string, userData: any) => void;
117
+ preferredPlatform?: string;
118
+ debug?: boolean;
119
+ test?: boolean;
120
+ embedd?: boolean;
121
+ }
122
+
123
+ /**
124
+ * Overlay props
125
+ */
126
+ export interface OverlayProps {
127
+ data: {
128
+ [key: string]: {
129
+ type: string;
130
+ descriptions: string;
131
+ reward: string;
132
+ };
133
+ };
134
+ username: string;
135
+ modelKey: string;
136
+ onResolved: (apiUrl: string, accessToken: string, loginDetails: any) => void;
137
+ }
138
+
139
+ /**
140
+ * OAuth Configuration
141
+ */
142
+ export interface OAuthConfig {
143
+ clientId: string;
144
+ redirectUri: string;
145
+ scope: string;
146
+ authorizationEndpoint: string;
147
+ tokenEndpoint: string;
148
+ responseType: string;
149
+ }
150
+
151
+ /** Platform configuration type */
152
+ export interface PlatformConfig {
153
+ name: string;
154
+ icon: string;
155
+ color: string;
156
+ description?: string;
157
+ }
158
+
159
+ // Main components
160
+ export const Onairos: React.ComponentType<OnairosButtonProps>;
161
+ export const OnairosButton: React.ComponentType<OnairosButtonProps>;
162
+ export const OnairosOverlay: React.ComponentType<OverlayProps>;
163
+ export const UniversalOnboarding: React.ComponentType<UniversalOnboardingProps>;
164
+
165
+ // Utility functions
166
+ export function initializeOAuthService(): void;
167
+ export function cleanupOAuthService(): void;
168
+ export function storeCredentials(credentials: Partial<OnairosCredentials>, options?: any): Promise<boolean>;
169
+ export function getCredentials(options?: any): Promise<OnairosCredentials | null>;
170
+ export function hasCredentials(): Promise<boolean>;
171
+ export function deleteCredentials(): Promise<boolean>;
172
+ export function updateCredentials(updates: Partial<OnairosCredentials>): Promise<boolean>;
173
+ export function generateDeviceUsername(): string;
174
+ export function verifyCredentials(credentials: OnairosCredentials): Promise<boolean>;
175
+
176
+ // Service functions
177
+ export function connectPlatform(platform: string): Promise<any>;
178
+ export function disconnectPlatform(platform: string, credentials: OnairosCredentials): Promise<boolean>;
179
+ export function storePlatformConnection(platform: string, connectionData: any, credentials: OnairosCredentials): Promise<boolean>;
180
+
181
+ // Export constants
182
+ export const COLORS: Record<string, string>;
183
+ export const PLATFORMS: Record<string, PlatformConfig>;
184
+ export const API_ENDPOINTS: {
185
+ base: string;
186
+ oauth: Record<string, string>;
187
+ callback: Record<string, string>;
188
+ };
189
+ export const STORAGE_KEYS: Record<string, string>;
190
+ export const PIN_REQUIREMENTS: {
191
+ minLength: number;
192
+ requireUppercase: boolean;
193
+ requireLowercase: boolean;
194
+ requireNumber: boolean;
195
+ requireSpecialChar: boolean;
196
+ };
197
+ export const DEEP_LINK_CONFIG: {
198
+ scheme: string;
199
+ host: string;
200
+ };
201
+
202
+ // Default export
203
+ declare const _default: {
204
+ Onairos: typeof Onairos;
205
+ OnairosButton: typeof OnairosButton;
206
+ OnairosOverlay: typeof OnairosOverlay;
207
+ UniversalOnboarding: typeof UniversalOnboarding;
208
+ };
209
+
210
+ export default _default;