jsf.js_next_gen 4.0.1-beta.6 → 4.0.1-beta.7

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 (175) hide show
  1. package/dist/docs/assets/style.css +4 -5
  2. package/dist/window/faces-development.js +19 -28
  3. package/dist/window/faces-development.js.br +0 -0
  4. package/dist/window/faces-development.js.gz +0 -0
  5. package/dist/window/faces-development.js.map +1 -1
  6. package/dist/window/faces.js +1 -1
  7. package/dist/window/faces.js.br +0 -0
  8. package/dist/window/faces.js.gz +0 -0
  9. package/dist/window/faces.js.map +1 -1
  10. package/dist/window/jsf-development.js +19 -28
  11. package/dist/window/jsf-development.js.br +0 -0
  12. package/dist/window/jsf-development.js.gz +0 -0
  13. package/dist/window/jsf-development.js.map +1 -1
  14. package/dist/window/jsf.js +1 -1
  15. package/dist/window/jsf.js.br +0 -0
  16. package/dist/window/jsf.js.gz +0 -0
  17. package/dist/window/jsf.js.map +1 -1
  18. package/package.json +10 -10
  19. package/src/main/typescript/impl/xhrCore/XhrRequest.ts +1 -1
  20. package/src/main/typescript/test/frameworkBase/_ext/monadish/DomQueryTest.spec.ts +1 -1
  21. package/src/main/typescript/test/frameworkBase/_ext/shared/StandardInits.ts +86 -0
  22. package/src/main/typescript/test/frameworkBase/_ext/shared/XmlResponses.ts +53 -0
  23. package/src/main/typescript/test/frameworkBase/_ext/shared/fixtures/css/bootstrap-icons.css +15 -0
  24. package/src/main/typescript/test/frameworkBase/_ext/shared/fixtures/css/tobago.css +15 -0
  25. package/src/main/typescript/test/frameworkBase/_ext/shared/fixtures/js/tobago.js +15 -0
  26. package/src/main/typescript/test/xhrCore/ErrorChainTest.spec.ts +23 -0
  27. package/src/main/typescript/test/xhrCore/RequestParamsTest.spec.ts +1 -1
  28. package/src/main/typescript/test/xhrCore/ResponseTest23.spec.ts +18 -0
  29. package/target/AssocArray.js +281 -0
  30. package/target/AssocArray.js.map +1 -0
  31. package/target/Config.js +235 -0
  32. package/target/Config.js.map +1 -0
  33. package/target/CryptoExtensions.js +112 -0
  34. package/target/CryptoExtensions.js.map +1 -0
  35. package/target/DomQuery.js +1963 -0
  36. package/target/DomQuery.js.map +1 -0
  37. package/target/Es2019Array.js +117 -0
  38. package/target/Es2019Array.js.map +1 -0
  39. package/target/Global.js +38 -0
  40. package/target/Global.js.map +1 -0
  41. package/target/IDomQuery.js +3 -0
  42. package/target/IDomQuery.js.map +1 -0
  43. package/target/Lang.js +183 -0
  44. package/target/Lang.js.map +1 -0
  45. package/target/Messaging.js +645 -0
  46. package/target/Messaging.js.map +1 -0
  47. package/target/Monad.js +330 -0
  48. package/target/Monad.js.map +1 -0
  49. package/target/Promise.js +296 -0
  50. package/target/Promise.js.map +1 -0
  51. package/target/PromiseShim.js +30 -0
  52. package/target/PromiseShim.js.map +1 -0
  53. package/target/SourcesCollectors.js +444 -0
  54. package/target/SourcesCollectors.js.map +1 -0
  55. package/target/Stream.js +562 -0
  56. package/target/Stream.js.map +1 -0
  57. package/target/TagBuilder.js +178 -0
  58. package/target/TagBuilder.js.map +1 -0
  59. package/target/XmlQuery.js +84 -0
  60. package/target/XmlQuery.js.map +1 -0
  61. package/target/index.js +80 -0
  62. package/target/index.js.map +1 -0
  63. package/target/index_core.js +76 -0
  64. package/target/index_core.js.map +1 -0
  65. package/target/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js +1 -1
  66. package/target/test/frameworkBase/_ext/shared/StandardInits.js +85 -0
  67. package/target/test/frameworkBase/_ext/shared/StandardInits.js.map +1 -1
  68. package/target/test/frameworkBase/_ext/shared/XmlResponses.js +53 -1
  69. package/target/test/frameworkBase/_ext/shared/XmlResponses.js.map +1 -1
  70. package/target/test/xhrCore/ErrorChainTest.spec.js +21 -0
  71. package/target/test/xhrCore/ErrorChainTest.spec.js.map +1 -1
  72. package/target/test/xhrCore/RequestParamsTest.spec.js.map +1 -1
  73. package/target/test/xhrCore/ResponseTest23.spec.js +13 -0
  74. package/target/test/xhrCore/ResponseTest23.spec.js.map +1 -1
  75. package/target/types/main/typescript/AssocArray.d.ts +86 -0
  76. package/target/types/main/typescript/Config.d.ts +94 -0
  77. package/target/types/main/typescript/CryptoExtensions.d.ts +87 -0
  78. package/target/types/main/typescript/DomQuery.d.ts +587 -0
  79. package/target/types/main/typescript/Es2019Array.d.ts +30 -0
  80. package/target/types/main/typescript/Global.d.ts +23 -0
  81. package/target/types/main/typescript/IDomQuery.d.ts +480 -0
  82. package/target/types/main/typescript/Lang.d.ts +97 -0
  83. package/target/types/main/typescript/Messaging.d.ts +285 -0
  84. package/target/types/main/typescript/Monad.d.ts +161 -0
  85. package/target/types/main/typescript/Promise.d.ts +58 -0
  86. package/target/types/main/typescript/PromiseShim.d.ts +22 -0
  87. package/target/types/main/typescript/SourcesCollectors.d.ts +280 -0
  88. package/target/types/main/typescript/Stream.d.ts +284 -0
  89. package/target/types/main/typescript/TagBuilder.d.ts +50 -0
  90. package/target/types/main/typescript/XmlQuery.d.ts +31 -0
  91. package/target/types/main/typescript/api/_api.d.ts +182 -0
  92. package/target/types/main/typescript/api/faces.d.ts +17 -0
  93. package/target/types/main/typescript/api/jsf.d.ts +17 -0
  94. package/target/types/main/typescript/impl/AjaxImpl.d.ts +164 -0
  95. package/target/types/main/typescript/impl/PushImpl.d.ts +38 -0
  96. package/target/types/main/typescript/impl/core/Const.d.ts +138 -0
  97. package/target/types/main/typescript/impl/core/ImplTypes.d.ts +16 -0
  98. package/target/types/main/typescript/impl/i18n/Messages.d.ts +102 -0
  99. package/target/types/main/typescript/impl/util/Assertions.d.ts +46 -0
  100. package/target/types/main/typescript/impl/util/AsyncRunnable.d.ts +112 -0
  101. package/target/types/main/typescript/impl/util/ExtDomQuery.d.ts +100 -0
  102. package/target/types/main/typescript/impl/util/FileUtils.d.ts +25 -0
  103. package/target/types/main/typescript/impl/util/HiddenInputBuilder.d.ts +37 -0
  104. package/target/types/main/typescript/impl/util/IListener.d.ts +18 -0
  105. package/target/types/main/typescript/impl/util/Lang.d.ts +138 -0
  106. package/target/types/main/typescript/impl/util/XhrQueueController.d.ts +51 -0
  107. package/target/types/main/typescript/impl/xhrCore/ErrorData.d.ts +37 -0
  108. package/target/types/main/typescript/impl/xhrCore/EventData.d.ts +25 -0
  109. package/target/types/main/typescript/impl/xhrCore/IResponseProcessor.d.ts +136 -0
  110. package/target/types/main/typescript/impl/xhrCore/RequestDataResolver.d.ts +84 -0
  111. package/target/types/main/typescript/impl/xhrCore/ResonseDataResolver.d.ts +60 -0
  112. package/target/types/main/typescript/impl/xhrCore/Response.d.ts +29 -0
  113. package/target/types/main/typescript/impl/xhrCore/ResponseProcessor.d.ts +208 -0
  114. package/target/types/main/typescript/impl/xhrCore/XhrFormData.d.ts +83 -0
  115. package/target/types/main/typescript/impl/xhrCore/XhrRequest.d.ts +102 -0
  116. package/target/types/main/typescript/index.d.ts +34 -0
  117. package/target/types/main/typescript/index_core.d.ts +29 -0
  118. package/target/types/main/typescript/myfaces/OamSubmit.d.ts +53 -0
  119. package/target/types/main/typescript/test/frameworkBase/LangTest.spec.d.ts +1 -0
  120. package/target/types/main/typescript/test/frameworkBase/_ext/monadish/DomQueryTest.spec.d.ts +1 -0
  121. package/target/types/main/typescript/test/frameworkBase/_ext/monadish/LangTest.spec.d.ts +16 -0
  122. package/target/types/main/typescript/test/frameworkBase/_ext/monadish/MappingProbes.d.ts +39 -0
  123. package/target/types/main/typescript/test/frameworkBase/_ext/monadish/MappingTest.spec.d.ts +16 -0
  124. package/target/types/main/typescript/test/frameworkBase/_ext/monadish/MonadTest.spec.d.ts +16 -0
  125. package/target/types/main/typescript/test/frameworkBase/_ext/monadish/XmlQueryTest.spec.d.ts +0 -0
  126. package/target/types/main/typescript/test/frameworkBase/_ext/monadish/markups/tobago-with-header.d.ts +1 -0
  127. package/target/types/main/typescript/test/frameworkBase/_ext/monadish/markups/tobago-without-header.d.ts +1 -0
  128. package/target/types/main/typescript/test/frameworkBase/_ext/shared/StandardInits.d.ts +63 -0
  129. package/target/types/main/typescript/test/frameworkBase/_ext/shared/XmlResponses.d.ts +23 -0
  130. package/target/types/main/typescript/test/impl/ImplTest.spec.d.ts +16 -0
  131. package/target/types/main/typescript/test/impl/ImplTest_23.spec.d.ts +16 -0
  132. package/target/types/main/typescript/test/impl/SeparatorCharsTest.spec.d.ts +16 -0
  133. package/target/types/main/typescript/test/myfaces/OamSubmit.spec.d.ts +16 -0
  134. package/target/types/main/typescript/test/myfaces/OnLoad.spec.d.ts +16 -0
  135. package/target/types/main/typescript/test/queue/AsynchronousProbe.d.ts +38 -0
  136. package/target/types/main/typescript/test/queue/AsynchronousQueueTest.spec.d.ts +16 -0
  137. package/target/types/main/typescript/test/xhrCore/ClientWindow.spec.d.ts +1 -0
  138. package/target/types/main/typescript/test/xhrCore/ErrorChainTest.spec.d.ts +16 -0
  139. package/target/types/main/typescript/test/xhrCore/EventTests.spec.d.ts +16 -0
  140. package/target/types/main/typescript/test/xhrCore/FakeWebsocket.d.ts +24 -0
  141. package/target/types/main/typescript/test/xhrCore/FileUploadTest.spec.d.ts +1 -0
  142. package/target/types/main/typescript/test/xhrCore/NamespacesRequestTest.spec.d.ts +16 -0
  143. package/target/types/main/typescript/test/xhrCore/OamSubmitTest.spec.d.ts +16 -0
  144. package/target/types/main/typescript/test/xhrCore/RequestParamsTest.spec.d.ts +1 -0
  145. package/target/types/main/typescript/test/xhrCore/RequestTest.spec.d.ts +16 -0
  146. package/target/types/main/typescript/test/xhrCore/RequestTest_23.spec.d.ts +16 -0
  147. package/target/types/main/typescript/test/xhrCore/ResponseTest.spec.d.ts +16 -0
  148. package/target/types/main/typescript/test/xhrCore/ResponseTest23.spec.d.ts +16 -0
  149. package/target/types/main/typescript/test/xhrCore/ShadowDomTest.spec.d.ts +16 -0
  150. package/target/types/main/typescript/test/xhrCore/TobagoFileUploadTest.spec.d.ts +1 -0
  151. package/target/types/main/typescript/test/xhrCore/WebsocketTest.d.ts +1 -0
  152. package/target/types/main/typescript/test/xhrCore/XhrFormDataTest.spec.d.ts +16 -0
  153. package/target/types/test/typescript/AssocArrayTest.spec.d.ts +1 -0
  154. package/target/types/test/typescript/DomQueryTest.spec.d.ts +1 -0
  155. package/target/types/test/typescript/ExtendedArrayTest.spec.d.ts +1 -0
  156. package/target/types/test/typescript/LangTest.spec.d.ts +1 -0
  157. package/target/types/test/typescript/MappingProbes.d.ts +24 -0
  158. package/target/types/test/typescript/MappingTest.spec.d.ts +1 -0
  159. package/target/types/test/typescript/MessagingTest.spec.d.ts +1 -0
  160. package/target/types/test/typescript/MonadTest.spec.d.ts +16 -0
  161. package/target/types/test/typescript/PromiseTest.spec.d.ts +1 -0
  162. package/target/types/test/typescript/StreamTest.spec.d.ts +1 -0
  163. package/target/types/test/typescript/XmlQueryTest.spec.d.ts +1 -0
  164. package/target/types/test/typescript/markups/tobago-with-header.d.ts +1 -0
  165. package/target/types/test/typescript/markups/tobago-without-header.d.ts +1 -0
  166. package/webpack.config.js +1 -1
  167. package/webpack.config.js.map +1 -1
  168. package/.nyc_output/09ca9ebc-2305-4357-8db9-48ddfc7dfde2.json +0 -1
  169. package/.nyc_output/7c496a14-166e-4aa5-85b9-47b22b055ad8.json +0 -1
  170. package/.nyc_output/processinfo/09ca9ebc-2305-4357-8db9-48ddfc7dfde2.json +0 -1
  171. package/.nyc_output/processinfo/7c496a14-166e-4aa5-85b9-47b22b055ad8.json +0 -1
  172. package/.nyc_output/processinfo/index.json +0 -1
  173. package/src/test.html +0 -75
  174. package/src/tmp/test.html +0 -16
  175. package/tmp.xml +0 -36
@@ -0,0 +1,235 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Config = exports.CONFIG_ANY = exports.CONFIG_VALUE = void 0;
4
+ const Es2019Array_1 = require("./Es2019Array");
5
+ const Monad_1 = require("./Monad");
6
+ const Lang_1 = require("./Lang");
7
+ var objAssign = Lang_1.Lang.objAssign;
8
+ const AssocArray_1 = require("./AssocArray");
9
+ /**
10
+ * specialized value embedder
11
+ * for our Configuration
12
+ */
13
+ class ConfigEntry extends Monad_1.ValueEmbedder {
14
+ constructor(rootElem, key, arrPos) {
15
+ super(rootElem, key);
16
+ this.arrPos = arrPos !== null && arrPos !== void 0 ? arrPos : -1;
17
+ }
18
+ get value() {
19
+ if (this.key == "" && this.arrPos >= 0) {
20
+ return this._value[this.arrPos];
21
+ }
22
+ else if (this.key && this.arrPos >= 0) {
23
+ return this._value[this.key][this.arrPos];
24
+ }
25
+ return this._value[this.key];
26
+ }
27
+ set value(val) {
28
+ if (this.key == "" && this.arrPos >= 0) {
29
+ this._value[this.arrPos] = val;
30
+ return;
31
+ }
32
+ else if (this.key && this.arrPos >= 0) {
33
+ this._value[this.key][this.arrPos] = val;
34
+ return;
35
+ }
36
+ this._value[this.key] = val;
37
+ }
38
+ }
39
+ /*default value for absent*/
40
+ ConfigEntry.absent = ConfigEntry.fromNullable(null);
41
+ exports.CONFIG_VALUE = "__END_POINT__";
42
+ exports.CONFIG_ANY = "__ANY_POINT__";
43
+ /**
44
+ * Config, basically an optional wrapper for a json structure
45
+ * (not Side - effect free, since we can alter the internal config state
46
+ * without generating a new config), not sure if we should make it side - effect free
47
+ * since this would swallow a lot of performance and ram
48
+ */
49
+ class Config extends Monad_1.Optional {
50
+ constructor(root, configDef) {
51
+ super(root);
52
+ this.configDef = configDef;
53
+ }
54
+ /**
55
+ * shallow copy getter, copies only the first level, references the deeper nodes
56
+ * in a shared manner
57
+ */
58
+ get shallowCopy() {
59
+ return this.shallowCopy$();
60
+ }
61
+ shallowCopy$() {
62
+ let ret = new Config({});
63
+ ret.shallowMerge(this.value);
64
+ return ret;
65
+ }
66
+ /**
67
+ * deep copy, copies all config nodes
68
+ */
69
+ get deepCopy() {
70
+ return this.deepCopy$();
71
+ }
72
+ deepCopy$() {
73
+ return new Config(objAssign({}, this.value));
74
+ }
75
+ /**
76
+ * creates a config from an initial value or null
77
+ * @param value
78
+ */
79
+ static fromNullable(value) {
80
+ return new Config(value);
81
+ }
82
+ /**
83
+ * simple merge for the root configs
84
+ */
85
+ shallowMerge(other, overwrite = true, withAppend = false) {
86
+ //shallow merge must be mutable so we have to remap
87
+ let newThis = (0, AssocArray_1.shallowMerge)(overwrite, withAppend, this.value, other.value);
88
+ if (Array.isArray(this._value)) {
89
+ this._value.length = 0;
90
+ this._value.push(...newThis);
91
+ }
92
+ else {
93
+ Object.getOwnPropertyNames(this._value).forEach(key => delete this._value[key]);
94
+ Object.getOwnPropertyNames(newThis).forEach(key => this._value[key] = newThis[key]);
95
+ }
96
+ }
97
+ /**
98
+ * assigns a single value as array, or appends it
99
+ * to an existing value mapping a single value to array
100
+ *
101
+ *
102
+ * usage myConfig.append("foobaz").value = "newValue"
103
+ * myConfig.append("foobaz").value = "newValue2"
104
+ *
105
+ * resulting in myConfig.foobaz == ["newValue, newValue2"]
106
+ *
107
+ * @param {string[]} accessPath
108
+ */
109
+ append(...accessPath) {
110
+ return (0, AssocArray_1.append)(this._value, ...accessPath);
111
+ }
112
+ /**
113
+ * appends to an existing entry (or extends into an array and appends)
114
+ * if the condition is met
115
+ * @param {boolean} condition
116
+ * @param {string[]} accessPath
117
+ */
118
+ appendIf(condition, ...accessPath) {
119
+ return (0, AssocArray_1.appendIf)(condition, this._value, ...accessPath);
120
+ }
121
+ /**
122
+ * assigns a new value on the given access path
123
+ * @param accessPath
124
+ */
125
+ assign(...accessPath) {
126
+ return (0, AssocArray_1.assign)(this.value, ...accessPath);
127
+ }
128
+ /**
129
+ * assign a value if the condition is set to true, otherwise skip it
130
+ *
131
+ * @param condition the condition, the access accessPath into the config
132
+ * @param accessPath
133
+ */
134
+ assignIf(condition, ...accessPath) {
135
+ return (0, AssocArray_1.assignIf)(condition, this._value, ...accessPath);
136
+ }
137
+ /**
138
+ * get if the access path is present (get is reserved as getter with a default, on the current path)
139
+ * TODO will be renamed to something more meaningful and deprecated, the name is ambiguous
140
+ * @param accessPath the access path
141
+ */
142
+ getIf(...accessPath) {
143
+ this.assertAccessPath(...accessPath);
144
+ return this.getClass().fromNullable((0, AssocArray_1.resolve)(this.value, ...accessPath));
145
+ }
146
+ /**
147
+ * gets the current node and if none is present returns a config with a default value
148
+ * @param defaultVal
149
+ */
150
+ get(defaultVal) {
151
+ return this.getClass().fromNullable(super.get(defaultVal).value);
152
+ }
153
+ //empties the current config entry
154
+ delete(key) {
155
+ if (key in this.value) {
156
+ delete this.value[key];
157
+ }
158
+ return this;
159
+ }
160
+ /**
161
+ * converts the entire config into a json object
162
+ */
163
+ toJson() {
164
+ return JSON.stringify(this.value);
165
+ }
166
+ getClass() {
167
+ return Config;
168
+ }
169
+ setVal(val) {
170
+ this._value = val;
171
+ }
172
+ /**
173
+ * asserts the access path for a semi typed access
174
+ * @param accessPath
175
+ * @private
176
+ */
177
+ assertAccessPath(...accessPath) {
178
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
179
+ accessPath = this.preprocessKeys(...accessPath);
180
+ if (!this.configDef) {
181
+ //untyped
182
+ return;
183
+ }
184
+ const ERR_ACCESS_PATH = "Access Path to config invalid";
185
+ let currAccessPos = Monad_1.Optional.fromNullable(Object.keys(this.configDef).map(key => {
186
+ let ret = {};
187
+ ret[key] = this.configDef[key];
188
+ return ret;
189
+ }));
190
+ for (let cnt = 0; cnt < accessPath.length; cnt++) {
191
+ let currKey = this.keyVal(accessPath[cnt]);
192
+ let arrPos = this.arrayIndex(accessPath[cnt]);
193
+ //key index
194
+ if (this.isArray(arrPos)) {
195
+ if (currKey != "") {
196
+ currAccessPos = Array.isArray(currAccessPos.value) ?
197
+ Monad_1.Optional.fromNullable((_b = (_a = new Es2019Array_1.Es2019Array(...currAccessPos.value)
198
+ .find(item => {
199
+ var _a;
200
+ return !!((_a = item === null || item === void 0 ? void 0 : item[currKey]) !== null && _a !== void 0 ? _a : false);
201
+ })) === null || _a === void 0 ? void 0 : _a[currKey]) === null || _b === void 0 ? void 0 : _b[arrPos]) :
202
+ Monad_1.Optional.fromNullable((_e = (_d = (_c = currAccessPos.value) === null || _c === void 0 ? void 0 : _c[currKey]) === null || _d === void 0 ? void 0 : _d[arrPos]) !== null && _e !== void 0 ? _e : null);
203
+ }
204
+ else {
205
+ currAccessPos = (Array.isArray(currAccessPos.value)) ?
206
+ Monad_1.Optional.fromNullable((_f = currAccessPos.value) === null || _f === void 0 ? void 0 : _f[arrPos]) : Monad_1.Optional.absent;
207
+ }
208
+ //we noe store either the current array or the filtered look ahead to go further
209
+ }
210
+ else {
211
+ //we now have an array and go further with a singular key
212
+ currAccessPos = (Array.isArray(currAccessPos.value)) ? Monad_1.Optional.fromNullable((_g = new Es2019Array_1.Es2019Array(...currAccessPos.value)
213
+ .find(item => {
214
+ var _a;
215
+ return !!((_a = item === null || item === void 0 ? void 0 : item[currKey]) !== null && _a !== void 0 ? _a : false);
216
+ })) === null || _g === void 0 ? void 0 : _g[currKey]) :
217
+ Monad_1.Optional.fromNullable((_j = (_h = currAccessPos.value) === null || _h === void 0 ? void 0 : _h[currKey]) !== null && _j !== void 0 ? _j : null);
218
+ }
219
+ if (!currAccessPos.isPresent()) {
220
+ throw Error(ERR_ACCESS_PATH);
221
+ }
222
+ if (currAccessPos.value == exports.CONFIG_ANY) {
223
+ return;
224
+ }
225
+ }
226
+ }
227
+ isNoArray(arrPos) {
228
+ return arrPos == -1;
229
+ }
230
+ isArray(arrPos) {
231
+ return !this.isNoArray(arrPos);
232
+ }
233
+ }
234
+ exports.Config = Config;
235
+ //# sourceMappingURL=Config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Config.js","sourceRoot":"","sources":["../src/main/typescript/Config.ts"],"names":[],"mappings":";;;AAAA,+CAA0C;AAC1C,mCAA8D;AAC9D,iCAA4B;AAC5B,IAAO,SAAS,GAAG,WAAI,CAAC,SAAS,CAAC;AAClC,6CAAuF;AAEvF;;;GAGG;AACH,MAAM,WAAe,SAAQ,qBAAgB;IAUzC,YAAY,QAAa,EAAE,GAAQ,EAAE,MAAe;QAChD,KAAK,CAAC,QAAQ,EAAE,GAAG,CAAC,CA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AAC;oBACpB,gBAAQ,CAAC,YAAY,CAAC,MAAA,MAAA,aAAa,CAAC,KAAK,0CAAG,OAAO,CAAC,mCAAI,IAAI,CAAC,CAAC;aACrE;YACD,IAAI,CAAC,aAAa,CAAC,SAAS,EAAE,EAAE;gBAC5B,MAAM,KAAK,CAAC,eAAe,CAAC,CAAA;aAC/B;YACD,IAAI,aAAa,CAAC,KAAK,IAAI,kBAAU,EAAE;gBACnC,OAAO;aACV;SACJ;IACL,CAAC;IAEO,SAAS,CAAC,MAAc;QAC5B,OAAO,MAAM,IAAI,CAAC,CAAC,CAAC;IACxB,CAAC;IAEO,OAAO,CAAC,MAAc;QAC1B,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IACnC,CAAC;CAEJ;AA7MD,wBA6MC"}
@@ -0,0 +1,112 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ExpiringCrypto = exports.JSONCrypto = void 0;
4
+ const SourcesCollectors_1 = require("./SourcesCollectors");
5
+ const Stream_1 = require("./Stream");
6
+ /*
7
+ * Some crypto implementations which might come in handy
8
+ */
9
+ /**
10
+ * basic json stringify encryption impl
11
+ * this does not really full encryption except for a standard json stringyfywith an encapsulation json
12
+ *
13
+ * the return value resembles:
14
+ * <pre>
15
+ * {
16
+ * encryptedData: <data as string>
17
+ * }
18
+ * </pre>
19
+ */
20
+ class JSONCrypto {
21
+ decode(data) {
22
+ if (data === null || data === void 0 ? void 0 : data.encryptedData) {
23
+ return JSON.parse(data.encryptedData);
24
+ }
25
+ return data;
26
+ }
27
+ encode(data) {
28
+ return {
29
+ encryptedData: JSON.stringify(data)
30
+ };
31
+ }
32
+ }
33
+ exports.JSONCrypto = JSONCrypto;
34
+ /**
35
+ * a class with timeout functionality which blocks decodes after a certain period of time
36
+ * if the message is not decoded by then
37
+ * We use hash as identifier generation after encryption to make sure
38
+ * a trace was possible
39
+ *
40
+ * The idea behind this is to have a generic wrapper which allows messages with dynamic encryption
41
+ * where keys/salts only exist for a certain period of time before expiring!
42
+ * That way someone who implements such a scheme does not have to take care about the bookeeping mechanisms!
43
+ * Or you can use crypto mechanisms which do not have expiring keys and still expire them automatically
44
+ *
45
+ * I will leave it up to the system integrator to provide a rotating crypto class, because this is highly
46
+ * implementation dependent. But it helps to have a wrapper!
47
+ */
48
+ class ExpiringCrypto {
49
+ /**
50
+ * @param timeout timeout in miliseconds until a message is expired
51
+ * @param parentCrypto the embedded decorated crypto algorithm
52
+ * @param hashSum hashshum implementation to generate a hash
53
+ */
54
+ constructor(timeout, parentCrypto, hashSum) {
55
+ this.timeout = timeout;
56
+ this.parentCrypto = parentCrypto;
57
+ this.hashSum = hashSum;
58
+ this.gcCycleCnt = 0;
59
+ this.storedMessages = {};
60
+ this.lastCall = 0;
61
+ }
62
+ /**
63
+ * decode implementation with a timeout hook install
64
+ * @param data
65
+ */
66
+ decode(data) {
67
+ //if ((this.gcCycleCnt++ % ExpiringCrypto.MAX_GC_CYCLES) === 0) {
68
+ var _a;
69
+ const currTime = new Date().getTime();
70
+ if (this.gcLimitReached(currTime)) {
71
+ this.storedMessages = Stream_1.LazyStream
72
+ .ofAssoc(this.storedMessages)
73
+ .filter(data => data[1] >= currTime)
74
+ .collect(new SourcesCollectors_1.AssocArrayCollector());
75
+ }
76
+ this.lastCall = currTime;
77
+ let rotatingEncoded = this.hashSum.encode(data);
78
+ if (!((_a = this.storedMessages) === null || _a === void 0 ? void 0 : _a[rotatingEncoded.toString()])) {
79
+ throw Error("An item was tried to be decryted which either was expired or invalid");
80
+ }
81
+ return this.parentCrypto.decode(data);
82
+ }
83
+ /**
84
+ * trigger function to determine whether the gc needs to cycle again, this is either time or call based
85
+ * the gc itself collects only on expiration dates
86
+ * The idea is to run this operation only occasionally because it is costly
87
+ * We also could have used timeouts etc.. but those would need shutdown/destroy cleanups
88
+ *
89
+ * @param currTime
90
+ * @private
91
+ */
92
+ gcLimitReached(currTime) {
93
+ return (this.lastCall + this.timeout) < currTime || ((++this.gcCycleCnt) % ExpiringCrypto.MAX_GC_CYCLES == 0);
94
+ }
95
+ /**
96
+ * encode with a timeout hook installed
97
+ * calls the encode of the delegated object
98
+ *
99
+ * @param data
100
+ */
101
+ encode(data) {
102
+ let encoded = this.parentCrypto.encode(data);
103
+ //ok use the hashsum really only to store expirations, theoretically there could be a second message which does not invalidate the first one
104
+ //but this is very unlikely unless a message is sent over and over again, in this case we have a timeout extension anyway!
105
+ let rotatingEncoded = this.hashSum.encode(encoded);
106
+ this.storedMessages[rotatingEncoded.toString()] = (new Date().getTime()) + this.timeout;
107
+ return encoded;
108
+ }
109
+ }
110
+ exports.ExpiringCrypto = ExpiringCrypto;
111
+ ExpiringCrypto.MAX_GC_CYCLES = 10;
112
+ //# sourceMappingURL=CryptoExtensions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CryptoExtensions.js","sourceRoot":"","sources":["../src/main/typescript/CryptoExtensions.ts"],"names":[],"mappings":";;;AAmBA,2DAAwD;AACxD,qCAAoC;AAEpC;;GAEG;AAGH;;;;;;;;;;GAUG;AACH,MAAa,UAAU;IACnB,MAAM,CAAC,IAAS;QACZ,IAAI,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,aAAa,EAAE;YACrB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;SACzC;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,MAAM,CAAC,IAAS;QACZ,OAAO;YACH,aAAa,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;SACtC,CAAA;IACL,CAAC;CACJ;AAbD,gCAaC;AAGD;;;;;;;;;;;;;GAaG;AACH,MAAa,cAAc;IAOvB;;;;OAIG;IACH,YAAoB,OAAe,EAAU,YAAoB,EAAU,OAAa;QAApE,YAAO,GAAP,OAAO,CAAQ;QAAU,iBAAY,GAAZ,YAAY,CAAQ;QAAU,YAAO,GAAP,OAAO,CAAM;QAThF,eAAU,GAAG,CAA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