engage-wasm 1.247.90870020 → 1.247.90870021

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/engagewasm.api.js CHANGED
@@ -51,28 +51,6 @@ export default class Engage extends EventTarget {
51
51
  return this.wasmWrapper.engageStop();
52
52
  }
53
53
 
54
- engageEncrypt(srcUint8Array, srcSize, dstUint8Array, passwordHex) {
55
- const srcHeap = this.wasm._malloc(srcSize * 1);
56
- this.wasm.HEAPU8.set(srcUint8Array, srcHeap);
57
-
58
- const dstHeap = this.wasm._malloc(srcSize + 64);
59
-
60
- const rc = this.wasmWrapper.engageEncrypt(
61
- srcHeap,
62
- srcSize,
63
- dstHeap,
64
- passwordHex);
65
-
66
- if (rc === 0) {
67
- const dstArray = this.wasm.HEAPU8.subarray(dstHeap, dstHeap + srcSize + 64);
68
- dstUint8Array.set(dstArray);
69
- }
70
-
71
- this.wasm._free(srcHeap);
72
- this.wasm._free(dstHeap);
73
- return rc;
74
- }
75
-
76
54
  engageDecrypt(srcUint8Array, srcSize, dstUint8Array, passwordHex) {
77
55
  const srcHeap = this.wasm._malloc(srcSize * 1);
78
56
  this.wasm.HEAPU8.set(srcUint8Array, srcHeap);
@@ -85,8 +63,8 @@ export default class Engage extends EventTarget {
85
63
  dstHeap,
86
64
  passwordHex);
87
65
 
88
- if (rc === 0) {
89
- const dstArray = this.wasm.HEAPU8.subarray(dstHeap, dstHeap + srcSize + 64);
66
+ if (rc > 0) {
67
+ const dstArray = this.wasm.HEAPU8.subarray(dstHeap, rc);
90
68
  dstUint8Array.set(dstArray);
91
69
  }
92
70
 
@@ -189,6 +167,58 @@ export default class Engage extends EventTarget {
189
167
  engageQueryGroupTimeline(id, jsonParams) {
190
168
  return this.wasmWrapper.engageQueryGroupTimeline(id, jsonParams);
191
169
  }
170
+
171
+ engageEncryptWasm(srcUint8Array, srcSize, passwordHex) {
172
+ var srcArrayPtr = this.wasm._malloc(srcSize * 1);
173
+ this.wasm.HEAPU8.set(srcUint8Array, srcArrayPtr);
174
+
175
+ var dstArrayPtr = this.wasm._malloc(srcSize + 64);
176
+
177
+ const rc = this.wasmWrapper.engageEncrypt(
178
+ srcArrayPtr,
179
+ srcSize,
180
+ dstArrayPtr,
181
+ passwordHex);
182
+
183
+ var encryptedBuffer = null;
184
+
185
+ if(rc > 0) {
186
+ var tmp = new Uint8Array(this.wasm.HEAPU8.buffer, dstArrayPtr, rc);
187
+ encryptedBuffer = new Uint8Array(rc);
188
+ encryptedBuffer.set(tmp);
189
+ }
190
+
191
+ this.wasm._free(srcArrayPtr);
192
+ this.wasm._free(dstArrayPtr);
193
+
194
+ return encryptedBuffer;
195
+ }
196
+
197
+ engageDecryptWasm(srcUint8Array, srcSize, passwordHex) {
198
+ var srcArrayPtr = this.wasm._malloc(srcSize * 1);
199
+ this.wasm.HEAPU8.set(srcUint8Array, srcArrayPtr);
200
+
201
+ var dstArrayPtr = this.wasm._malloc(srcSize + 64);
202
+
203
+ const rc = this.wasmWrapper.engageDecrypt(
204
+ srcArrayPtr,
205
+ srcSize,
206
+ dstArrayPtr,
207
+ passwordHex);
208
+
209
+ var decryptedBuffer = null;
210
+
211
+ if(rc > 0) {
212
+ var tmp = new Uint8Array(this.wasm.HEAPU8.buffer, dstArrayPtr, rc);
213
+ decryptedBuffer = new Uint8Array(rc);
214
+ decryptedBuffer.set(tmp);
215
+ }
216
+
217
+ this.wasm._free(srcArrayPtr);
218
+ this.wasm._free(dstArrayPtr);
219
+
220
+ return decryptedBuffer;
221
+ }
192
222
  }
193
223
 
194
224
  /*
package/engagewasm.wasm CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "engage-wasm",
3
- "version": "1.247.90870020",
3
+ "version": "1.247.90870021",
4
4
  "description": "The RTS Engage Engine built for WebAssembly",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"