cordova-plugin-unvired-universal-sdk 1.0.5 → 1.0.8

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 (76) hide show
  1. package/package.json +1 -1
  2. package/plugin.xml +1 -13
  3. package/www/kernel.js +38345 -1239
  4. package/aar/README.md +0 -3
  5. package/aar/Unvired_Kernel_Android.aar +0 -0
  6. package/aar/Unvired_Kernel_HTML5_Android.aar +0 -0
  7. package/src/android/build.gradle +0 -35
  8. package/src/android/xml/provider_paths.xml +0 -21
  9. package/src/browser/UnviredPluginProxy.js +0 -2430
  10. package/src/browser/bootstrap.min.js +0 -17
  11. package/src/browser/codemirror.js +0 -9755
  12. package/src/browser/jquery-3.2.1.js +0 -10253
  13. package/src/browser/sql-wasm.wasm +0 -0
  14. package/src/browser/sql.js +0 -203
  15. package/src/browser/src_index_worker_js.unvired-db-worker.js +0 -231
  16. package/src/browser/unvired-db-worker.js +0 -166
  17. package/src/browser/vendors-node_modules_comlink_dist_esm_comlink_mjs.unvired-db-worker.js +0 -22
  18. package/src/ios/AttachmentPlugin.h +0 -21
  19. package/src/ios/AttachmentPlugin.m +0 -180
  20. package/src/ios/DataStructureHelper.h +0 -28
  21. package/src/ios/DataStructureHelper.m +0 -188
  22. package/src/ios/IOSAuthPlugin.h +0 -14
  23. package/src/ios/IOSAuthPlugin.m +0 -13
  24. package/src/ios/IOSDatabasePlugin.h +0 -28
  25. package/src/ios/IOSDatabasePlugin.m +0 -253
  26. package/src/ios/IOSFWSettingsPlugin.h +0 -65
  27. package/src/ios/IOSFWSettingsPlugin.m +0 -363
  28. package/src/ios/IOSLoggerPlugin.h +0 -34
  29. package/src/ios/IOSLoggerPlugin.m +0 -198
  30. package/src/ios/IOSLoginPlugin.h +0 -29
  31. package/src/ios/IOSLoginPlugin.m +0 -480
  32. package/src/ios/IOSProxyPlugin.h +0 -21
  33. package/src/ios/IOSProxyPlugin.m +0 -172
  34. package/src/ios/IOSSyncEnginePlugin.h +0 -54
  35. package/src/ios/IOSSyncEnginePlugin.m +0 -847
  36. package/src/ios/PluginConstants.h +0 -195
  37. package/src/ios/PluginHelper.h +0 -29
  38. package/src/ios/PluginHelper.m +0 -74
  39. package/src/ios/SyncHTML5Response.h +0 -50
  40. package/src/ios/SyncHTML5Response.m +0 -68
  41. package/www/applicationMeta/applicationMetadataParser.ts +0 -285
  42. package/www/applicationMeta/fieldConstants.ts +0 -92
  43. package/www/attachment/attachmentHelper.ts +0 -326
  44. package/www/attachment/attachmentQHelper.ts +0 -158
  45. package/www/attachment/attachmentService.ts +0 -259
  46. package/www/authenticationService.ts +0 -751
  47. package/www/database/appDatabaseManager.ts +0 -54
  48. package/www/database/databaseManager.ts +0 -616
  49. package/www/helper/dbCreateTablesManager.ts +0 -354
  50. package/www/helper/frameworkHelper.ts +0 -127
  51. package/www/helper/frameworkSettingsManager.ts +0 -287
  52. package/www/helper/getMessageTimerManager.ts +0 -81
  53. package/www/helper/httpConnection.ts +0 -1051
  54. package/www/helper/logger.ts +0 -312
  55. package/www/helper/notificationListnerHelper.ts +0 -56
  56. package/www/helper/passcodeGenerator.ts +0 -61
  57. package/www/helper/reconciler.ts +0 -1062
  58. package/www/helper/serverResponseHandler.ts +0 -677
  59. package/www/helper/serviceConstants.ts +0 -254
  60. package/www/helper/settingsHelper.ts +0 -386
  61. package/www/helper/status.ts +0 -83
  62. package/www/helper/syncInputDataManager.ts +0 -205
  63. package/www/helper/unviredAccount.ts +0 -104
  64. package/www/helper/unviredAccountManager.ts +0 -120
  65. package/www/helper/urlService.ts +0 -43
  66. package/www/helper/userSettingsManager.ts +0 -172
  67. package/www/helper/utils.ts +0 -110
  68. package/www/inbox/downloadMessageService.ts +0 -270
  69. package/www/inbox/inboxHelper.ts +0 -132
  70. package/www/inbox/inboxService.ts +0 -223
  71. package/www/outbox/outboxAttachmentManager.ts +0 -152
  72. package/www/outbox/outboxHelper.ts +0 -67
  73. package/www/outbox/outboxService.ts +0 -519
  74. package/www/subtract.ts +0 -5
  75. package/www/sum.ts +0 -4
  76. package/www/syncEngine.ts +0 -687
@@ -1,312 +0,0 @@
1
- import InboxHelper from "../inbox/inboxHelper";
2
- import FrameworkHelper from "./frameworkHelper";
3
- import { UnviredAccountManager } from "./unviredAccountManager";
4
-
5
- export enum LogLevel {
6
- Debug = "debug",
7
- Error = "error",
8
- Info = "info"
9
- }
10
-
11
- export class Logger {
12
- private static LogFolderName = "log";
13
- private static defaultLogLevel = LogLevel.Info;
14
- private static logFileName = "log.txt";
15
- private static backupLogFileName = "log_backup.txt";
16
-
17
- private static logger: any;
18
-
19
-
20
- static async initLogger() {
21
-
22
- }
23
-
24
- static async logDebug(sourceClass: string, sourceMethod: string, message: string){
25
- await Logger.loggerWithLevel(LogLevel.Debug, sourceClass, sourceMethod, message);
26
- }
27
-
28
- static async logError(sourceClass: string, sourceMethod: string, message: string) {
29
- await Logger.loggerWithLevel(LogLevel.Error, sourceClass, sourceMethod, message);
30
- }
31
-
32
- static async logInfo(sourceClass: string, sourceMethod: string, message: string) {
33
- await Logger.loggerWithLevel(LogLevel.Info, sourceClass, sourceMethod, message);
34
- }
35
-
36
- static setLogLevel(logLevel: LogLevel) {
37
- Logger.defaultLogLevel = logLevel;
38
- }
39
-
40
- private static async loggerWithLevel(level: LogLevel, sourceClass: string, sourceMethod: string, message: string) {
41
-
42
- if ((Logger.defaultLogLevel === LogLevel.Error &&
43
- (level === LogLevel.Debug || level === LogLevel.Info)) ||
44
- (Logger.defaultLogLevel === LogLevel.Info && level === LogLevel.Debug)) {
45
- return;
46
- }
47
-
48
- if (Logger.logger == null) {
49
- await Logger.initLogger();
50
- }
51
-
52
- // Local Format
53
- const currentDate = new Date();
54
- const formatter = new Intl.DateTimeFormat('en-US', {
55
- day: '2-digit',
56
- month: '2-digit',
57
- year: 'numeric',
58
- hour: '2-digit',
59
- minute: '2-digit',
60
- second: '2-digit'
61
- });
62
- const localDateString = formatter.format(currentDate);
63
-
64
- // UTC Format
65
- const dateUtc = new Date(currentDate.toUTCString());
66
- const utcFormatter = new Intl.DateTimeFormat('en-US', {
67
- day: '2-digit',
68
- month: '2-digit',
69
- year: 'numeric',
70
- hour: '2-digit',
71
- minute: '2-digit',
72
- second: '2-digit',
73
- timeZone: 'UTC'
74
- });
75
- const utcDateString = utcFormatter.format(dateUtc);
76
- let data = `${localDateString} | UTC:${utcDateString} | ${Logger.getStringFromLevel(level)} | ${sourceClass} | ${sourceMethod} | ${message}\n`;
77
-
78
- if (level === LogLevel.Error) {
79
- data = `⭕️⭕️⭕️ ${data}`;
80
- }
81
-
82
- console.log(data);
83
-
84
- // Write to log file with append functionality
85
- // try {
86
- // await Logger.appendToLogFile(data);
87
- // } catch (error) {
88
- // console.error("Failed to write to log file:", error);
89
- // }
90
- }
91
-
92
- static async getLogFileURL(): Promise<string> {
93
- return new Promise(async (resolve, reject) => {
94
- const logDirectory = await Logger.getLogDirectory();
95
- window.resolveLocalFileSystemURL(logDirectory, (dirEntry) => {
96
- dirEntry.getFile(Logger.logFileName, { create: true }, (fileEntry) => {
97
- console.log("Logger | getLogFileURL | File exists: " + fileEntry.nativeURL);
98
- resolve(fileEntry.nativeURL);
99
- },
100
- (error) => {
101
- console.log("⭕️⭕️⭕️ Logger | getLogFileURL | Get file error: " + error);
102
- reject(error);
103
- });
104
- },
105
- (error) => {
106
- console.log("⭕️⭕️⭕️ Logger | getLogFileURL | Resolve file system URL error: " + error);
107
- reject(error);
108
- });
109
- })
110
- }
111
-
112
- static async getLogFileContent(): Promise<string> {
113
- try {
114
- const logFileURL = await Logger.getLogFileURL();
115
- return await Logger.readFile(logFileURL);
116
- } catch (error) {
117
- console.error("Logger | getLogFileContent | Error reading log file:", error);
118
- return "";
119
- }
120
- }
121
-
122
- static async clearLogFile(): Promise<void> {
123
- try {
124
- const logFileURL = await Logger.getLogFileURL();
125
- await Logger.writeFile(logFileURL, "");
126
- console.log("Logger | clearLogFile | Log file cleared successfully");
127
- } catch (error) {
128
- console.error("Logger | clearLogFile | Error clearing log file:", error);
129
- throw error;
130
- }
131
- }
132
-
133
- static async getBackupLogFileURL(): Promise<string> {
134
- return new Promise(async (resolve, reject) => {
135
- const logDirectory = await Logger.getLogDirectory();
136
- window.resolveLocalFileSystemURL(logDirectory, (dirEntry) => {
137
- dirEntry.getFile(Logger.backupLogFileName, { create: true }, (fileEntry) => {
138
- console.log("Logger | getBackupLogFileURL | File exists: " + fileEntry.nativeURL);
139
- resolve(fileEntry.nativeURL);
140
- },
141
- (error) => {
142
- console.log("⭕️⭕️⭕️ Logger | getBackupLogFileURL | Get file error: " + error);
143
- reject(error);
144
- });
145
- },
146
- (error) => {
147
- console.log("⭕️⭕️⭕️ Logger | getBackupLogFileURL | Resolve file system URL error: " + error);
148
- reject(error);
149
- });
150
- })
151
- }
152
-
153
- static async getBackupLogFileContent(): Promise<string> {
154
- try {
155
- const backupLogFileURL = await Logger.getBackupLogFileURL();
156
- return await Logger.readFile(backupLogFileURL);
157
- } catch (error) {
158
- console.error("Logger | getBackupLogFileContent | Error reading backup log file:", error);
159
- return "";
160
- }
161
- }
162
-
163
- private static getLogDirectory(): Promise<string> {
164
- return new Promise(async (resolve, reject) => {
165
- const account = UnviredAccountManager.getInstance().getLastLoggedInAccount()
166
- if (account == null) {
167
- resolve("")
168
- return;
169
- }
170
- const userDirectory = await FrameworkHelper.getFolderBasedOnUserId(account.getAccountId());
171
- const logDir = `${userDirectory}${Logger.LogFolderName}`;
172
- window.resolveLocalFileSystemURL(logDir, (dir) => {
173
- console.log("Logger | getLogDirectory | Directory exists: " + dir.fullPath);
174
- resolve(dir.nativeURL);
175
- }, (error) => {
176
- console.log("Logger | getLogDirectory | Directory did not exist. Error: " + error);
177
- // Directory did not exist, so creating it.
178
- console.log("Logger | getLogDirectory | Directory did not exist, so creating it: " + logDir);
179
- window.resolveLocalFileSystemURL(userDirectory, (parentDir) => {
180
- parentDir.getDirectory(Logger.LogFolderName, {create: true}, (newDir) => {
181
- console.log("Logger | getLogDirectory | Directory created: " + newDir.nativeURL);
182
- resolve(newDir.nativeURL);
183
- }, (error) => {
184
- console.log("⭕️⭕️⭕️ Logger | getLogDirectory | Unable to create log directory. Error: " + error);
185
- resolve("");
186
- })
187
- }, (error) => {
188
- console.log("⭕️⭕️⭕️ Logger | getLogDirectory | Unable to get log directory. Error: " + error);
189
- resolve("");
190
- })
191
- })
192
- })
193
- }
194
-
195
- private static async copyLogToBackup(): Promise<void> {
196
- return new Promise(async (resolve, reject) => {
197
- try {
198
- const logFileURL = await Logger.getLogFileURL();
199
- const backupLogFileURL = await Logger.getBackupLogFileURL();
200
-
201
- const logFileContent = await Logger.readFile(logFileURL);
202
- await Logger.writeFile(backupLogFileURL, logFileContent);
203
-
204
- console.log("Logger | copyLogToBackup | Log file successfully copied to backup");
205
- resolve();
206
- } catch (error) {
207
- console.log("⭕️⭕️⭕️ Logger | copyLogToBackup | Error copying log file: " + error);
208
- reject(error);
209
- }
210
- });
211
- }
212
-
213
- private static readFile(fileURL: string): Promise<string> {
214
- return new Promise((resolve, reject) => {
215
- window.resolveLocalFileSystemURL(fileURL, (fileEntry) => {
216
- fileEntry.file((file) => {
217
- const reader = new FileReader();
218
- reader.onloadend = function() {
219
- resolve(this.result as string);
220
- };
221
- reader.onerror = (error) => reject(error);
222
- reader.readAsText(file);
223
- }, reject);
224
- }, reject);
225
- });
226
- }
227
-
228
- private static writeFile(fileURL: string, content: string): Promise<void> {
229
- return new Promise((resolve, reject) => {
230
- window.resolveLocalFileSystemURL(fileURL, (fileEntry) => {
231
- fileEntry.createWriter((fileWriter) => {
232
- fileWriter.onwriteend = () => resolve();
233
- fileWriter.onerror = (error) => reject(error);
234
- fileWriter.write(content);
235
- }, reject);
236
- }, reject);
237
- });
238
- }
239
-
240
- private static async appendToLogFile(content: string): Promise<void> {
241
- return new Promise(async (resolve, reject) => {
242
- try {
243
- const logFileURL = await Logger.getLogFileURL();
244
-
245
- // Check if file exists and get its current content
246
- let existingContent = "";
247
- try {
248
- existingContent = await Logger.readFile(logFileURL);
249
- } catch (error) {
250
- // File doesn't exist yet, which is fine for new logs
251
- console.log("Logger | appendToLogFile | Creating new log file");
252
- }
253
-
254
- // Check if we need to rotate logs due to size
255
- await Logger.checkAndRotateLogFile(existingContent);
256
-
257
- // Get updated content after potential rotation
258
- try {
259
- existingContent = await Logger.readFile(logFileURL);
260
- } catch (error) {
261
- // File was rotated, start fresh
262
- existingContent = "";
263
- }
264
-
265
- // Append new content to existing content
266
- const newContent = existingContent + content;
267
-
268
- // Write the combined content back to file
269
- await Logger.writeFile(logFileURL, newContent);
270
-
271
- resolve();
272
- } catch (error) {
273
- console.error("Logger | appendToLogFile | Error appending to log file:", error);
274
- reject(error);
275
- }
276
- });
277
- }
278
-
279
- private static async checkAndRotateLogFile(currentContent: string): Promise<void> {
280
- // Define maximum log file size (5MB)
281
- const MAX_LOG_SIZE = 5 * 1024 * 1024; // 5MB in bytes
282
-
283
- if (currentContent.length > MAX_LOG_SIZE) {
284
- try {
285
- // Copy current log to backup
286
- await Logger.copyLogToBackup();
287
-
288
- // Clear the main log file by writing empty content
289
- const logFileURL = await Logger.getLogFileURL();
290
- await Logger.writeFile(logFileURL, "");
291
-
292
- console.log("Logger | checkAndRotateLogFile | Log file rotated due to size limit");
293
- } catch (error) {
294
- console.error("Logger | checkAndRotateLogFile | Error rotating log file:", error);
295
- }
296
- }
297
- }
298
-
299
- private static getStringFromLevel(value:LogLevel) {
300
- switch (value) {
301
- case LogLevel.Info:
302
- return "IMPORTANT";
303
- case LogLevel.Error:
304
- return "ERROR";
305
- case LogLevel.Debug:
306
- return "DEBUG";
307
- default:
308
- break;
309
- }
310
- return "";
311
- }
312
- }
@@ -1,56 +0,0 @@
1
- import { Logger } from "./logger";
2
-
3
- export const TYPE = "type";
4
- export const DATA = "data";
5
- export const MESSAGE = "message";
6
- export const ERROR = "error";
7
- export const ERROR_DETAIL = "errorDetail";
8
-
9
- export const kAttachmentItem = "kAttachmentItem";
10
- export const kError = "kError";
11
-
12
- export enum NotificationListnerType {
13
- data_send = 0,
14
- data_changed = 1,
15
- data_received = 2,
16
- app_reset = 3,
17
- attachmentDownloadSuccess = 4,
18
- attachmentDownloadError = 5, // Notify application with error message and attchment item on attachment download success
19
- incomingDataProcessingFinished = 6,
20
- attachmentDownloadWaiting = 7, // Notify application when attachment download is waiting on the server
21
- infoMessage = 8, // Notify application with any InfoMessages
22
- serverError = 9,
23
- attachmentDownloadCompleted = 10,
24
- sentItemChanged = 11,
25
- jwtTokenUpdated = 12,
26
- jwtTokenExpired = 13
27
- }
28
-
29
- const fileName = "NotificationListenerHelper";
30
-
31
- export class NotificationListenerHelper {
32
- public static dataSenderListener: any = null;
33
- public static synchronizationStateListener: any = null;
34
- public static postDataSenderNotification(data: any, notificationType: NotificationListnerType) {
35
- if (this.dataSenderListener === null) {
36
- Logger.logInfo(fileName, "postDataSenderNotification", "Data sender listener is null");
37
- return;
38
- }
39
- const notificationData = {
40
- [TYPE]: notificationType,
41
- [MESSAGE]: "",
42
- [DATA]: data ?? [],
43
- [ERROR]: "",
44
- [ERROR_DETAIL]: ""
45
- }
46
- this.dataSenderListener(notificationData);
47
- }
48
-
49
- public static postSynchronizationStateNotification(postMessage: string) {
50
- if (this.synchronizationStateListener === null) {
51
- Logger.logInfo(fileName, "postSynchronizationStateNotification", "Synchronization state listener is null");
52
- return;
53
- }
54
- this.synchronizationStateListener(postMessage);
55
- }
56
- }
@@ -1,61 +0,0 @@
1
- import * as CryptoJS from 'crypto-js';
2
- import * as base32 from 'hi-base32';
3
- import { Logger } from "./logger";
4
- const fileName = "PassCodeGenerator";
5
-
6
- class PassCodeGenerator {
7
- private static readonly PASS_CODE_LENGTH: number = 6;
8
- private static readonly INTERVAL: number = 30;
9
- private static readonly ADJACENT_INTERVALS: number = 5;
10
- private static readonly PIN_MODULO: number = Math.pow(10, PassCodeGenerator.PASS_CODE_LENGTH);
11
-
12
- computePin(secret: string | null, feUserId: string | null): string[] {
13
- const timeStamp = this.getTimeStamp();
14
- if (!secret || secret.length === 0) {
15
- return [timeStamp];
16
- }
17
-
18
- try {
19
- const keyBytes = base32.decode.asBytes(secret.toUpperCase());
20
- const keyWordArray = CryptoJS.lib.WordArray.create(keyBytes);
21
- const hmacSha1 = CryptoJS.HmacSHA1(feUserId + '~' + timeStamp, keyWordArray);
22
-
23
- const hashBytes = CryptoJS.enc.Hex.parse(hmacSha1.toString());
24
- let offset = parseInt(hashBytes.toString(CryptoJS.enc.Hex).slice(-1), 16) & 0xf;
25
-
26
- let result = 0;
27
- for (let i = 0; i < 4; ++i) {
28
- result = (result << 8) + parseInt(hashBytes.toString(CryptoJS.enc.Hex).substr(offset * 2, 2), 16);
29
- offset++;
30
- }
31
- const truncatedHash = result & 0x7fffffff;
32
- const pinValue = truncatedHash % PassCodeGenerator.PIN_MODULO;
33
- const resultPin = this.padOutput(pinValue);
34
- return [resultPin, timeStamp];
35
- } catch (e) {
36
- Logger.logError(fileName, "computePin", "Error while generating pin. Error: " + JSON.stringify(e));
37
- throw e;
38
- }
39
- }
40
-
41
- getTimeStamp(): string {
42
- const currentDate = new Date();
43
- const utcDate = new Date(currentDate.getTime() + currentDate.getTimezoneOffset() * 60000)
44
- const year = utcDate.getUTCFullYear();
45
- const month = String(utcDate.getUTCMonth() + 1).padStart(2, '0');
46
- const day = String(utcDate.getUTCDate()).padStart(2, '0');
47
- const hours = String(utcDate.getUTCHours()).padStart(2, '0');
48
- const minutes = String(utcDate.getUTCMinutes()).padStart(2, '0');
49
- return `${year}-${month}-${day} ${hours}:${minutes}`;
50
- }
51
-
52
- padOutput(value: number): string {
53
- let result = value.toString();
54
- while (result.length < PassCodeGenerator.PASS_CODE_LENGTH) {
55
- result = '0' + result;
56
- }
57
- return result;
58
- }
59
- }
60
-
61
- export default new PassCodeGenerator();