@onairos/react-native 3.0.72 → 3.0.74
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/lib/commonjs/components/Onairos.js.map +1 -1
- package/lib/commonjs/index.js +23 -504
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/services/apiKeyService.js +93 -14
- package/lib/commonjs/services/apiKeyService.js.map +1 -1
- package/lib/commonjs/services/platformAuthService.js +224 -9
- package/lib/commonjs/services/platformAuthService.js.map +1 -1
- package/lib/commonjs/types/index.js +4 -0
- package/lib/commonjs/types.js +12 -0
- package/lib/commonjs/types.js.map +1 -1
- package/lib/commonjs/utils/programmaticFlow.js +117 -0
- package/lib/commonjs/utils/programmaticFlow.js.map +1 -0
- package/lib/module/components/Onairos.js.map +1 -1
- package/lib/module/index.js +17 -64
- package/lib/module/index.js.map +1 -1
- package/lib/module/services/apiKeyService.js +90 -11
- package/lib/module/services/apiKeyService.js.map +1 -1
- package/lib/module/services/platformAuthService.js +218 -8
- package/lib/module/services/platformAuthService.js.map +1 -1
- package/lib/module/types/index.js +1 -1
- package/lib/module/types.js +8 -0
- package/lib/module/types.js.map +1 -1
- package/lib/module/utils/programmaticFlow.js +111 -0
- package/lib/module/utils/programmaticFlow.js.map +1 -0
- package/lib/typescript/components/Onairos.d.ts +1 -29
- package/lib/typescript/components/Onairos.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +10 -40
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/services/apiKeyService.d.ts +18 -0
- package/lib/typescript/services/apiKeyService.d.ts.map +1 -1
- package/lib/typescript/services/platformAuthService.d.ts +26 -0
- package/lib/typescript/services/platformAuthService.d.ts.map +1 -1
- package/lib/typescript/types/index.d.ts +144 -78
- package/lib/typescript/types/index.d.ts.map +1 -1
- package/lib/typescript/types.d.ts +56 -0
- package/lib/typescript/types.d.ts.map +1 -1
- package/lib/typescript/utils/programmaticFlow.d.ts +23 -0
- package/lib/typescript/utils/programmaticFlow.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/components/Onairos.tsx +1 -30
- package/src/index.ts +23 -132
- package/src/services/apiKeyService.ts +84 -8
- package/src/services/platformAuthService.ts +260 -4
- package/src/types/index.d.ts +110 -0
- package/src/types/index.ts +148 -74
- package/src/types.ts +59 -0
- package/src/utils/programmaticFlow.ts +113 -0
package/src/types/index.d.ts
CHANGED
|
@@ -53,6 +53,57 @@ declare module '@onairos/react-native' {
|
|
|
53
53
|
testMode?: boolean;
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
+
export interface OnairosProps {
|
|
57
|
+
/** Return link after authentication (used for web-based flows) */
|
|
58
|
+
returnLink?: string;
|
|
59
|
+
/** Prefill URL for the authentication process */
|
|
60
|
+
prefillUrl?: string;
|
|
61
|
+
/** Application name to display in dialogs */
|
|
62
|
+
AppName: string;
|
|
63
|
+
/** Button type - 'normal' or 'pill' */
|
|
64
|
+
buttonType?: 'normal' | 'pill';
|
|
65
|
+
/** Data requests for user consent */
|
|
66
|
+
requestData?: {
|
|
67
|
+
[key: string]: DataTier;
|
|
68
|
+
};
|
|
69
|
+
/** Button width in pixels */
|
|
70
|
+
buttonWidth?: number;
|
|
71
|
+
/** Button height in pixels */
|
|
72
|
+
buttonHeight?: number;
|
|
73
|
+
/** Whether to show stroke/border around button */
|
|
74
|
+
hasStroke?: boolean;
|
|
75
|
+
/** Whether the button is enabled */
|
|
76
|
+
enabled?: boolean;
|
|
77
|
+
/** Button form/shape style */
|
|
78
|
+
buttonForm?: 'default' | 'connect';
|
|
79
|
+
/** Callback when user rejects or cancels */
|
|
80
|
+
onRejection?: (error?: string) => void;
|
|
81
|
+
/** Callback when authentication is resolved */
|
|
82
|
+
onResolved?: (apiUrl: string, token: string, userData: any) => void;
|
|
83
|
+
/** Function to check before starting authentication */
|
|
84
|
+
preCheck?: () => Promise<boolean>;
|
|
85
|
+
/** Button background color */
|
|
86
|
+
color?: string;
|
|
87
|
+
/** Enable debug mode */
|
|
88
|
+
debug?: boolean;
|
|
89
|
+
/** Enable dark mode */
|
|
90
|
+
darkMode?: boolean;
|
|
91
|
+
/** Preferred platform for authentication */
|
|
92
|
+
preferredPlatform?: string;
|
|
93
|
+
/** Enable test mode */
|
|
94
|
+
testMode?: boolean;
|
|
95
|
+
/** API Key Configuration (REQUIRED) */
|
|
96
|
+
apiKey: string;
|
|
97
|
+
/** Environment setting for API calls */
|
|
98
|
+
environment?: 'production' | 'staging' | 'development';
|
|
99
|
+
/** Enable logging for debugging */
|
|
100
|
+
enableLogging?: boolean;
|
|
101
|
+
/** Request timeout in milliseconds */
|
|
102
|
+
timeout?: number;
|
|
103
|
+
/** Number of retry attempts for failed requests */
|
|
104
|
+
retryAttempts?: number;
|
|
105
|
+
}
|
|
106
|
+
|
|
56
107
|
export interface UniversalOnboardingProps {
|
|
57
108
|
visible: boolean;
|
|
58
109
|
onClose: () => void;
|
|
@@ -129,12 +180,71 @@ declare module '@onairos/react-native' {
|
|
|
129
180
|
error?: string;
|
|
130
181
|
}
|
|
131
182
|
|
|
183
|
+
// Authentication & PIN Management Types
|
|
184
|
+
export interface EmailVerificationResult {
|
|
185
|
+
success: boolean;
|
|
186
|
+
message?: string;
|
|
187
|
+
error?: string;
|
|
188
|
+
existingUser?: boolean;
|
|
189
|
+
jwtToken?: string;
|
|
190
|
+
requestId?: string;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
export interface PinStorageResult {
|
|
194
|
+
success: boolean;
|
|
195
|
+
message?: string;
|
|
196
|
+
error?: string;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export interface EmailVerificationStatusResult {
|
|
200
|
+
success: boolean;
|
|
201
|
+
isPending?: boolean;
|
|
202
|
+
message?: string;
|
|
203
|
+
error?: string;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// Component Classes
|
|
132
207
|
export class OnairosButton extends Component<OnairosButtonProps> {}
|
|
208
|
+
export class Onairos extends Component<OnairosProps> {}
|
|
133
209
|
export class UniversalOnboarding extends Component<UniversalOnboardingProps> {}
|
|
134
210
|
export class PlatformList extends Component<PlatformListProps> {}
|
|
135
211
|
export class PinInput extends Component<PinInputProps> {}
|
|
136
212
|
export class TrainingModal extends Component<TrainingModalProps> {}
|
|
137
213
|
export class OAuthWebView extends Component<OAuthWebViewProps> {}
|
|
214
|
+
|
|
215
|
+
// Authentication & PIN Management Functions
|
|
216
|
+
export function storePinAfterBiometric(
|
|
217
|
+
username: string,
|
|
218
|
+
pin: string,
|
|
219
|
+
jwtToken?: string
|
|
220
|
+
): Promise<PinStorageResult>;
|
|
221
|
+
|
|
222
|
+
export function getStoredJwtToken(): Promise<string | null>;
|
|
223
|
+
|
|
224
|
+
export function clearStoredTokens(): Promise<void>;
|
|
225
|
+
|
|
226
|
+
export function requestEmailVerification(
|
|
227
|
+
email: string,
|
|
228
|
+
testMode?: boolean
|
|
229
|
+
): Promise<EmailVerificationResult>;
|
|
230
|
+
|
|
231
|
+
export function verifyEmailCode(
|
|
232
|
+
email: string,
|
|
233
|
+
code: string,
|
|
234
|
+
testMode?: boolean
|
|
235
|
+
): Promise<EmailVerificationResult>;
|
|
236
|
+
|
|
237
|
+
export function checkEmailVerificationStatus(
|
|
238
|
+
email: string,
|
|
239
|
+
testMode?: boolean
|
|
240
|
+
): Promise<EmailVerificationStatusResult>;
|
|
241
|
+
|
|
242
|
+
// SDK Initialization Functions
|
|
243
|
+
export function initializeApiKey(config: any): Promise<void>;
|
|
244
|
+
export const ADMIN_API_KEY: string;
|
|
245
|
+
|
|
246
|
+
// Programmatic Flow
|
|
247
|
+
export function executeOnairosFlow(config: any): Promise<any>;
|
|
138
248
|
}
|
|
139
249
|
|
|
140
250
|
// Fix for Node.js type conflicts
|
package/src/types/index.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { ViewStyle, TextStyle } from 'react-native';
|
|
2
|
+
import { Component } from 'react';
|
|
3
|
+
|
|
1
4
|
export interface DataTier {
|
|
2
5
|
type: string;
|
|
3
6
|
descriptions: string;
|
|
@@ -5,72 +8,137 @@ export interface DataTier {
|
|
|
5
8
|
}
|
|
6
9
|
|
|
7
10
|
export interface OnairosButtonProps {
|
|
8
|
-
|
|
9
|
-
requestData: {
|
|
10
|
-
[key: string]: {
|
|
11
|
-
type: string;
|
|
12
|
-
descriptions: string;
|
|
13
|
-
reward: string;
|
|
14
|
-
};
|
|
15
|
-
};
|
|
11
|
+
/** Return link after authentication (used for web-based flows) */
|
|
16
12
|
returnLink?: string;
|
|
13
|
+
/** Prefill URL for the authentication process */
|
|
17
14
|
prefillUrl?: string;
|
|
15
|
+
/** Application name to display in dialogs */
|
|
16
|
+
AppName?: string;
|
|
17
|
+
/** Button type - 'normal' or 'pill' */
|
|
18
18
|
buttonType?: 'normal' | 'pill';
|
|
19
|
+
/** Data requests for user consent */
|
|
20
|
+
requestData?: {
|
|
21
|
+
[key: string]: DataTier;
|
|
22
|
+
};
|
|
23
|
+
/** Button width in pixels or percentage */
|
|
19
24
|
buttonWidth?: number | string;
|
|
25
|
+
/** Button height in pixels */
|
|
20
26
|
buttonHeight?: number;
|
|
27
|
+
/** Whether to show stroke/border around button */
|
|
21
28
|
hasStroke?: boolean;
|
|
29
|
+
/** Whether the button is enabled */
|
|
22
30
|
enabled?: boolean;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
31
|
+
/** Button form/shape style */
|
|
32
|
+
buttonForm?: 'default' | 'rounded' | 'square' | 'connect';
|
|
33
|
+
/** Callback when user rejects or cancels */
|
|
34
|
+
onRejection?: (reason?: string) => void;
|
|
35
|
+
/** Callback when authentication is resolved */
|
|
36
|
+
onResolved?: (apiUrl: string, accessToken: string, data: any) => void;
|
|
37
|
+
/** Function to check before starting authentication */
|
|
27
38
|
preCheck?: () => Promise<boolean>;
|
|
39
|
+
/** Button background color */
|
|
28
40
|
color?: string;
|
|
41
|
+
/** Whether to apply a slight rotation effect */
|
|
29
42
|
swerv?: boolean;
|
|
43
|
+
/** Enable debug mode */
|
|
30
44
|
debug?: boolean;
|
|
45
|
+
/** Preferred platform for authentication */
|
|
31
46
|
preferredPlatform?: string;
|
|
47
|
+
/** Enable test mode */
|
|
32
48
|
testMode?: boolean;
|
|
49
|
+
/** Enable dark mode */
|
|
33
50
|
darkMode?: boolean;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
51
|
+
/** Enable automatic API calls */
|
|
52
|
+
auto?: boolean;
|
|
53
|
+
/** App icon to display */
|
|
54
|
+
appIcon?: any;
|
|
55
|
+
/** Flow 2: New User (Email → Code → Platform Connect → PIN → Training → Complete) */
|
|
39
56
|
newUser?: boolean; // Flow 2: Email → Code → Platform Connect → PIN → Training → Complete
|
|
40
|
-
|
|
41
|
-
//
|
|
57
|
+
/** Flow 3: Existing User (Email → Code → Data Request → Complete) */
|
|
58
|
+
existingUser?: boolean; // Flow 3: Existing User (Email → Code → Data Request → Complete)
|
|
42
59
|
fastTraining?: boolean; // Speed up training simulation
|
|
43
|
-
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface OnairosProps {
|
|
63
|
+
/** Return link after authentication (used for web-based flows) */
|
|
64
|
+
returnLink?: string;
|
|
65
|
+
/** Prefill URL for the authentication process */
|
|
66
|
+
prefillUrl?: string;
|
|
67
|
+
/** Application name to display in dialogs */
|
|
68
|
+
AppName: string;
|
|
69
|
+
/** Button type - 'normal' or 'pill' */
|
|
70
|
+
buttonType?: 'normal' | 'pill';
|
|
71
|
+
/** Data requests for user consent */
|
|
72
|
+
requestData?: {
|
|
73
|
+
[key: string]: DataTier;
|
|
74
|
+
};
|
|
75
|
+
/** Button width in pixels */
|
|
76
|
+
buttonWidth?: number;
|
|
77
|
+
/** Button height in pixels */
|
|
78
|
+
buttonHeight?: number;
|
|
79
|
+
/** Whether to show stroke/border around button */
|
|
80
|
+
hasStroke?: boolean;
|
|
81
|
+
/** Whether the button is enabled */
|
|
82
|
+
enabled?: boolean;
|
|
83
|
+
/** Button form/shape style */
|
|
84
|
+
buttonForm?: 'default' | 'connect';
|
|
85
|
+
/** Callback when user rejects or cancels */
|
|
86
|
+
onRejection?: (error?: string) => void;
|
|
87
|
+
/** Callback when authentication is resolved */
|
|
88
|
+
onResolved?: (apiUrl: string, token: string, userData: any) => void;
|
|
89
|
+
/** Function to check before starting authentication */
|
|
90
|
+
preCheck?: () => Promise<boolean>;
|
|
91
|
+
/** Button background color */
|
|
92
|
+
color?: string;
|
|
93
|
+
/** Enable debug mode */
|
|
94
|
+
debug?: boolean;
|
|
95
|
+
/** Enable dark mode */
|
|
96
|
+
darkMode?: boolean;
|
|
97
|
+
/** Preferred platform for authentication */
|
|
98
|
+
preferredPlatform?: string;
|
|
99
|
+
/** Enable test mode */
|
|
100
|
+
testMode?: boolean;
|
|
101
|
+
/** API Key Configuration (REQUIRED) */
|
|
102
|
+
apiKey: string;
|
|
103
|
+
/** Environment setting for API calls */
|
|
104
|
+
environment?: 'production' | 'staging' | 'development';
|
|
105
|
+
/** Enable logging for debugging */
|
|
106
|
+
enableLogging?: boolean;
|
|
107
|
+
/** Request timeout in milliseconds */
|
|
108
|
+
timeout?: number;
|
|
109
|
+
/** Number of retry attempts for failed requests */
|
|
110
|
+
retryAttempts?: number;
|
|
44
111
|
}
|
|
45
112
|
|
|
46
113
|
export interface UniversalOnboardingProps {
|
|
47
114
|
visible: boolean;
|
|
48
115
|
onClose: () => void;
|
|
49
116
|
AppName: string;
|
|
117
|
+
appIcon?: any;
|
|
50
118
|
requestData?: {
|
|
51
|
-
[key: string]:
|
|
52
|
-
type: string;
|
|
53
|
-
descriptions: string;
|
|
54
|
-
reward: string;
|
|
55
|
-
};
|
|
119
|
+
[key: string]: DataTier;
|
|
56
120
|
};
|
|
57
121
|
returnLink?: string;
|
|
58
122
|
onComplete: (apiUrl: string, token: string, userData: any) => void;
|
|
59
123
|
preferredPlatform?: string;
|
|
60
124
|
debug?: boolean;
|
|
61
|
-
|
|
125
|
+
testMode?: boolean;
|
|
62
126
|
embedd?: boolean;
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
127
|
+
/** Flow 2: New User (Email → Code → Platform Connect → PIN → Training → Complete) */
|
|
128
|
+
newUser?: boolean; // Flow 2: Email → Code → Platform Connect → PIN → Training → Complete
|
|
129
|
+
/** Flow 3: Existing User (Email → Code → Data Request → Complete) */
|
|
130
|
+
existingUser?: boolean; // Flow 3: Existing User (Email → Code → Data Request → Complete)
|
|
131
|
+
fastTraining?: boolean; // Speed up training simulation
|
|
132
|
+
/** Inference data for auto mode */
|
|
133
|
+
inferenceData?: any;
|
|
134
|
+
/** Auto mode for direct API calls */
|
|
135
|
+
auto?: boolean;
|
|
136
|
+
/** Partner integration */
|
|
137
|
+
partner?: string;
|
|
70
138
|
}
|
|
71
139
|
|
|
72
140
|
export interface PlatformListProps {
|
|
73
|
-
connections:
|
|
141
|
+
connections: { [key: string]: boolean };
|
|
74
142
|
onToggle: (platform: string, connect: boolean) => Promise<void>;
|
|
75
143
|
isLoading: boolean;
|
|
76
144
|
canProceed: boolean;
|
|
@@ -82,7 +150,7 @@ export interface PinInputProps {
|
|
|
82
150
|
minLength?: number;
|
|
83
151
|
requireSpecialChar?: boolean;
|
|
84
152
|
requireNumber?: boolean;
|
|
85
|
-
|
|
153
|
+
initialPin?: string;
|
|
86
154
|
}
|
|
87
155
|
|
|
88
156
|
export interface TrainingModalProps {
|
|
@@ -103,6 +171,27 @@ export interface OAuthWebViewProps {
|
|
|
103
171
|
onClose: () => void;
|
|
104
172
|
}
|
|
105
173
|
|
|
174
|
+
export interface CredentialsResult {
|
|
175
|
+
isValid: boolean;
|
|
176
|
+
credentials?: {
|
|
177
|
+
username?: string;
|
|
178
|
+
userPin?: string;
|
|
179
|
+
accessToken?: string;
|
|
180
|
+
pinterest?: { token: string; username: string };
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export interface OverlayProps {
|
|
185
|
+
visible: boolean;
|
|
186
|
+
onClose: () => void;
|
|
187
|
+
credentials: any;
|
|
188
|
+
onDeleteCredentials: () => void;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export interface ConnectionStatus {
|
|
192
|
+
[key: string]: boolean;
|
|
193
|
+
}
|
|
194
|
+
|
|
106
195
|
export interface PlatformConfig {
|
|
107
196
|
name: string;
|
|
108
197
|
icon: string;
|
|
@@ -110,40 +199,21 @@ export interface PlatformConfig {
|
|
|
110
199
|
description?: string;
|
|
111
200
|
}
|
|
112
201
|
|
|
113
|
-
export interface
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
userPin?: string;
|
|
118
|
-
platforms?: {
|
|
119
|
-
instagram?: { token: string; username: string };
|
|
120
|
-
youtube?: { token: string; username: string };
|
|
121
|
-
pinterest?: { token: string; username: string };
|
|
122
|
-
reddit?: { token: string; username: string };
|
|
123
|
-
};
|
|
124
|
-
createdAt: number;
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
export interface OverlayProps {
|
|
128
|
-
data: {
|
|
129
|
-
[key: string]: {
|
|
130
|
-
type: string;
|
|
131
|
-
descriptions: string;
|
|
132
|
-
reward: string;
|
|
133
|
-
};
|
|
134
|
-
};
|
|
135
|
-
username: string;
|
|
136
|
-
modelKey: string;
|
|
137
|
-
onResolved: (apiUrl: string, accessToken: string, loginDetails: any) => void;
|
|
138
|
-
appName?: string;
|
|
139
|
-
darkMode?: boolean;
|
|
202
|
+
export interface ApiResponse<T> {
|
|
203
|
+
success: boolean;
|
|
204
|
+
data?: T;
|
|
205
|
+
error?: string;
|
|
140
206
|
}
|
|
141
207
|
|
|
142
|
-
export interface
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
208
|
+
export interface PlatformAuthConfig {
|
|
209
|
+
hasNativeSDK: boolean;
|
|
210
|
+
nativeSDKPackage?: string;
|
|
211
|
+
authEndpoint: string;
|
|
212
|
+
color: string;
|
|
213
|
+
clientId?: string;
|
|
214
|
+
redirectUri?: string;
|
|
215
|
+
scope?: string;
|
|
216
|
+
responseType?: string;
|
|
147
217
|
}
|
|
148
218
|
|
|
149
219
|
export interface PinRequirements {
|
|
@@ -152,13 +222,17 @@ export interface PinRequirements {
|
|
|
152
222
|
requireNumber: boolean;
|
|
153
223
|
}
|
|
154
224
|
|
|
155
|
-
export interface
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
225
|
+
export interface OnairosConfig {
|
|
226
|
+
apiKey: string;
|
|
227
|
+
environment?: 'production' | 'staging' | 'development';
|
|
228
|
+
enableLogging?: boolean;
|
|
229
|
+
timeout?: number;
|
|
230
|
+
retryAttempts?: number;
|
|
159
231
|
}
|
|
160
232
|
|
|
161
|
-
export interface
|
|
162
|
-
|
|
163
|
-
|
|
233
|
+
export interface TestModeOptions {
|
|
234
|
+
skipEmailVerification?: boolean;
|
|
235
|
+
mockApiResponses?: boolean;
|
|
236
|
+
simulateTraining?: boolean;
|
|
237
|
+
enableDebugLogs?: boolean;
|
|
164
238
|
}
|
package/src/types.ts
CHANGED
|
@@ -26,6 +26,13 @@ export interface ApiKeyConfig {
|
|
|
26
26
|
enableLogging?: boolean;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
// API key types
|
|
30
|
+
export enum ApiKeyType {
|
|
31
|
+
DEVELOPER = 'developer',
|
|
32
|
+
ADMIN = 'admin',
|
|
33
|
+
INVALID = 'invalid'
|
|
34
|
+
}
|
|
35
|
+
|
|
29
36
|
export interface ApiKeyValidationResult {
|
|
30
37
|
isValid: boolean;
|
|
31
38
|
error?: string;
|
|
@@ -34,6 +41,7 @@ export interface ApiKeyValidationResult {
|
|
|
34
41
|
remaining: number;
|
|
35
42
|
resetTime: number;
|
|
36
43
|
};
|
|
44
|
+
keyType?: ApiKeyType;
|
|
37
45
|
}
|
|
38
46
|
|
|
39
47
|
export interface OnairosConfig {
|
|
@@ -44,6 +52,57 @@ export interface OnairosConfig {
|
|
|
44
52
|
retryAttempts?: number;
|
|
45
53
|
}
|
|
46
54
|
|
|
55
|
+
export interface OnairosProps {
|
|
56
|
+
/** Return link after authentication (used for web-based flows) */
|
|
57
|
+
returnLink?: string;
|
|
58
|
+
/** Prefill URL for the authentication process */
|
|
59
|
+
prefillUrl?: string;
|
|
60
|
+
/** Application name to display in dialogs */
|
|
61
|
+
AppName: string;
|
|
62
|
+
/** Button type - 'normal' or 'pill' */
|
|
63
|
+
buttonType?: 'normal' | 'pill';
|
|
64
|
+
/** Data requests for user consent */
|
|
65
|
+
requestData?: {
|
|
66
|
+
[key: string]: DataTier;
|
|
67
|
+
};
|
|
68
|
+
/** Button width in pixels */
|
|
69
|
+
buttonWidth?: number;
|
|
70
|
+
/** Button height in pixels */
|
|
71
|
+
buttonHeight?: number;
|
|
72
|
+
/** Whether to show stroke/border around button */
|
|
73
|
+
hasStroke?: boolean;
|
|
74
|
+
/** Whether the button is enabled */
|
|
75
|
+
enabled?: boolean;
|
|
76
|
+
/** Button form/shape style */
|
|
77
|
+
buttonForm?: 'default' | 'connect';
|
|
78
|
+
/** Callback when user rejects or cancels */
|
|
79
|
+
onRejection?: (error?: string) => void;
|
|
80
|
+
/** Callback when authentication is resolved */
|
|
81
|
+
onResolved?: (apiUrl: string, token: string, userData: any) => void;
|
|
82
|
+
/** Function to check before starting authentication */
|
|
83
|
+
preCheck?: () => Promise<boolean>;
|
|
84
|
+
/** Button background color */
|
|
85
|
+
color?: string;
|
|
86
|
+
/** Enable debug mode */
|
|
87
|
+
debug?: boolean;
|
|
88
|
+
/** Enable dark mode */
|
|
89
|
+
darkMode?: boolean;
|
|
90
|
+
/** Preferred platform for authentication */
|
|
91
|
+
preferredPlatform?: string;
|
|
92
|
+
/** Enable test mode */
|
|
93
|
+
testMode?: boolean;
|
|
94
|
+
/** API Key Configuration (REQUIRED) */
|
|
95
|
+
apiKey: string;
|
|
96
|
+
/** Environment setting for API calls */
|
|
97
|
+
environment?: 'production' | 'staging' | 'development';
|
|
98
|
+
/** Enable logging for debugging */
|
|
99
|
+
enableLogging?: boolean;
|
|
100
|
+
/** Request timeout in milliseconds */
|
|
101
|
+
timeout?: number;
|
|
102
|
+
/** Number of retry attempts for failed requests */
|
|
103
|
+
retryAttempts?: number;
|
|
104
|
+
}
|
|
105
|
+
|
|
47
106
|
export interface UniversalOnboardingProps {
|
|
48
107
|
visible: boolean;
|
|
49
108
|
onClose: (result?: any) => void;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Programmatic Onairos Flow
|
|
3
|
+
*
|
|
4
|
+
* This function executes the complete Onairos authentication and onboarding flow
|
|
5
|
+
* that can be attached to custom buttons or called programmatically.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { OnairosButtonProps } from '../types';
|
|
9
|
+
import { initializePlatformAuthService } from '../services/platformAuthService';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Execute the complete Onairos flow programmatically
|
|
13
|
+
* This is the same logic that the OnairosButton uses internally
|
|
14
|
+
*
|
|
15
|
+
* @param options Configuration options for the flow
|
|
16
|
+
* @returns Promise that resolves when flow is complete
|
|
17
|
+
*/
|
|
18
|
+
export const executeOnairosFlow = async (options: OnairosButtonProps): Promise<void> => {
|
|
19
|
+
try {
|
|
20
|
+
console.log('🚀 Starting Onairos flow programmatically...');
|
|
21
|
+
|
|
22
|
+
// Initialize API key service if not already initialized
|
|
23
|
+
await initializePlatformAuthService();
|
|
24
|
+
|
|
25
|
+
// Import components dynamically to avoid circular dependencies
|
|
26
|
+
const { UniversalOnboarding } = await import('../components/UniversalOnboarding');
|
|
27
|
+
const React = await import('react');
|
|
28
|
+
|
|
29
|
+
// Create a promise that resolves when the flow is complete
|
|
30
|
+
return new Promise((resolve, reject) => {
|
|
31
|
+
let modalRef: any = null;
|
|
32
|
+
|
|
33
|
+
const handleComplete = (apiUrl: string, token: string, userData: any) => {
|
|
34
|
+
console.log('✅ Onairos flow completed successfully');
|
|
35
|
+
|
|
36
|
+
// Clean up modal
|
|
37
|
+
if (modalRef && modalRef.close) {
|
|
38
|
+
modalRef.close();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Call user's onResolved callback
|
|
42
|
+
if (options.onResolved) {
|
|
43
|
+
options.onResolved(apiUrl, token, userData);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
resolve();
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const handleRejection = (error?: string) => {
|
|
50
|
+
console.log('❌ Onairos flow rejected:', error);
|
|
51
|
+
|
|
52
|
+
// Clean up modal
|
|
53
|
+
if (modalRef && modalRef.close) {
|
|
54
|
+
modalRef.close();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Call user's onRejection callback
|
|
58
|
+
if (options.onRejection) {
|
|
59
|
+
options.onRejection(error);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
reject(new Error(error || 'Onairos flow was rejected'));
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
// Create and show the Universal Onboarding modal
|
|
66
|
+
const modalElement = React.createElement(UniversalOnboarding, {
|
|
67
|
+
visible: true,
|
|
68
|
+
onClose: () => handleRejection('User closed the modal'),
|
|
69
|
+
AppName: options.AppName,
|
|
70
|
+
requestData: options.requestData,
|
|
71
|
+
returnLink: options.returnLink,
|
|
72
|
+
onComplete: handleComplete,
|
|
73
|
+
preferredPlatform: options.preferredPlatform,
|
|
74
|
+
debug: options.debug,
|
|
75
|
+
testMode: options.testMode,
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
// Store modal reference for cleanup
|
|
79
|
+
modalRef = modalElement;
|
|
80
|
+
|
|
81
|
+
// Note: In a real implementation, you'd need to render this modal
|
|
82
|
+
// This is a simplified version - the actual implementation would
|
|
83
|
+
// need to handle React rendering in the current app context
|
|
84
|
+
console.log('📱 Onairos modal should be displayed');
|
|
85
|
+
});
|
|
86
|
+
} catch (error) {
|
|
87
|
+
console.error('❌ Failed to execute Onairos flow:', error);
|
|
88
|
+
throw error;
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Simple wrapper function that matches the OnairosButton click behavior
|
|
94
|
+
*
|
|
95
|
+
* @param options Configuration options for the flow
|
|
96
|
+
* @returns Promise that resolves when flow is complete
|
|
97
|
+
*/
|
|
98
|
+
export const startOnairosFlow = async (options: OnairosButtonProps): Promise<void> => {
|
|
99
|
+
// Pre-check if provided
|
|
100
|
+
if (options.preCheck) {
|
|
101
|
+
const canProceed = await options.preCheck();
|
|
102
|
+
if (!canProceed) {
|
|
103
|
+
console.log('❌ Pre-check failed, not starting Onairos flow');
|
|
104
|
+
if (options.onRejection) {
|
|
105
|
+
options.onRejection('Pre-check failed');
|
|
106
|
+
}
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Execute the flow
|
|
112
|
+
return executeOnairosFlow(options);
|
|
113
|
+
};
|