@unvired/react-native-wrapper-sdk 0.0.10 → 0.0.11

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 (33) hide show
  1. package/dist/UnviredWrapper.d.ts +7 -12
  2. package/dist/UnviredWrapper.d.ts.map +1 -1
  3. package/dist/UnviredWrapper.js +28 -32
  4. package/dist/core/UnviredSDK.d.ts +107 -0
  5. package/dist/core/UnviredSDK.d.ts.map +1 -0
  6. package/dist/core/UnviredSDK.js +24 -0
  7. package/dist/core/platform/CordovaPlatformAdapter.d.ts +13 -0
  8. package/dist/core/platform/CordovaPlatformAdapter.d.ts.map +1 -0
  9. package/dist/core/platform/CordovaPlatformAdapter.js +62 -0
  10. package/dist/core/platform/PlatformInterface.d.ts +12 -0
  11. package/dist/core/platform/PlatformInterface.d.ts.map +1 -0
  12. package/dist/core/platform/PlatformInterface.js +2 -0
  13. package/dist/core/platform/PlatformManager.d.ts +10 -0
  14. package/dist/core/platform/PlatformManager.d.ts.map +1 -0
  15. package/dist/core/platform/PlatformManager.js +29 -0
  16. package/dist/core/platform/ReactNativePlatformAdapter.d.ts +13 -0
  17. package/dist/core/platform/ReactNativePlatformAdapter.d.ts.map +1 -0
  18. package/dist/core/platform/ReactNativePlatformAdapter.js +47 -0
  19. package/dist/index.d.ts +3 -0
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +6 -0
  22. package/dist/lib/AuthBuilder.d.ts +6 -42
  23. package/dist/lib/AuthBuilder.d.ts.map +1 -1
  24. package/dist/lib/AuthBuilder.js +7 -28
  25. package/package.json +3 -3
  26. package/src/UnviredWrapper.ts +36 -35
  27. package/src/core/UnviredSDK.ts +126 -0
  28. package/src/core/platform/CordovaPlatformAdapter.ts +69 -0
  29. package/src/core/platform/PlatformInterface.ts +12 -0
  30. package/src/core/platform/PlatformManager.ts +35 -0
  31. package/src/core/platform/ReactNativePlatformAdapter.ts +57 -0
  32. package/src/index.ts +5 -0
  33. package/src/lib/AuthBuilder.ts +28 -66
@@ -1,30 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LoginType = exports.LoginParameters = void 0;
4
- const unvired_ts_core_sdk_1 = require("@unvired/unvired-ts-core-sdk");
5
- /**
6
- * LoginParameters class - Local definition to avoid module resolution issues
7
- */
8
- class LoginParameters {
9
- }
10
- exports.LoginParameters = LoginParameters;
11
- /**
12
- * LoginType enum for different authentication types
13
- */
14
- var LoginType;
15
- (function (LoginType) {
16
- LoginType["UNVIRED"] = "UNVIRED";
17
- LoginType["LDAP"] = "LDAP";
18
- LoginType["SSO"] = "SSO";
19
- })(LoginType || (exports.LoginType = LoginType = {}));
20
- /**
21
- * AuthBuilder - Fluent API for building authentication requests
22
- * Can be awaited directly without calling .execute()
23
- */
3
+ const UnviredSDK_1 = require("./../core/UnviredSDK");
24
4
  class AuthBuilder {
25
- constructor(method) {
5
+ constructor(sdk, method) {
6
+ this.sdk = sdk;
26
7
  this.method = method;
27
- this.loginParameters = new LoginParameters();
8
+ this.loginParameters = new UnviredSDK_1.LoginParameters();
28
9
  }
29
10
  setAppName(appName) {
30
11
  this.loginParameters.appName = appName;
@@ -115,15 +96,13 @@ class AuthBuilder {
115
96
  return this;
116
97
  }
117
98
  execute() {
118
- // Get the singleton instance and call the appropriate authentication method
119
- const authService = unvired_ts_core_sdk_1.AuthenticationService.instance;
120
99
  switch (this.method) {
121
100
  case 'login':
122
- return authService.login(this.loginParameters);
101
+ return this.sdk.login(this.loginParameters);
123
102
  case 'authenticateAndActivate':
124
- return authService.authenticateAndActivate(this.loginParameters);
103
+ return this.sdk.authenticateAndActivate(this.loginParameters);
125
104
  case 'authenticateLocal':
126
- return authService.authenticateLocal(this.loginParameters);
105
+ return this.sdk.authenticateLocal(this.loginParameters);
127
106
  default:
128
107
  return Promise.reject(new Error(`Unknown method: ${this.method}`));
129
108
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unvired/react-native-wrapper-sdk",
3
- "version": "0.0.10",
3
+ "version": "0.0.11",
4
4
  "description": "Unvired SDK for React Native - Enterprise mobile platform SDK with authentication, sync, and offline database",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -27,8 +27,8 @@
27
27
  "react-native": ">=0.60.0"
28
28
  },
29
29
  "dependencies": {
30
- "@unvired/react-native-unvired-sdk": "^0.0.10",
31
- "@unvired/unvired-ts-core-sdk": "^0.0.10",
30
+ "@unvired/react-native-unvired-sdk": "^0.0.5",
31
+ "@unvired/unvired-ts-core-sdk": "^0.0.6",
32
32
  "axios": "^1.6.5",
33
33
  "crypto-js": "^4.2.0",
34
34
  "uuid": "^9.0.1"
@@ -1,13 +1,19 @@
1
- import AuthBuilder from './lib/AuthBuilder';
2
- import { AuthenticationService, PlatformManager } from '@unvired/unvired-ts-core-sdk';
1
+ import UnviredSDK from './core/UnviredSDK';
2
+ import AuthBuilder from './lib/AuthBuilder';
3
+
4
+ import PlatformInterface from '@unvired/unvired-ts-core-sdk/platform/PlatformManager';
5
+
3
6
 
4
- /**
5
- * React Native Wrapper for Unvired Core SDK
6
- * Provides a clean, fluent API for React Native applications
7
- */
8
7
  export class UnviredWrapper {
8
+ private unviredSDK: UnviredSDK;
9
+
9
10
  constructor() {
10
- // AuthenticationService is a singleton, accessed via static instance getter
11
+ this.unviredSDK = new UnviredSDK();
12
+ }
13
+
14
+ private static get logger() {
15
+ console.log('PlatformInterface from core SDK', PlatformInterface);
16
+ return UnviredSDK.getPlatformManager().getPlatformAdapter();
11
17
  }
12
18
 
13
19
  /**
@@ -15,7 +21,7 @@ export class UnviredWrapper {
15
21
  * Can be awaited directly: await sdk.login().setAppName("my-app")
16
22
  */
17
23
  login(): AuthBuilder {
18
- return new AuthBuilder('login');
24
+ return new AuthBuilder(this.unviredSDK, 'login');
19
25
  }
20
26
 
21
27
  /**
@@ -23,7 +29,7 @@ export class UnviredWrapper {
23
29
  * Can be awaited directly: await sdk.authenticateAndActivate().setUsername("demo")
24
30
  */
25
31
  authenticateAndActivate(): AuthBuilder {
26
- return new AuthBuilder('authenticateAndActivate');
32
+ return new AuthBuilder(this.unviredSDK, 'authenticateAndActivate');
27
33
  }
28
34
 
29
35
  /**
@@ -31,57 +37,52 @@ export class UnviredWrapper {
31
37
  * Can be awaited directly: await sdk.authenticateLocal().setUsername("demo")
32
38
  */
33
39
  authenticateLocal(): AuthBuilder {
34
- return new AuthBuilder('authenticateLocal');
40
+ return new AuthBuilder(this.unviredSDK, 'authenticateLocal');
35
41
  }
36
42
 
37
- /**
38
- * Logout method - Logs out the current user
39
- */
40
- async logout(): Promise<any> {
41
- const authService = (AuthenticationService as any).instance;
42
- return authService.logout();
43
- }
44
-
45
- /**
46
- * Clear all data
47
- */
48
- async clearData(): Promise<any> {
49
- const authService = (AuthenticationService as any).instance;
50
- return authService.clearData();
51
- }
52
-
53
- // Logging methods - delegating to PlatformManager's adapter
54
43
  static logInfo(className: string, methodName: string, message: string) {
55
- return PlatformManager.getInstance().getPlatformAdapter().getLoggerAdapter().logInfo(className, methodName, message);
44
+
45
+ console.log('PlatformInterface from core SDK', PlatformInterface);
46
+ this.logger.logInfo(className, methodName, message);
56
47
  }
57
48
 
58
49
  static logError(className: string, methodName: string, message: string) {
59
- return PlatformManager.getInstance().getPlatformAdapter().getLoggerAdapter().logError(className, methodName, message);
50
+ this.logger.logError(className, methodName, message);
60
51
  }
61
52
 
62
53
  static logDebug(className: string, methodName: string, message: string) {
63
- return PlatformManager.getInstance().getPlatformAdapter().getLoggerAdapter().logDebug(className, methodName, message);
54
+ this.logger.logDebug(className, methodName, message);
64
55
  }
65
56
 
57
+ static logWarning(className: string, methodName: string, message: string) {
58
+ this.logger.logWarning(className, methodName, message);
59
+ }
66
60
 
67
61
  static setLogLevel(level: string) {
68
- return PlatformManager.getInstance().getPlatformAdapter().getLoggerAdapter().setLogLevel(level);
62
+ this.logger.setLogLevel(level);
69
63
  }
70
64
 
71
65
  static async getLogFileURL(): Promise<string> {
72
- return PlatformManager.getInstance().getPlatformAdapter().getLoggerAdapter().getLogFileURL();
66
+ return this.logger.getLogFileURL();
73
67
  }
74
68
 
75
69
  static async getLogFileContent(): Promise<string> {
76
- return PlatformManager.getInstance().getPlatformAdapter().getLoggerAdapter().getLogFileContent();
70
+ return this.logger.getLogFileContent();
77
71
  }
78
72
 
79
73
  static async getBackupLogFileContent(): Promise<string> {
80
- return PlatformManager.getInstance().getPlatformAdapter().getLoggerAdapter().getBackupLogFileContent();
74
+ return this.logger.getBackupLogFileContent();
81
75
  }
82
76
 
83
77
  static async clearLogFile(): Promise<void> {
84
- return PlatformManager.getInstance().getPlatformAdapter().getLoggerAdapter().clearLogFile();
78
+ return this.logger.clearLogFile();
79
+ }
80
+
81
+ /**
82
+ * Logout method - Calls CoreWebSDK
83
+ */
84
+ async logout(): Promise<boolean> {
85
+ return this.unviredSDK.logout();
85
86
  }
86
87
  }
87
88
 
@@ -0,0 +1,126 @@
1
+ import { PlatformManager } from './platform/PlatformManager';
2
+
3
+ export declare enum LoginType {
4
+ unvired = 'UNVIRED_ID',
5
+ }
6
+ export declare class LoginParameters {
7
+ /**
8
+ * Set the application name as configured in UMP.
9
+ */
10
+ appName: string;
11
+ /**
12
+ * Company name as configured in UMP.
13
+ */
14
+ company: string;
15
+ /**
16
+ * Username of the user trying to login.
17
+ */
18
+ username: string;
19
+ /**
20
+ * Password of the user trying to login.
21
+ */
22
+ password: string;
23
+ /**
24
+ * UMP URL. For example: https://umpdev.unvired.io/UMP
25
+ */
26
+ url: string;
27
+ /**
28
+ * Domain name. Required only if the login type is ADS or SAP.
29
+ */
30
+ domain: string;
31
+ /**
32
+ * Set this value to one of the allowed login types for your app as configured in UMP.
33
+ */
34
+ loginType: LoginType;
35
+ /**
36
+ * FrontEndUserId: This id uniquely identifies the user across devices of same type. If the Unvired user has multiple front end ids for a device type, you need to set this value.
37
+ * If the Unvired user has only one front end id, leave this field blank.
38
+ */
39
+ feUserId: string;
40
+ /**
41
+ * Required only if the loginType is 'sap'. This sets the SAP Port Name.
42
+ */
43
+ port: string;
44
+ /**
45
+ * Required for Browser Platform.
46
+ * For iOS Platform include the metadata.xml file as part of App Bundle
47
+ * For Android Platform include the metadata.xml file in src > res > raw
48
+ */
49
+ metadataPath: string;
50
+ /**
51
+ * This is required for Android only. Setting this value would save the attachments as Base64 string for easy access.
52
+ */
53
+ isRequiredAttachmentBase64: boolean;
54
+ /**
55
+ * Set an interval in seconds at which the framework has to make an attempt to send data from outbox.
56
+ * If the data-sender fails for reason, then the framework does not restart even if there are outbox items.
57
+ * In those cases, you will have to set this value, so that the framework always makes an attempt to send from outbox.
58
+ * Example:
59
+ * loginParameters.autoSendTime = '5' // Make an attempt to send data every 5 seconds.
60
+ */
61
+ autoSendTime: string;
62
+ /**
63
+ * Set the number of seconds at which GetMessage should automatically run. When this value is set, GetMessage would run in a interval as long as there are entries in Sent Items.
64
+ * You may need to set this value if your app doesn't support Push Notifications.
65
+ * By default, the framework does not do GetMessage automatically.
66
+ * Example:
67
+ * loginParameters.autoSyncTime = '5' // Make an attempt to receive data (GetMessage) every 5 seconds.
68
+ */
69
+ autoSyncTime: string;
70
+ /**
71
+ * Specify the metadata as a JSON string. This will override metadata.xml set at platform level.
72
+ */
73
+ metadataJSON: string;
74
+ /**
75
+ * Specify the demo data xml string for demo mode.
76
+ */
77
+ demoData: string;
78
+ /**
79
+ * Set 'true' if the application supports demo mode otherwise set 'false'.
80
+ */
81
+ demoModeRequired: boolean;
82
+ persistWebDb: boolean;
83
+ jwtOptions: object;
84
+ /**
85
+ * Language code to be sent to UMP. Specify a two-letter language code.
86
+ * The default value of this is 'en'.
87
+ */
88
+ loginLanguage: string;
89
+ /**
90
+ * Applicable for browser only. Set this flag to indicate that saved data should be reloaded upon launch.
91
+ */
92
+ cacheWebData: boolean;
93
+ /**
94
+ * Set this value if you the login process requires client credentials to be set.
95
+ * You can pass the client credentials with the method: |unviredSDK.setClientCredentials(credentials)|
96
+ * The passed credentials will be used based on this flag.
97
+ */
98
+ requireClientCredentials: boolean;
99
+ }
100
+
101
+ class UnviredSDK {
102
+ static getPlatformManager(): PlatformManager {
103
+ return PlatformManager.getInstance();
104
+ }
105
+
106
+ async login(_loginParameters: LoginParameters): Promise<string> {
107
+ // Returns one of: auth_activation_required, app_requires_login, login_success, app_requires_current_account, login_demo
108
+ return 'auth_activation_required';
109
+ }
110
+
111
+ async logout(): Promise<boolean> {
112
+ return true;
113
+ }
114
+
115
+ async authenticateLocal(_loginParameters: LoginParameters): Promise<string> {
116
+ // Returns one of: login_success, login_error
117
+ return 'login_success';
118
+ }
119
+
120
+ async authenticateAndActivate(_loginParameters: LoginParameters): Promise<string> {
121
+ // Returns one of: auth_activation_success, auth_activation_error
122
+ return 'auth_activation_success';
123
+ }
124
+ }
125
+
126
+ export default UnviredSDK;
@@ -0,0 +1,69 @@
1
+ import { PlatformInterface } from './PlatformInterface';
2
+
3
+ declare var Logger: any;
4
+
5
+ export class CordovaPlatformAdapter implements PlatformInterface {
6
+
7
+ // Logger
8
+ logInfo(className: string, methodName: string, message: string): void {
9
+ Logger.logInfo(className, methodName, message);
10
+ }
11
+
12
+ logError(className: string, methodName: string, message: string): void {
13
+ Logger.logError(className, methodName, message);
14
+ }
15
+
16
+ logDebug(className: string, methodName: string, message: string): void {
17
+ Logger.logDebug(className, methodName, message);
18
+ }
19
+
20
+ logWarning(className: string, methodName: string, message: string): void {
21
+ Logger.logWarning(className, methodName, message);
22
+ }
23
+
24
+ setLogLevel(level: string): void {
25
+ Logger.setLogLevel(level);
26
+ }
27
+
28
+ async getLogFileURL(): Promise<string> {
29
+ return new Promise((resolve, reject) => {
30
+ try {
31
+ const url = Logger.getLogFileURL();
32
+ resolve(url);
33
+ } catch (e) {
34
+ reject(e);
35
+ }
36
+ });
37
+ }
38
+
39
+ async getLogFileContent(): Promise<string> {
40
+ return new Promise((resolve, reject) => {
41
+ Logger.getLogFileContent((content: string) => {
42
+ resolve(content);
43
+ }, (error: any) => {
44
+ reject(error);
45
+ });
46
+ });
47
+ }
48
+
49
+ async getBackupLogFileContent(): Promise<string> {
50
+ return new Promise((resolve, reject) => {
51
+ Logger.getBackupLogFileContent((content: string) => {
52
+ resolve(content);
53
+ }, (error: any) => {
54
+ reject(error);
55
+ });
56
+ });
57
+ }
58
+
59
+ async clearLogFile(): Promise<void> {
60
+ return new Promise((resolve, reject) => {
61
+ try {
62
+ Logger.clearLogFile();
63
+ resolve();
64
+ } catch (e) {
65
+ reject(e);
66
+ }
67
+ });
68
+ }
69
+ }
@@ -0,0 +1,12 @@
1
+ export interface PlatformInterface {
2
+ // Logger
3
+ logInfo(className: string, methodName: string, message: string): void;
4
+ logError(className: string, methodName: string, message: string): void;
5
+ logDebug(className: string, methodName: string, message: string): void;
6
+ logWarning(className: string, methodName: string, message: string): void;
7
+ setLogLevel(level: string): void;
8
+ getLogFileURL(): Promise<string>;
9
+ getLogFileContent(): Promise<string>;
10
+ getBackupLogFileContent(): Promise<string>;
11
+ clearLogFile(): Promise<void>;
12
+ }
@@ -0,0 +1,35 @@
1
+ import { PlatformInterface } from './PlatformInterface';
2
+ import { ReactNativePlatformAdapter } from './ReactNativePlatformAdapter';
3
+
4
+ export class PlatformManager {
5
+ private static instance: PlatformManager;
6
+ private platformAdapter: PlatformInterface;
7
+
8
+ private constructor() {
9
+ // Default to Cordova for now, or detect environment
10
+ // In a real scenario, we might inject this or detect based on environment variables
11
+ this.platformAdapter = new ReactNativePlatformAdapter();
12
+ }
13
+
14
+ public static getInstance(): PlatformManager {
15
+ if (!PlatformManager.instance) {
16
+ PlatformManager.instance = new PlatformManager();
17
+ }
18
+ return PlatformManager.instance;
19
+ }
20
+
21
+ public getPlatformAdapter(): PlatformInterface {
22
+ return this.platformAdapter;
23
+ }
24
+
25
+ public setPlatformAdapter(adapter: PlatformInterface) {
26
+ this.platformAdapter = adapter;
27
+ }
28
+ }
29
+
30
+ // Usage:
31
+ // import { PlatformManager } from './platform/PlatformManager';
32
+ // import { ReactNativePlatformAdapter } from './platform/ReactNativePlatformAdapter';
33
+
34
+ // // Initialize with React Native adapter
35
+ // PlatformManager.getInstance().setPlatformAdapter(new ReactNativePlatformAdapter());
@@ -0,0 +1,57 @@
1
+ import { PlatformInterface } from './PlatformInterface';
2
+ import { logger, LogLevel } from '@unvired/react-native-unvired-sdk';
3
+
4
+ export class ReactNativePlatformAdapter implements PlatformInterface {
5
+ // Logger
6
+ logInfo(className: string, methodName: string, message: string): void {
7
+ logger.logInfo(className, methodName, message);
8
+
9
+ console.log(`[INFO] ${className}.${methodName}: ${message}`);
10
+ }
11
+
12
+ logError(className: string, methodName: string, message: string): void {
13
+ logger.logError(className, methodName, message);
14
+
15
+ console.error(`[ERROR] ${className}.${methodName}: ${message}`);
16
+ }
17
+
18
+ logDebug(className: string, methodName: string, message: string): void {
19
+ logger.logDebug(className, methodName, message);
20
+
21
+ console.debug(`[DEBUG] ${className}.${methodName}: ${message}`);
22
+ }
23
+
24
+ logWarning(className: string, methodName: string, message: string): void {
25
+ // TODO: Update to logger.logWarning once available in react-native-wrapper-sdk
26
+ // Using logInfo as fallback for now
27
+ if (typeof (logger as any).logWarning === 'function') {
28
+ (logger as any).logWarning(className, methodName, message);
29
+ } else {
30
+ logger.logInfo(className, methodName, `[WARNING] ${message}`);
31
+ }
32
+
33
+ console.warn(`[WARNING] ${className}.${methodName}: ${message}`);
34
+ }
35
+
36
+ setLogLevel(level: string): void {
37
+ logger.setLogLevel(level.toUpperCase() as LogLevel);
38
+
39
+ console.log(`[setLogLevel] ${level}`);
40
+ }
41
+
42
+ async getLogFileURL(): Promise<string> {
43
+ return await logger.getLogFileURL();
44
+ }
45
+
46
+ async getLogFileContent(): Promise<string> {
47
+ return await logger.getLogFileContent();
48
+ }
49
+
50
+ async getBackupLogFileContent(): Promise<string> {
51
+ return await logger.getBackupLogFileContent();
52
+ }
53
+
54
+ async clearLogFile(): Promise<void> {
55
+ await logger.clearLogFile();
56
+ }
57
+ }
package/src/index.ts CHANGED
@@ -1,5 +1,10 @@
1
1
  // Export main SDK
2
2
  import UnviredWrapper from './UnviredWrapper';
3
+
4
+ export { LoginParameters, LoginType } from './core/UnviredSDK';
5
+
3
6
  // Export the default SDK instance
4
7
  export default UnviredWrapper;
5
8
 
9
+ import UMP from '@unvired/unvired-ts-core-sdk';
10
+ export { UMP };