mcard-js 1.0.0

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 (111) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +117 -0
  3. package/dist/__mocks__/better-sqlite3.js +20 -0
  4. package/dist/__mocks__/better-sqlite3.js.map +1 -0
  5. package/dist/config/config_constants.js +188 -0
  6. package/dist/config/config_constants.js.map +1 -0
  7. package/dist/config/env_parameters.js +62 -0
  8. package/dist/config/env_parameters.js.map +1 -0
  9. package/dist/content/model/content_type_detector.js +89 -0
  10. package/dist/content/model/content_type_detector.js.map +1 -0
  11. package/dist/core/card-collection.js +279 -0
  12. package/dist/core/card-collection.js.map +1 -0
  13. package/dist/core/event-producer.js +132 -0
  14. package/dist/core/event-producer.js.map +1 -0
  15. package/dist/core/g_time.js +201 -0
  16. package/dist/core/g_time.js.map +1 -0
  17. package/dist/core/hash/enums.js +19 -0
  18. package/dist/core/hash/enums.js.map +1 -0
  19. package/dist/core/hash/validator.js +260 -0
  20. package/dist/core/hash/validator.js.map +1 -0
  21. package/dist/core/mcard.js +205 -0
  22. package/dist/core/mcard.js.map +1 -0
  23. package/dist/engine/sqlite_engine.js +723 -0
  24. package/dist/engine/sqlite_engine.js.map +1 -0
  25. package/dist/index.js +10 -0
  26. package/dist/index.js.map +1 -0
  27. package/dist/middleware/mcardPersistenceMiddleware.js +45 -0
  28. package/dist/middleware/mcardPersistenceMiddleware.js.map +1 -0
  29. package/dist/models/database_schemas.js +31 -0
  30. package/dist/models/database_schemas.js.map +1 -0
  31. package/dist/services/logger.js +80 -0
  32. package/dist/services/logger.js.map +1 -0
  33. package/dist/services/mcardStorageService.js +36 -0
  34. package/dist/services/mcardStorageService.js.map +1 -0
  35. package/dist/utils/actionHelpers.js +25 -0
  36. package/dist/utils/actionHelpers.js.map +1 -0
  37. package/dist/utils/bufferContentHelper.js +393 -0
  38. package/dist/utils/bufferContentHelper.js.map +1 -0
  39. package/dist/utils/bufferPolyfill.js +198 -0
  40. package/dist/utils/bufferPolyfill.js.map +1 -0
  41. package/dist/utils/content-detection.js +74 -0
  42. package/dist/utils/content-detection.js.map +1 -0
  43. package/dist/utils/content-utils.js +269 -0
  44. package/dist/utils/content-utils.js.map +1 -0
  45. package/dist/utils/content_type_detector copy.js +480 -0
  46. package/dist/utils/content_type_detector copy.js.map +1 -0
  47. package/dist/utils/content_type_detector.js +480 -0
  48. package/dist/utils/content_type_detector.js.map +1 -0
  49. package/dist/utils/cryptoPolyfill.js +166 -0
  50. package/dist/utils/cryptoPolyfill.js.map +1 -0
  51. package/dist/utils/dotenv-browser.js +35 -0
  52. package/dist/utils/dotenv-browser.js.map +1 -0
  53. package/dist/utils/environmentDetector.js +93 -0
  54. package/dist/utils/environmentDetector.js.map +1 -0
  55. package/dist/utils/logWriter.js +27 -0
  56. package/dist/utils/logWriter.js.map +1 -0
  57. package/dist/utils/serviceWorkerManager.js +118 -0
  58. package/dist/utils/serviceWorkerManager.js.map +1 -0
  59. package/dist/utils/test-content-detection.js +79 -0
  60. package/dist/utils/test-content-detection.js.map +1 -0
  61. package/dist/utils/test-detection-fix.js +121 -0
  62. package/dist/utils/test-detection-fix.js.map +1 -0
  63. package/dist/utils/test-format-conversion.js +170 -0
  64. package/dist/utils/test-format-conversion.js.map +1 -0
  65. package/dist/utils/test-mov-viewer.js +57 -0
  66. package/dist/utils/test-mov-viewer.js.map +1 -0
  67. package/dist/utils/testDetection.js +21 -0
  68. package/dist/utils/testDetection.js.map +1 -0
  69. package/dist/utils/textEncoderPolyfill.js +87 -0
  70. package/dist/utils/textEncoderPolyfill.js.map +1 -0
  71. package/package.json +74 -0
  72. package/src/__mocks__/better-sqlite3.js +14 -0
  73. package/src/config/config_constants.js +227 -0
  74. package/src/config/env_parameters.js +69 -0
  75. package/src/content/model/content_type_detector.js +87 -0
  76. package/src/core/card-collection.js +300 -0
  77. package/src/core/event-producer.js +160 -0
  78. package/src/core/g_time.js +215 -0
  79. package/src/core/hash/enums.js +13 -0
  80. package/src/core/hash/validator.js +271 -0
  81. package/src/core/mcard.js +203 -0
  82. package/src/engine/sqlite_engine.js +755 -0
  83. package/src/index.js +10 -0
  84. package/src/middleware/mcardPersistenceMiddleware.js +45 -0
  85. package/src/models/database_schemas.js +26 -0
  86. package/src/services/logger.js +74 -0
  87. package/src/services/mcardStorageService.js +34 -0
  88. package/src/utils/actionHelpers.js +13 -0
  89. package/src/utils/bufferContentHelper.js +436 -0
  90. package/src/utils/bufferPolyfill.js +202 -0
  91. package/src/utils/cn.ts +6 -0
  92. package/src/utils/content-detection.js +66 -0
  93. package/src/utils/content-utils.js +250 -0
  94. package/src/utils/content_type_detector copy.js +501 -0
  95. package/src/utils/content_type_detector.js +501 -0
  96. package/src/utils/cryptoPolyfill.js +180 -0
  97. package/src/utils/dateUtils.ts +18 -0
  98. package/src/utils/dbInitializer.ts +27 -0
  99. package/src/utils/dotenv-browser.js +29 -0
  100. package/src/utils/environmentDetector.js +92 -0
  101. package/src/utils/logWriter.js +20 -0
  102. package/src/utils/serviceWorkerManager.js +122 -0
  103. package/src/utils/stateWatcher.ts +78 -0
  104. package/src/utils/storeAdapter copy.ts +157 -0
  105. package/src/utils/storeAdapter.ts +157 -0
  106. package/src/utils/test-content-detection.js +71 -0
  107. package/src/utils/test-detection-fix.js +136 -0
  108. package/src/utils/test-format-conversion.js +165 -0
  109. package/src/utils/test-mov-viewer.js +59 -0
  110. package/src/utils/testDetection.js +16 -0
  111. package/src/utils/textEncoderPolyfill.js +88 -0
@@ -0,0 +1,205 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.MCardFromData = exports.MCard = void 0;
8
+ var _bufferPolyfill = require("../utils/bufferPolyfill.js");
9
+ var _cryptoPolyfill = require("../utils/cryptoPolyfill.js");
10
+ var _g_time = _interopRequireDefault(require("./g_time.js"));
11
+ var _config_constants = require("../config/config_constants.js");
12
+ var _validator = _interopRequireDefault(require("./hash/validator.js"));
13
+ var _content_type_detector = _interopRequireDefault(require("../utils/content_type_detector.js"));
14
+ // Corrected path
15
+
16
+ // Corrected path (assuming content_type_detector.js is in src/utils/)
17
+
18
+ // Create a mock HashValidator if the real one fails to load
19
+ let hashValidator;
20
+ try {
21
+ hashValidator = new _validator.default(_bufferPolyfill.SafeBuffer.from(''), 'sha256');
22
+ } catch (error) {
23
+ console.warn('Failed to initialize HashValidator, using mock implementation');
24
+ hashValidator = {
25
+ computeHash: (data, algorithm) => {
26
+ // Simple mock implementation for testing
27
+ const hash = (0, _cryptoPolyfill.createHash)(algorithm || 'sha256');
28
+ return hash.update(data).digest('hex');
29
+ },
30
+ validate: () => Promise.resolve(true)
31
+ };
32
+ }
33
+ class MCard {
34
+ constructor(content, hashFunction = _config_constants.HashAlgorithm.DEFAULT, options = {}) {
35
+ // Validate input
36
+ if (content === null) {
37
+ throw new Error('Content cannot be None');
38
+ }
39
+ if (hashFunction === null) {
40
+ throw new Error('hash_function cannot be None');
41
+ }
42
+
43
+ // Track the original content type
44
+ this._originalContentType = typeof content;
45
+
46
+ // Convert input content to Buffer and store as this._content
47
+ if (_bufferPolyfill.SafeBuffer.isBuffer(content)) {
48
+ this._content = content;
49
+ } else if (typeof content === 'string') {
50
+ this._content = _bufferPolyfill.SafeBuffer.from(content, 'utf-8');
51
+ } else if (typeof content === 'object' && content !== null) {
52
+ try {
53
+ // Ensure that plain objects are not empty before stringifying
54
+ if (Object.keys(content).length === 0 && content.constructor === Object) {
55
+ throw new Error('Object content cannot be empty.');
56
+ }
57
+ this._content = _bufferPolyfill.SafeBuffer.from(JSON.stringify(content), 'utf-8');
58
+ } catch (e) {
59
+ throw new Error(`Failed to stringify object content for MCard: ${e.message}`);
60
+ }
61
+ } else {
62
+ if (content === undefined) {
63
+ throw new Error('Content cannot be undefined.');
64
+ }
65
+ throw new Error(`Unsupported content type for MCard: ${typeof content}`);
66
+ }
67
+
68
+ // Validate content (which is now this._content, a Buffer) is not empty
69
+ if (this._content.length === 0) {
70
+ throw new Error('Content cannot be empty after conversion to Buffer.');
71
+ }
72
+
73
+ // Compute hash using this._content
74
+ const forcedHashAlgorithm = options.forceHashAlgorithm || hashFunction;
75
+ try {
76
+ this.hash = hashValidator.computeHash(this._content, (0, _config_constants.HashAlgorithm)(forcedHashAlgorithm));
77
+ this.hash_algorithm = (0, _config_constants.HashAlgorithm)(forcedHashAlgorithm);
78
+ } catch (error) {
79
+ console.error('Error computing hash:', error);
80
+ // Fallback to a simple hash if the validator fails
81
+ const hash = (0, _cryptoPolyfill.createHash)(forcedHashAlgorithm || 'sha256');
82
+ this.hash = hash.update(this._content).digest('hex');
83
+ this.hash_algorithm = forcedHashAlgorithm || 'sha256';
84
+ }
85
+
86
+ // Generate timestamp
87
+ this.g_time = _g_time.default.stamp_now(this.hash_algorithm);
88
+ }
89
+
90
+ // Getter methods
91
+ get_content() {
92
+ // If the content is a Uint8Array and was created from a string, convert it back to a string
93
+ if (this._content instanceof Uint8Array && this._originalContentType === 'string') {
94
+ return new TextDecoder('utf-8').decode(this._content);
95
+ }
96
+ return this._content;
97
+ }
98
+
99
+ // Getter for content property (for backward compatibility with tests)
100
+ get content() {
101
+ // Ensure we return a Buffer
102
+ if (_bufferPolyfill.SafeBuffer.isBuffer(this._content)) {
103
+ return this._content;
104
+ }
105
+ // If it's a Uint8Array, convert to Buffer
106
+ if (this._content instanceof Uint8Array) {
107
+ return new _bufferPolyfill.SafeBuffer(this._content);
108
+ }
109
+ // For any other type, convert to Buffer
110
+ return new _bufferPolyfill.SafeBuffer(String(this._content));
111
+ }
112
+
113
+ // Setter for content property (for backward compatibility with tests)
114
+ set content(value) {
115
+ this._content = value;
116
+ }
117
+
118
+ // Convert to dictionary representation
119
+ to_dict() {
120
+ // Ensure content is a Buffer
121
+ let content = this._content;
122
+ if (!Buffer.isBuffer(content)) {
123
+ content = Buffer.from(content);
124
+ }
125
+ return {
126
+ content: content,
127
+ hash: this.hash,
128
+ g_time: this.g_time,
129
+ hash_algorithm: this.hash_algorithm
130
+ };
131
+ }
132
+ get_hash() {
133
+ return this.hash;
134
+ }
135
+ get_g_time() {
136
+ return this.g_time;
137
+ }
138
+
139
+ // Utility methods
140
+ equals(other) {
141
+ return this.hash === other.hash;
142
+ }
143
+ }
144
+ exports.MCard = MCard;
145
+ class MCardFromData extends MCard {
146
+ constructor(content, hash_value, g_time_str) {
147
+ // Validate input parameters
148
+ if (!content) {
149
+ throw new Error("Content cannot be null or empty");
150
+ }
151
+
152
+ // Ensure content is a Buffer
153
+ if (!_bufferPolyfill.SafeBuffer.isBuffer(content)) {
154
+ throw new Error("Content must be a Buffer when initializing from existing data.");
155
+ }
156
+ if (!hash_value) {
157
+ throw new Error("Hash value cannot be None or empty");
158
+ }
159
+ if (!g_time_str) {
160
+ throw new Error("g_time string cannot be None or empty");
161
+ }
162
+
163
+ // Call parent constructor with content and hash function
164
+ super(content, _g_time.default.get_hash_function(g_time_str));
165
+
166
+ // Override the hash generated by parent constructor
167
+ this.hash = hash_value;
168
+ this.g_time = g_time_str; // Directly assign the provided g_time string
169
+ this.hash_function = _g_time.default.get_hash_function(this.g_time);
170
+
171
+ // Detect content type (for metadata only, don't modify the content)
172
+ const interpreter = new _content_type_detector.default();
173
+ let contentForType = content;
174
+
175
+ // For type detection, convert to Buffer if needed
176
+ if (!(content instanceof Buffer) && typeof content !== 'string') {
177
+ contentForType = _bufferPolyfill.SafeBuffer.from(JSON.stringify(content), 'utf-8');
178
+ } else if (typeof content === 'string') {
179
+ contentForType = _bufferPolyfill.SafeBuffer.from(content, 'utf-8');
180
+ }
181
+ this._content_type = interpreter.detectContentType(contentForType);
182
+ }
183
+
184
+ // Getter method for content type
185
+ get_content_type() {
186
+ return this._content_type;
187
+ }
188
+
189
+ // Async method for content type (for compatibility)
190
+ async getContentType() {
191
+ return this._content_type;
192
+ }
193
+
194
+ // Update to_dict to include content type
195
+ to_dict() {
196
+ return {
197
+ content: this.content,
198
+ hash: this.hash,
199
+ g_time: this.g_time,
200
+ content_type: this._content_type
201
+ };
202
+ }
203
+ }
204
+ exports.MCardFromData = MCardFromData;
205
+ //# sourceMappingURL=mcard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcard.js","names":["_bufferPolyfill","require","_cryptoPolyfill","_g_time","_interopRequireDefault","_config_constants","_validator","_content_type_detector","hashValidator","HashValidator","SafeBuffer","from","error","console","warn","computeHash","data","algorithm","hash","createHash","update","digest","validate","Promise","resolve","MCard","constructor","content","hashFunction","HashAlgorithm","DEFAULT","options","Error","_originalContentType","isBuffer","_content","Object","keys","length","JSON","stringify","e","message","undefined","forcedHashAlgorithm","forceHashAlgorithm","hash_algorithm","g_time","GTime","stamp_now","get_content","Uint8Array","TextDecoder","decode","String","value","to_dict","Buffer","get_hash","get_g_time","equals","other","exports","MCardFromData","hash_value","g_time_str","get_hash_function","hash_function","interpreter","ContentTypeInterpreter","contentForType","_content_type","detectContentType","get_content_type","getContentType","content_type"],"sources":["../../src/core/mcard.js"],"sourcesContent":["import { SafeBuffer } from '../utils/bufferPolyfill.js';\nimport { createHash } from '../utils/cryptoPolyfill.js';\nimport GTime from './g_time.js';\nimport { HashAlgorithm } from '../config/config_constants.js'; // Corrected path\nimport HashValidator from './hash/validator.js';\nimport ContentTypeInterpreter from '../utils/content_type_detector.js'; // Corrected path (assuming content_type_detector.js is in src/utils/)\n\n// Create a mock HashValidator if the real one fails to load\nlet hashValidator;\ntry {\n hashValidator = new HashValidator(SafeBuffer.from(''), 'sha256');\n} catch (error) {\n console.warn('Failed to initialize HashValidator, using mock implementation');\n hashValidator = {\n computeHash: (data, algorithm) => {\n // Simple mock implementation for testing\n const hash = createHash(algorithm || 'sha256');\n return hash.update(data).digest('hex');\n },\n validate: () => Promise.resolve(true)\n };\n}\n\nclass MCard {\n constructor(content, hashFunction = HashAlgorithm.DEFAULT, options = {}) {\n // Validate input\n if (content === null) {\n throw new Error('Content cannot be None');\n }\n\n if (hashFunction === null) {\n throw new Error('hash_function cannot be None');\n }\n\n // Track the original content type\n this._originalContentType = typeof content;\n \n // Convert input content to Buffer and store as this._content\n if (SafeBuffer.isBuffer(content)) {\n this._content = content;\n } else if (typeof content === 'string') {\n this._content = SafeBuffer.from(content, 'utf-8');\n } else if (typeof content === 'object' && content !== null) {\n try {\n // Ensure that plain objects are not empty before stringifying\n if (Object.keys(content).length === 0 && content.constructor === Object) {\n throw new Error('Object content cannot be empty.');\n }\n this._content = SafeBuffer.from(JSON.stringify(content), 'utf-8');\n } catch (e) {\n throw new Error(`Failed to stringify object content for MCard: ${e.message}`);\n }\n } else {\n if (content === undefined) {\n throw new Error('Content cannot be undefined.');\n }\n throw new Error(`Unsupported content type for MCard: ${typeof content}`);\n }\n\n // Validate content (which is now this._content, a Buffer) is not empty\n if (this._content.length === 0) {\n throw new Error('Content cannot be empty after conversion to Buffer.');\n }\n\n // Compute hash using this._content\n const forcedHashAlgorithm = options.forceHashAlgorithm || hashFunction;\n try {\n this.hash = hashValidator.computeHash(this._content, HashAlgorithm(forcedHashAlgorithm));\n this.hash_algorithm = HashAlgorithm(forcedHashAlgorithm);\n } catch (error) {\n console.error('Error computing hash:', error);\n // Fallback to a simple hash if the validator fails\n const hash = createHash(forcedHashAlgorithm || 'sha256');\n this.hash = hash.update(this._content).digest('hex');\n this.hash_algorithm = forcedHashAlgorithm || 'sha256';\n }\n\n // Generate timestamp\n this.g_time = GTime.stamp_now(this.hash_algorithm);\n }\n\n // Getter methods\n get_content() {\n // If the content is a Uint8Array and was created from a string, convert it back to a string\n if (this._content instanceof Uint8Array && this._originalContentType === 'string') {\n return new TextDecoder('utf-8').decode(this._content);\n }\n return this._content;\n }\n \n // Getter for content property (for backward compatibility with tests)\n get content() {\n // Ensure we return a Buffer\n if (SafeBuffer.isBuffer(this._content)) {\n return this._content;\n }\n // If it's a Uint8Array, convert to Buffer\n if (this._content instanceof Uint8Array) {\n return new SafeBuffer(this._content);\n }\n // For any other type, convert to Buffer\n return new SafeBuffer(String(this._content));\n }\n \n // Setter for content property (for backward compatibility with tests)\n set content(value) {\n this._content = value;\n }\n\n // Convert to dictionary representation\n to_dict() {\n // Ensure content is a Buffer\n let content = this._content;\n if (!Buffer.isBuffer(content)) {\n content = Buffer.from(content);\n }\n \n return {\n content: content,\n hash: this.hash,\n g_time: this.g_time,\n hash_algorithm: this.hash_algorithm\n };\n }\n\n get_hash() {\n return this.hash;\n }\n\n get_g_time() {\n return this.g_time;\n }\n\n // Utility methods\n equals(other) {\n return this.hash === other.hash;\n }\n}\n\nclass MCardFromData extends MCard {\n constructor(content, hash_value, g_time_str) {\n // Validate input parameters\n if (!content) {\n throw new Error(\"Content cannot be null or empty\");\n }\n\n // Ensure content is a Buffer\n if (!SafeBuffer.isBuffer(content)) {\n throw new Error(\"Content must be a Buffer when initializing from existing data.\");\n }\n\n if (!hash_value) {\n throw new Error(\"Hash value cannot be None or empty\");\n }\n\n if (!g_time_str) {\n throw new Error(\"g_time string cannot be None or empty\");\n }\n\n // Call parent constructor with content and hash function\n super(content, GTime.get_hash_function(g_time_str));\n\n // Override the hash generated by parent constructor\n this.hash = hash_value;\n this.g_time = g_time_str; // Directly assign the provided g_time string\n this.hash_function = GTime.get_hash_function(this.g_time);\n\n // Detect content type (for metadata only, don't modify the content)\n const interpreter = new ContentTypeInterpreter();\n let contentForType = content;\n \n // For type detection, convert to Buffer if needed\n if (!(content instanceof Buffer) && typeof content !== 'string') {\n contentForType = SafeBuffer.from(JSON.stringify(content), 'utf-8');\n } else if (typeof content === 'string') {\n contentForType = SafeBuffer.from(content, 'utf-8');\n }\n \n this._content_type = interpreter.detectContentType(contentForType);\n }\n\n // Getter method for content type\n get_content_type() {\n return this._content_type;\n }\n\n // Async method for content type (for compatibility)\n async getContentType() {\n return this._content_type;\n }\n\n // Update to_dict to include content type\n to_dict() {\n return {\n content: this.content,\n hash: this.hash,\n g_time: this.g_time,\n content_type: this._content_type\n };\n }\n}\n\nexport { MCard, MCard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