@onairos/react-native 3.0.1 → 3.0.4
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 +23 -3
- package/lib/commonjs/api/index.js +109 -86
- package/lib/commonjs/api/index.js.map +1 -1
- package/lib/commonjs/components/OnairosButton.js +20 -13
- package/lib/commonjs/components/OnairosButton.js.map +1 -1
- package/lib/commonjs/components/Overlay.js +260 -108
- package/lib/commonjs/components/Overlay.js.map +1 -1
- package/lib/commonjs/components/UniversalOnboarding.js +30 -0
- package/lib/commonjs/components/UniversalOnboarding.js.map +1 -1
- package/lib/commonjs/components/onboarding/OAuthWebView.js +28 -9
- package/lib/commonjs/components/onboarding/OAuthWebView.js.map +1 -1
- package/lib/commonjs/components/onboarding/PlatformConnector.js +6 -1
- package/lib/commonjs/components/onboarding/PlatformConnector.js.map +1 -1
- package/lib/commonjs/components/screens/ConnectorScreen.js +3 -2
- package/lib/commonjs/components/screens/ConnectorScreen.js.map +1 -1
- package/lib/commonjs/constants/index.js +1 -1
- package/lib/commonjs/hooks/useConnections.js +77 -15
- package/lib/commonjs/hooks/useConnections.js.map +1 -1
- package/lib/commonjs/hooks/useCredentials.js +2 -0
- package/lib/commonjs/hooks/useCredentials.js.map +1 -1
- package/lib/commonjs/index.js +38 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/services/oauthService.js +26 -51
- package/lib/commonjs/services/oauthService.js.map +1 -1
- package/lib/commonjs/types/ambient.d.js +2 -0
- package/lib/commonjs/types/ambient.d.js.map +1 -0
- package/lib/commonjs/types/node-fix.d.js +2 -0
- package/lib/commonjs/types/node-fix.d.js.map +1 -0
- package/lib/commonjs/types/node-override.d.js +2 -0
- package/lib/commonjs/types/node-override.d.js.map +1 -0
- package/lib/commonjs/types/types.d.js +2 -0
- package/lib/commonjs/types/types.d.js.map +1 -0
- package/lib/commonjs/utils/encryption.js +8 -2
- package/lib/commonjs/utils/encryption.js.map +1 -1
- package/lib/commonjs/utils/secureStorage.js +148 -42
- package/lib/commonjs/utils/secureStorage.js.map +1 -1
- package/lib/module/api/index.js +109 -86
- package/lib/module/api/index.js.map +1 -1
- package/lib/module/components/OnairosButton.js +21 -14
- package/lib/module/components/OnairosButton.js.map +1 -1
- package/lib/module/components/Overlay.js +260 -110
- package/lib/module/components/Overlay.js.map +1 -1
- package/lib/module/components/UniversalOnboarding.js +31 -1
- package/lib/module/components/UniversalOnboarding.js.map +1 -1
- package/lib/module/components/onboarding/OAuthWebView.js +28 -9
- package/lib/module/components/onboarding/OAuthWebView.js.map +1 -1
- package/lib/module/components/onboarding/PlatformConnector.js +6 -1
- package/lib/module/components/onboarding/PlatformConnector.js.map +1 -1
- package/lib/module/components/screens/ConnectorScreen.js +3 -2
- package/lib/module/components/screens/ConnectorScreen.js.map +1 -1
- package/lib/module/constants/index.js +1 -1
- package/lib/module/hooks/useConnections.js +77 -14
- package/lib/module/hooks/useConnections.js.map +1 -1
- package/lib/module/hooks/useCredentials.js +2 -0
- package/lib/module/hooks/useCredentials.js.map +1 -1
- package/lib/module/index.js +27 -9
- package/lib/module/index.js.map +1 -1
- package/lib/module/services/oauthService.js +26 -33
- package/lib/module/services/oauthService.js.map +1 -1
- package/lib/module/types/ambient.d.js +2 -0
- package/lib/module/types/ambient.d.js.map +1 -0
- package/lib/module/types/node-fix.d.js +2 -0
- package/lib/module/types/node-fix.d.js.map +1 -0
- package/lib/module/types/node-override.d.js +2 -0
- package/lib/module/types/node-override.d.js.map +1 -0
- package/lib/module/types/types.d.js +2 -0
- package/lib/module/types/types.d.js.map +1 -0
- package/lib/module/utils/encryption.js +8 -2
- package/lib/module/utils/encryption.js.map +1 -1
- package/lib/module/utils/secureStorage.js +149 -42
- package/lib/module/utils/secureStorage.js.map +1 -1
- package/lib/typescript/api/index.d.ts +8 -0
- package/lib/typescript/api/index.d.ts.map +1 -0
- package/lib/typescript/components/DataRequestModal.d.ts +11 -0
- package/lib/typescript/components/DataRequestModal.d.ts.map +1 -0
- package/lib/typescript/components/Onairos.d.ts +29 -0
- package/lib/typescript/components/Onairos.d.ts.map +1 -0
- package/lib/typescript/components/OnairosButton.d.ts +7 -0
- package/lib/typescript/components/OnairosButton.d.ts.map +1 -0
- package/lib/typescript/components/Overlay.d.ts +18 -0
- package/lib/typescript/components/Overlay.d.ts.map +1 -0
- package/lib/typescript/components/PinInput.d.ts +4 -0
- package/lib/typescript/components/PinInput.d.ts.map +1 -0
- package/lib/typescript/components/PlatformList.d.ts +4 -0
- package/lib/typescript/components/PlatformList.d.ts.map +1 -0
- package/lib/typescript/components/TrainingModal.d.ts +4 -0
- package/lib/typescript/components/TrainingModal.d.ts.map +1 -0
- package/lib/typescript/components/UniversalOnboarding.d.ts +4 -0
- package/lib/typescript/components/UniversalOnboarding.d.ts.map +1 -0
- package/lib/typescript/components/onboarding/OAuthWebView.d.ts +4 -0
- package/lib/typescript/components/onboarding/OAuthWebView.d.ts.map +1 -0
- package/lib/typescript/components/onboarding/OnboardingHeader.d.ts +11 -0
- package/lib/typescript/components/onboarding/OnboardingHeader.d.ts.map +1 -0
- package/lib/typescript/components/onboarding/PinInput.d.ts +4 -0
- package/lib/typescript/components/onboarding/PinInput.d.ts.map +1 -0
- package/lib/typescript/components/onboarding/PlatformConnector.d.ts +13 -0
- package/lib/typescript/components/onboarding/PlatformConnector.d.ts.map +1 -0
- package/lib/typescript/components/screens/ConnectorScreen.d.ts +9 -0
- package/lib/typescript/components/screens/ConnectorScreen.d.ts.map +1 -0
- package/lib/typescript/components/screens/LoadingScreen.d.ts +9 -0
- package/lib/typescript/components/screens/LoadingScreen.d.ts.map +1 -0
- package/lib/typescript/components/screens/PinCreationScreen.d.ts +10 -0
- package/lib/typescript/components/screens/PinCreationScreen.d.ts.map +1 -0
- package/lib/typescript/constants/index.d.ts +52 -0
- package/lib/typescript/constants/index.d.ts.map +1 -0
- package/lib/typescript/hooks/useConnections.d.ts +9 -0
- package/lib/typescript/hooks/useConnections.d.ts.map +1 -0
- package/lib/typescript/hooks/useCredentials.d.ts +9 -0
- package/lib/typescript/hooks/useCredentials.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +45 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/services/oauthService.d.ts +50 -0
- package/lib/typescript/services/oauthService.d.ts.map +1 -0
- package/lib/typescript/types/index.d.ts +145 -0
- package/lib/typescript/types/index.d.ts.map +1 -0
- package/lib/typescript/types.d.ts +135 -0
- package/lib/typescript/types.d.ts.map +1 -0
- package/lib/typescript/utils/api.d.ts +6 -0
- package/lib/typescript/utils/api.d.ts.map +1 -0
- package/lib/typescript/utils/auth.d.ts +6 -0
- package/lib/typescript/utils/auth.d.ts.map +1 -0
- package/lib/typescript/utils/crypto.d.ts +4 -0
- package/lib/typescript/utils/crypto.d.ts.map +1 -0
- package/lib/typescript/utils/debugHelper.d.ts +29 -0
- package/lib/typescript/utils/debugHelper.d.ts.map +1 -0
- package/lib/typescript/utils/encryption.d.ts +19 -0
- package/lib/typescript/utils/encryption.d.ts.map +1 -0
- package/lib/typescript/utils/onairosApi.d.ts +72 -0
- package/lib/typescript/utils/onairosApi.d.ts.map +1 -0
- package/lib/typescript/utils/secureStorage.d.ts +63 -0
- package/lib/typescript/utils/secureStorage.d.ts.map +1 -0
- package/package.json +16 -4
- package/src/api/index.ts +86 -101
- package/src/components/OnairosButton.tsx +22 -14
- package/src/components/Overlay.tsx +303 -138
- package/src/components/UniversalOnboarding.tsx +25 -0
- package/src/components/onboarding/OAuthWebView.tsx +27 -7
- package/src/components/onboarding/PlatformConnector.tsx +5 -0
- package/src/components/screens/ConnectorScreen.tsx +3 -2
- package/src/constants/index.ts +81 -81
- package/src/hooks/useConnections.ts +76 -16
- package/src/hooks/useCredentials.ts +5 -1
- package/src/index.ts +30 -3
- package/src/services/oauthService.ts +412 -419
- package/src/types/ambient.d.ts +29 -0
- package/src/types/index.d.ts +48 -8
- package/src/types/index.ts +21 -15
- package/src/types/node-fix.d.ts +19 -0
- package/src/types/node-override.d.ts +24 -0
- package/src/types/types.d.ts +18 -0
- package/src/types.ts +121 -1
- package/src/utils/encryption.ts +7 -2
- package/src/utils/secureStorage.ts +155 -56
- package/types/index.d.ts +210 -0
- package/types/node-env.d.ts +15 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,wBAAwB;IACvC,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE;QACX,KAAK,EAAE,QAAQ,CAAC;QAChB,MAAM,EAAE,QAAQ,CAAC;QACjB,KAAK,EAAE,QAAQ,CAAC;KACjB,CAAC;IACF,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,IAAI,CAAC;IAC/D,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,UAAU,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IAChC,UAAU,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC;IAChC,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,gBAAgB;IAC/B,CAAC,GAAG,EAAE,MAAM,GAAG;QACb,QAAQ,EAAE,MAAM,CAAC;QACjB,SAAS,EAAE,OAAO,CAAC;KACpB,CAAC;CACH;AAED,MAAM,WAAW,kBAAkB;IACjC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,C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CAAC;CACtB;AAED,MAAM,WAAW,WAAW,CAAC,CAAC;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,CAAC,CAAC;IACT,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,CAAC,EAAE,GAAG,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE;QACJ,CAAC,GAAG,EAAE,MAAM,GAAG;YACb,IAAI,EAAE,MAAM,CAAC;YACb,YAAY,EAAE,MAAM,CAAC;YACrB,MAAM,EAAE,MAAM,CAAC;SAChB,CAAC;KACH,CAAC;IACF,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,KAAK,IAAI,CAAC;CAC9E;AAED,MAAM,WAAW,gBAAgB;IAC/B,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,gBAAgB,EAAE,OAAO,CAAC;IAC1B,aAAa,EAAE,OAAO,CAAC;IACvB,kBAAkB,EAAE,OAAO,CAAC;CAC7B"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export function createApiInstance(): Promise<any>;
|
|
2
|
+
export function validateDomain(): Promise<any>;
|
|
3
|
+
export function fetchAccountInfo(identifier: string, isEmail?: boolean): Promise<any>;
|
|
4
|
+
export function getApiUrl(approvedRequests: any[], pin: string, othentSub: string): Promise<any>;
|
|
5
|
+
export function createAccount(othentSub: string, pin: string, socialAccounts: any[], email: string): Promise<any>;
|
|
6
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/utils/api.js"],"names":[],"mappings":"AASO,qCAFM,YAAe,CAY3B;AAMM,kCAFM,YAAe,CAW3B;AAQM,6CAJI,MAAM,YACN,OAAO,GACL,YAAe,CAiB3B;AASM,wDAJI,MAAM,aACN,MAAM,GACJ,YAAe,CAsB3B;AAUM,yCANI,MAAM,OACN,MAAM,gCAEN,MAAM,GACJ,YAAe,CAiB3B"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export function getPin(hashedOthentSub: string): Promise<any>;
|
|
2
|
+
export function verifyToken(token: string): Promise<boolean>;
|
|
3
|
+
export function storeAuthData(token: string, username?: string, othentData?: any): Promise<void>;
|
|
4
|
+
export function clearAuthData(): Promise<void>;
|
|
5
|
+
export function getStoredAuthData(): Promise<any>;
|
|
6
|
+
//# sourceMappingURL=auth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/utils/auth.js"],"names":[],"mappings":"AAUO,wCAHI,MAAM,GACJ,YAAe,CAa3B;AAOM,mCAHI,MAAM,GACJ,QAAQ,OAAO,CAAC,CAe5B;AAQM,qCAJI,MAAM,aACN,MAAM,mCAkBhB;AAKM,+CASN;AAMM,qCAFM,YAAe,CAqB3B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../../../src/utils/crypto.js"],"names":[],"mappings":"AASO,sCAJI,MAAM,QACN,MAAM,GACJ,QAAQ,MAAM,CAAC,CAsB3B;AAOM,6BAHI,MAAM,GACJ,MAAM,CAIlB;AAOM,6CAHI,MAAM,GACJ,WAAW,CAgBvB"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Debug utility functions for Onairos React Native SDK
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Log debug message to console when in development mode
|
|
6
|
+
* @param label Label for the debug message
|
|
7
|
+
* @param data Data to log
|
|
8
|
+
*/
|
|
9
|
+
export declare const logDebug: (label: string, data?: any) => void;
|
|
10
|
+
/**
|
|
11
|
+
* Log error message to console
|
|
12
|
+
* @param label Label for the error message
|
|
13
|
+
* @param error Error object or message
|
|
14
|
+
*/
|
|
15
|
+
export declare const logError: (label: string, error: any) => void;
|
|
16
|
+
/**
|
|
17
|
+
* Check if debug mode is enabled
|
|
18
|
+
* @param debug Debug flag passed to component
|
|
19
|
+
* @returns Whether debug mode is enabled
|
|
20
|
+
*/
|
|
21
|
+
export declare const isDebugMode: (debug?: boolean) => boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Format and log API request details
|
|
24
|
+
* @param method HTTP method
|
|
25
|
+
* @param url API URL
|
|
26
|
+
* @param data Request data
|
|
27
|
+
*/
|
|
28
|
+
export declare const logApiRequest: (method: string, url: string, data?: any) => void;
|
|
29
|
+
//# sourceMappingURL=debugHelper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debugHelper.d.ts","sourceRoot":"","sources":["../../../src/utils/debugHelper.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH;;;;GAIG;AACH,eAAO,MAAM,QAAQ,UAAW,MAAM,SAAS,GAAG,KAAG,IAIpD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,QAAQ,UAAW,MAAM,SAAS,GAAG,KAAG,IAIpD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,WAAW,WAAY,OAAO,KAAG,OAE7C,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,aAAa,WAAY,MAAM,OAAO,MAAM,SAAS,GAAG,KAAG,IAQvE,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Encrypt a model key using RSA with a public key
|
|
3
|
+
* @param publicKey The public key to encrypt with
|
|
4
|
+
* @param modelKey The model key to encrypt
|
|
5
|
+
* @returns The encrypted model key
|
|
6
|
+
*/
|
|
7
|
+
export declare const encryptModelKey: (publicKey: string, modelKey: string) => string;
|
|
8
|
+
/**
|
|
9
|
+
* Get the server's public key
|
|
10
|
+
* @returns The server's public key
|
|
11
|
+
*/
|
|
12
|
+
export declare const getServerPublicKey: () => Promise<string>;
|
|
13
|
+
/**
|
|
14
|
+
* Hash a string using SHA-256
|
|
15
|
+
* @param input The string to hash
|
|
16
|
+
* @returns The hashed string
|
|
17
|
+
*/
|
|
18
|
+
export declare const hashString: (input: string) => Promise<string>;
|
|
19
|
+
//# sourceMappingURL=encryption.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encryption.d.ts","sourceRoot":"","sources":["../../../src/utils/encryption.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,eAAO,MAAM,eAAe,cAAe,MAAM,YAAY,MAAM,KAAG,MAkBrE,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,kBAAkB,QAAa,QAAQ,MAAM,CAkBzD,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,UAAU,UAAiB,MAAM,KAAG,QAAQ,MAAM,CAS9D,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { OnairosCredentials } from './secureStorage';
|
|
2
|
+
export interface ApiResponse<T = any> {
|
|
3
|
+
success: boolean;
|
|
4
|
+
data?: T;
|
|
5
|
+
error?: {
|
|
6
|
+
code: string;
|
|
7
|
+
message: string;
|
|
8
|
+
details?: any;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export declare type ApiErrorType = 'network_error' | 'timeout_error' | 'auth_error' | 'server_error' | 'validation_error' | 'unknown_error';
|
|
12
|
+
export declare class ApiError extends Error {
|
|
13
|
+
type: ApiErrorType;
|
|
14
|
+
code?: string;
|
|
15
|
+
details?: any;
|
|
16
|
+
constructor(message: string, type: ApiErrorType, code?: string, details?: any);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Validate user credentials with the API
|
|
20
|
+
*/
|
|
21
|
+
export declare const validateCredentials: (username: string, options?: {
|
|
22
|
+
debug: boolean;
|
|
23
|
+
}) => Promise<{
|
|
24
|
+
isValid: boolean;
|
|
25
|
+
message?: string;
|
|
26
|
+
}>;
|
|
27
|
+
/**
|
|
28
|
+
* Create a new user account
|
|
29
|
+
*/
|
|
30
|
+
export declare const createAccount: (credentials: Partial<OnairosCredentials>, options?: {
|
|
31
|
+
debug: boolean;
|
|
32
|
+
}) => Promise<ApiResponse<{
|
|
33
|
+
accessToken: string;
|
|
34
|
+
userId: string;
|
|
35
|
+
}>>;
|
|
36
|
+
/**
|
|
37
|
+
* Authenticate with the API using credentials
|
|
38
|
+
*/
|
|
39
|
+
export declare const authenticate: (credentials: Partial<OnairosCredentials>, options?: {
|
|
40
|
+
debug: boolean;
|
|
41
|
+
}) => Promise<ApiResponse<{
|
|
42
|
+
accessToken: string;
|
|
43
|
+
refreshToken: string;
|
|
44
|
+
}>>;
|
|
45
|
+
/**
|
|
46
|
+
* Refresh authentication token
|
|
47
|
+
*/
|
|
48
|
+
export declare const refreshToken: (refreshToken: string, options?: {
|
|
49
|
+
debug: boolean;
|
|
50
|
+
}) => Promise<ApiResponse<{
|
|
51
|
+
accessToken: string;
|
|
52
|
+
refreshToken: string;
|
|
53
|
+
}>>;
|
|
54
|
+
/**
|
|
55
|
+
* Get user's connected platform data
|
|
56
|
+
*/
|
|
57
|
+
export declare const getPlatformData: (accessToken: string, platform: string, options?: {
|
|
58
|
+
debug: boolean;
|
|
59
|
+
}) => Promise<ApiResponse<any>>;
|
|
60
|
+
/**
|
|
61
|
+
* Get user profile information
|
|
62
|
+
*/
|
|
63
|
+
export declare const getUserProfile: (accessToken: string, options?: {
|
|
64
|
+
debug: boolean;
|
|
65
|
+
}) => Promise<ApiResponse<any>>;
|
|
66
|
+
/**
|
|
67
|
+
* Update user platform connections
|
|
68
|
+
*/
|
|
69
|
+
export declare const updatePlatformConnections: (accessToken: string, platforms: Record<string, any>, options?: {
|
|
70
|
+
debug: boolean;
|
|
71
|
+
}) => Promise<ApiResponse<any>>;
|
|
72
|
+
//# sourceMappingURL=onairosApi.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"onairosApi.d.ts","sourceRoot":"","sources":["../../../src/utils/onairosApi.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAWrD,MAAM,WAAW,WAAW,CAAC,CAAC,GAAG,GAAG;IAClC,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,CAAC,CAAC;IACT,KAAK,CAAC,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,CAAC,EAAE,GAAG,CAAC;KACf,CAAC;CACH;AAGD,oBAAY,YAAY,GACpB,eAAe,GACf,eAAe,GACf,YAAY,GACZ,cAAc,GACd,kBAAkB,GAClB,eAAe,CAAC;AAGpB,qBAAa,QAAS,SAAQ,KAAK;IACjC,IAAI,EAAE,YAAY,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,GAAG,CAAC;gBAEF,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG;CAO9E;AAmJD;;GAEG;AACH,eAAO,MAAM,mBAAmB,aACpB,MAAM;;MAEf,QAAQ;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAiBhD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,aAAa,gBACX,QAAQ,kBAAkB,CAAC;;MAEvC,QAAQ,YAAY;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAQ9D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,gBACV,QAAQ,kBAAkB,CAAC;;MAEvC,QAAQ,YAAY;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,cAAc,MAAM,CAAA;CAAE,CAAC,CAQpE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,iBACT,MAAM;;;iBAEgB,MAAM;kBAAgB,MAAM;GAKjE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe,gBACb,MAAM,YACT,MAAM;;MAEf,QAAQ,YAAY,GAAG,CAAC,CAK1B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,gBACZ,MAAM;;MAElB,QAAQ,YAAY,GAAG,CAAC,CAK1B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,yBAAyB,gBACvB,MAAM,aACR,OAAO,MAAM,EAAE,GAAG,CAAC;;MAE7B,QAAQ,YAAY,GAAG,CAAC,CAM1B,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
export interface OnairosCredentials {
|
|
2
|
+
username: string;
|
|
3
|
+
accessToken?: string;
|
|
4
|
+
refreshToken?: string;
|
|
5
|
+
userPin?: string;
|
|
6
|
+
platforms?: {
|
|
7
|
+
instagram?: {
|
|
8
|
+
token: string;
|
|
9
|
+
username: string;
|
|
10
|
+
userId?: string;
|
|
11
|
+
};
|
|
12
|
+
youtube?: {
|
|
13
|
+
token: string;
|
|
14
|
+
username: string;
|
|
15
|
+
userId?: string;
|
|
16
|
+
};
|
|
17
|
+
pinterest?: {
|
|
18
|
+
token: string;
|
|
19
|
+
username: string;
|
|
20
|
+
userId?: string;
|
|
21
|
+
};
|
|
22
|
+
reddit?: {
|
|
23
|
+
token: string;
|
|
24
|
+
username: string;
|
|
25
|
+
userId?: string;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
createdAt: number;
|
|
29
|
+
}
|
|
30
|
+
export interface StorageOptions {
|
|
31
|
+
service?: string;
|
|
32
|
+
accessControl?: any;
|
|
33
|
+
accessible?: any;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Store credentials in memory (temporary solution)
|
|
37
|
+
*/
|
|
38
|
+
export declare const storeCredentials: (credentials: Partial<OnairosCredentials>) => Promise<boolean>;
|
|
39
|
+
/**
|
|
40
|
+
* Retrieve credentials from memory (temporary solution)
|
|
41
|
+
*/
|
|
42
|
+
export declare const getCredentials: () => Promise<OnairosCredentials | null>;
|
|
43
|
+
/**
|
|
44
|
+
* Check if the user has stored credentials
|
|
45
|
+
*/
|
|
46
|
+
export declare const hasCredentials: () => Promise<boolean>;
|
|
47
|
+
/**
|
|
48
|
+
* Delete stored credentials
|
|
49
|
+
*/
|
|
50
|
+
export declare const deleteCredentials: () => Promise<boolean>;
|
|
51
|
+
/**
|
|
52
|
+
* Update specific fields in the stored credentials
|
|
53
|
+
*/
|
|
54
|
+
export declare const updateCredentials: (credentials: Partial<OnairosCredentials>) => Promise<boolean>;
|
|
55
|
+
/**
|
|
56
|
+
* Generate a device-specific unique username
|
|
57
|
+
*/
|
|
58
|
+
export declare const generateDeviceUsername: () => string;
|
|
59
|
+
/**
|
|
60
|
+
* Verify credentials (temporary mock implementation)
|
|
61
|
+
*/
|
|
62
|
+
export declare const verifyCredentials: (username: string) => Promise<boolean>;
|
|
63
|
+
//# sourceMappingURL=secureStorage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secureStorage.d.ts","sourceRoot":"","sources":["../../../src/utils/secureStorage.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE;QACV,S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,aAAoB,MAAM,KAAG,QAAQ,OAAO,CAazE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onairos/react-native",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.4",
|
|
4
4
|
"description": "Onairos React Native SDK for social media authentication and AI model training",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"files": [
|
|
11
11
|
"src",
|
|
12
12
|
"lib",
|
|
13
|
+
"types",
|
|
13
14
|
"android",
|
|
14
15
|
"ios",
|
|
15
16
|
"cpp",
|
|
@@ -28,13 +29,16 @@
|
|
|
28
29
|
],
|
|
29
30
|
"scripts": {
|
|
30
31
|
"test": "jest",
|
|
31
|
-
"typecheck": "tsc --noEmit",
|
|
32
|
+
"typecheck": "tsc --noEmit --skipLibCheck",
|
|
32
33
|
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
33
34
|
"prepare": "bob build",
|
|
34
35
|
"release": "release-it",
|
|
35
36
|
"example": "npm --prefix example",
|
|
36
37
|
"bootstrap": "npm run example && npm install",
|
|
37
|
-
"build": "bob build",
|
|
38
|
+
"build": "npm run clean && bob build",
|
|
39
|
+
"build:js": "bob build --targets commonjs,module",
|
|
40
|
+
"build:types": "bob build --targets typescript",
|
|
41
|
+
"build:all": "npm run clean && bob build",
|
|
38
42
|
"clean": "del-cli lib",
|
|
39
43
|
"prebuild": "npm run clean"
|
|
40
44
|
},
|
|
@@ -76,6 +80,7 @@
|
|
|
76
80
|
"@react-native-community/eslint-config": "^3.0.0",
|
|
77
81
|
"@release-it/conventional-changelog": "^5.0.0",
|
|
78
82
|
"@types/jest": "^28.1.2",
|
|
83
|
+
"@types/node": "^22.15.17",
|
|
79
84
|
"@types/react": "^18.0.0",
|
|
80
85
|
"@types/react-native": "^0.70.0",
|
|
81
86
|
"@types/react-native-vector-icons": "^6.4.13",
|
|
@@ -112,7 +117,14 @@
|
|
|
112
117
|
"output": "lib",
|
|
113
118
|
"targets": [
|
|
114
119
|
"commonjs",
|
|
115
|
-
"module"
|
|
120
|
+
"module",
|
|
121
|
+
[
|
|
122
|
+
"typescript",
|
|
123
|
+
{
|
|
124
|
+
"project": "tsconfig.build.json",
|
|
125
|
+
"tscFlags": ["--skipLibCheck"]
|
|
126
|
+
}
|
|
127
|
+
]
|
|
116
128
|
]
|
|
117
129
|
}
|
|
118
130
|
}
|
package/src/api/index.ts
CHANGED
|
@@ -1,126 +1,111 @@
|
|
|
1
|
-
import axios from 'axios';
|
|
1
|
+
import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from 'axios';
|
|
2
|
+
import { Platform } from 'react-native';
|
|
3
|
+
import { API_ENDPOINTS } from '../constants';
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
// Check if running in development mode
|
|
6
|
+
const isDevelopmentMode = () => {
|
|
7
|
+
return __DEV__ || process.env.NODE_ENV === 'development';
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
// Create mock response helper
|
|
11
|
+
const createMockResponse = <T>(data: T): Promise<AxiosResponse<T>> => {
|
|
12
|
+
return Promise.resolve({ data, status: 200, statusText: 'OK', headers: {}, config: {} as any });
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
// Create API instance
|
|
16
|
+
const apiInstance: AxiosInstance = axios.create({
|
|
17
|
+
baseURL: API_ENDPOINTS.base,
|
|
18
|
+
timeout: 10000,
|
|
19
|
+
headers: {
|
|
20
|
+
'Content-Type': 'application/json',
|
|
21
|
+
'Accept': 'application/json',
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
// Add error handling interceptor
|
|
26
|
+
apiInstance.interceptors.response.use(
|
|
27
|
+
(response) => response,
|
|
28
|
+
(error) => {
|
|
29
|
+
if (isDevelopmentMode()) {
|
|
30
|
+
console.warn('API error in development mode, using fallback:', error);
|
|
31
|
+
return createMockResponse({ success: true, data: { mockData: true } });
|
|
32
|
+
}
|
|
33
|
+
return Promise.reject(error);
|
|
34
|
+
}
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
// API service with Expo compatibility
|
|
6
38
|
export const onairosApi = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Make a GET request to the API
|
|
11
|
-
* @param endpoint The endpoint to request
|
|
12
|
-
* @returns The response data
|
|
13
|
-
*/
|
|
14
|
-
get: async (endpoint: string) => {
|
|
39
|
+
// Core API methods with fallbacks
|
|
40
|
+
async get<T = any>(url: string): Promise<AxiosResponse<T>> {
|
|
15
41
|
try {
|
|
16
|
-
|
|
17
|
-
|
|
42
|
+
if (Platform.OS === 'web' && isDevelopmentMode()) {
|
|
43
|
+
return createMockResponse<T>({ success: true, data: { mockData: true } } as unknown as T);
|
|
44
|
+
}
|
|
45
|
+
return await apiInstance.get<T>(url);
|
|
18
46
|
} catch (error) {
|
|
19
|
-
console.error(`GET ${
|
|
47
|
+
console.error(`GET ${url} error:`, error);
|
|
48
|
+
if (isDevelopmentMode()) {
|
|
49
|
+
return createMockResponse<T>({ success: true, data: { mockData: true } } as unknown as T);
|
|
50
|
+
}
|
|
20
51
|
throw error;
|
|
21
52
|
}
|
|
22
53
|
},
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
* Make a POST request to the API
|
|
26
|
-
* @param endpoint The endpoint to request
|
|
27
|
-
* @param data The data to send
|
|
28
|
-
* @returns The response data
|
|
29
|
-
*/
|
|
30
|
-
post: async (endpoint: string, data: any) => {
|
|
54
|
+
|
|
55
|
+
async post<T = any>(url: string, data: any): Promise<AxiosResponse<T>> {
|
|
31
56
|
try {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
);
|
|
36
|
-
return response.data;
|
|
57
|
+
if (Platform.OS === 'web' && isDevelopmentMode()) {
|
|
58
|
+
return createMockResponse<T>({ success: true, data: { mockData: true } } as unknown as T);
|
|
59
|
+
}
|
|
60
|
+
return await apiInstance.post<T>(url, data);
|
|
37
61
|
} catch (error) {
|
|
38
|
-
console.error(`POST ${
|
|
62
|
+
console.error(`POST ${url} error:`, error);
|
|
63
|
+
if (isDevelopmentMode()) {
|
|
64
|
+
return createMockResponse<T>({ success: true, data: { mockData: true } } as unknown as T);
|
|
65
|
+
}
|
|
39
66
|
throw error;
|
|
40
67
|
}
|
|
41
68
|
},
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
* @returns The server's public key
|
|
46
|
-
*/
|
|
47
|
-
getServerPublicKey: async () => {
|
|
48
|
-
try {
|
|
49
|
-
const response = await onairosApi.get('public/getPublicKey');
|
|
50
|
-
return response.publicKey;
|
|
51
|
-
} catch (error) {
|
|
52
|
-
console.error('Error getting server public key:', error);
|
|
53
|
-
return '';
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Validate credentials with the server
|
|
59
|
-
* @param username The username to validate
|
|
60
|
-
* @returns Whether the credentials are valid
|
|
61
|
-
*/
|
|
62
|
-
validateCredentials: async (username: string) => {
|
|
69
|
+
|
|
70
|
+
// Helper methods for specific API endpoints
|
|
71
|
+
async validateCredentials(username: string) {
|
|
63
72
|
try {
|
|
64
|
-
|
|
65
|
-
|
|
73
|
+
if (isDevelopmentMode()) {
|
|
74
|
+
console.log('Using mock validation for:', username);
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const response = await this.post('validate', { username });
|
|
79
|
+
return response.data?.success || false;
|
|
66
80
|
} catch (error) {
|
|
67
81
|
console.error('Error validating credentials:', error);
|
|
68
|
-
return
|
|
69
|
-
}
|
|
70
|
-
},
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Get account information for a user
|
|
74
|
-
* @param username The username to get account info for
|
|
75
|
-
* @returns The account information
|
|
76
|
-
*/
|
|
77
|
-
getAccountInfo: async (username: string) => {
|
|
78
|
-
try {
|
|
79
|
-
const response = await onairosApi.post('getAccountInfo', {
|
|
80
|
-
Info: { username }
|
|
81
|
-
});
|
|
82
|
-
return response.AccountInfo;
|
|
83
|
-
} catch (error) {
|
|
84
|
-
console.error('Error getting account info:', error);
|
|
85
|
-
return null;
|
|
82
|
+
return isDevelopmentMode(); // Return true in dev mode to allow flow to continue
|
|
86
83
|
}
|
|
87
84
|
},
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
* Get API URL and token for a user
|
|
91
|
-
* @param params The parameters for the request
|
|
92
|
-
* @returns The API URL and token
|
|
93
|
-
*/
|
|
94
|
-
getApiUrl: async (params: {
|
|
95
|
-
appId: string;
|
|
96
|
-
username: string;
|
|
97
|
-
encryptedModelKey: string;
|
|
98
|
-
confirmations: { [key: string]: boolean };
|
|
99
|
-
}) => {
|
|
85
|
+
|
|
86
|
+
async getUserProfile(token: string) {
|
|
100
87
|
try {
|
|
101
|
-
|
|
102
|
-
Info: {
|
|
103
|
-
storage: 'local',
|
|
104
|
-
appId: params.appId,
|
|
105
|
-
confirmations: params.confirmations,
|
|
106
|
-
developerURL: 'devURL',
|
|
107
|
-
EncryptedUserPin: params.encryptedModelKey,
|
|
108
|
-
account: params.username,
|
|
109
|
-
proofMode: false,
|
|
110
|
-
},
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
if (response && response.apiUrl && response.token) {
|
|
88
|
+
if (isDevelopmentMode()) {
|
|
114
89
|
return {
|
|
115
|
-
|
|
116
|
-
|
|
90
|
+
username: 'demo_user',
|
|
91
|
+
platforms: ['instagram', 'youtube'],
|
|
92
|
+
createdAt: Date.now(),
|
|
117
93
|
};
|
|
118
|
-
} else {
|
|
119
|
-
throw new Error('Invalid response from getAPIUrlMobile');
|
|
120
94
|
}
|
|
95
|
+
|
|
96
|
+
apiInstance.defaults.headers.common['Authorization'] = `Bearer ${token}`;
|
|
97
|
+
const response = await this.get('user/profile');
|
|
98
|
+
return response.data?.data;
|
|
121
99
|
} catch (error) {
|
|
122
|
-
console.error('Error
|
|
100
|
+
console.error('Error fetching user profile:', error);
|
|
101
|
+
if (isDevelopmentMode()) {
|
|
102
|
+
return {
|
|
103
|
+
username: 'demo_user',
|
|
104
|
+
platforms: ['instagram', 'youtube'],
|
|
105
|
+
createdAt: Date.now(),
|
|
106
|
+
};
|
|
107
|
+
}
|
|
123
108
|
throw error;
|
|
124
109
|
}
|
|
125
|
-
}
|
|
110
|
+
},
|
|
126
111
|
};
|
|
@@ -57,6 +57,7 @@ export const OnairosButton: React.FC<OnairosButtonProps> = ({
|
|
|
57
57
|
const shouldProceed = await preCheck();
|
|
58
58
|
if (!shouldProceed) {
|
|
59
59
|
onRejection?.('Precheck validation failed');
|
|
60
|
+
setIsLoading(false);
|
|
60
61
|
return;
|
|
61
62
|
}
|
|
62
63
|
}
|
|
@@ -68,33 +69,41 @@ export const OnairosButton: React.FC<OnairosButtonProps> = ({
|
|
|
68
69
|
// If credentials exist, fetch them and verify
|
|
69
70
|
const credentials = await getCredentials();
|
|
70
71
|
|
|
71
|
-
if (!credentials || !credentials.username
|
|
72
|
+
if (!credentials || !credentials.username) {
|
|
72
73
|
// Invalid credentials, clear and start fresh
|
|
73
74
|
await clearCredentials();
|
|
74
75
|
setShowOnboarding(true);
|
|
76
|
+
setIsLoading(false);
|
|
75
77
|
return;
|
|
76
78
|
}
|
|
77
79
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
80
|
+
try {
|
|
81
|
+
// Validate credentials with server - catch errors here to prevent crashing
|
|
82
|
+
const isValid = await onairosApi.validateCredentials(credentials.username);
|
|
83
|
+
|
|
84
|
+
if (!isValid) {
|
|
85
|
+
// Clear invalid credentials
|
|
86
|
+
await clearCredentials();
|
|
87
|
+
setShowOnboarding(true);
|
|
88
|
+
setIsLoading(false);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// Store and display overlay with valid credentials
|
|
93
|
+
setStoredCredentials(credentials);
|
|
94
|
+
setShowOverlay(true);
|
|
95
|
+
} catch (validationError) {
|
|
96
|
+
console.warn('Validation error, proceeding to onboarding:', validationError);
|
|
84
97
|
setShowOnboarding(true);
|
|
85
|
-
return;
|
|
86
98
|
}
|
|
87
|
-
|
|
88
|
-
// Store and display overlay with valid credentials
|
|
89
|
-
setStoredCredentials(credentials);
|
|
90
|
-
setShowOverlay(true);
|
|
91
99
|
} else {
|
|
92
100
|
// If no credentials, show onboarding
|
|
93
101
|
setShowOnboarding(true);
|
|
94
102
|
}
|
|
95
103
|
} catch (error) {
|
|
96
104
|
console.error('Error during button press flow:', error);
|
|
97
|
-
|
|
105
|
+
// Fall back to onboarding on error
|
|
106
|
+
setShowOnboarding(true);
|
|
98
107
|
onRejection?.(error instanceof Error ? error.message : 'Unknown error');
|
|
99
108
|
} finally {
|
|
100
109
|
setIsLoading(false);
|
|
@@ -169,7 +178,6 @@ export const OnairosButton: React.FC<OnairosButtonProps> = ({
|
|
|
169
178
|
requestData={requestData}
|
|
170
179
|
returnLink={returnLink}
|
|
171
180
|
onComplete={handleOnboardingComplete}
|
|
172
|
-
preferredPlatform={preferredPlatform}
|
|
173
181
|
debug={debug}
|
|
174
182
|
test={testMode}
|
|
175
183
|
/>
|