openclaw-channel-dmwork 0.5.13 → 0.5.14

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 (84) hide show
  1. package/package.json +1 -1
  2. package/src/channel.ts +17 -4
  3. package/src/multi-bot-isolation.test.ts +208 -0
  4. package/node_modules/crypto-js/CONTRIBUTING.md +0 -28
  5. package/node_modules/crypto-js/LICENSE +0 -24
  6. package/node_modules/crypto-js/README.md +0 -275
  7. package/node_modules/crypto-js/aes.js +0 -234
  8. package/node_modules/crypto-js/blowfish.js +0 -471
  9. package/node_modules/crypto-js/bower.json +0 -39
  10. package/node_modules/crypto-js/cipher-core.js +0 -895
  11. package/node_modules/crypto-js/core.js +0 -807
  12. package/node_modules/crypto-js/crypto-js.js +0 -6657
  13. package/node_modules/crypto-js/docs/QuickStartGuide.wiki +0 -470
  14. package/node_modules/crypto-js/enc-base64.js +0 -136
  15. package/node_modules/crypto-js/enc-base64url.js +0 -148
  16. package/node_modules/crypto-js/enc-hex.js +0 -18
  17. package/node_modules/crypto-js/enc-latin1.js +0 -18
  18. package/node_modules/crypto-js/enc-utf16.js +0 -149
  19. package/node_modules/crypto-js/enc-utf8.js +0 -18
  20. package/node_modules/crypto-js/evpkdf.js +0 -134
  21. package/node_modules/crypto-js/format-hex.js +0 -66
  22. package/node_modules/crypto-js/format-openssl.js +0 -18
  23. package/node_modules/crypto-js/hmac-md5.js +0 -18
  24. package/node_modules/crypto-js/hmac-ripemd160.js +0 -18
  25. package/node_modules/crypto-js/hmac-sha1.js +0 -18
  26. package/node_modules/crypto-js/hmac-sha224.js +0 -18
  27. package/node_modules/crypto-js/hmac-sha256.js +0 -18
  28. package/node_modules/crypto-js/hmac-sha3.js +0 -18
  29. package/node_modules/crypto-js/hmac-sha384.js +0 -18
  30. package/node_modules/crypto-js/hmac-sha512.js +0 -18
  31. package/node_modules/crypto-js/hmac.js +0 -143
  32. package/node_modules/crypto-js/index.js +0 -18
  33. package/node_modules/crypto-js/lib-typedarrays.js +0 -76
  34. package/node_modules/crypto-js/md5.js +0 -268
  35. package/node_modules/crypto-js/mode-cfb.js +0 -80
  36. package/node_modules/crypto-js/mode-ctr-gladman.js +0 -116
  37. package/node_modules/crypto-js/mode-ctr.js +0 -58
  38. package/node_modules/crypto-js/mode-ecb.js +0 -40
  39. package/node_modules/crypto-js/mode-ofb.js +0 -54
  40. package/node_modules/crypto-js/package.json +0 -42
  41. package/node_modules/crypto-js/pad-ansix923.js +0 -49
  42. package/node_modules/crypto-js/pad-iso10126.js +0 -44
  43. package/node_modules/crypto-js/pad-iso97971.js +0 -40
  44. package/node_modules/crypto-js/pad-nopadding.js +0 -30
  45. package/node_modules/crypto-js/pad-pkcs7.js +0 -18
  46. package/node_modules/crypto-js/pad-zeropadding.js +0 -47
  47. package/node_modules/crypto-js/pbkdf2.js +0 -145
  48. package/node_modules/crypto-js/rabbit-legacy.js +0 -190
  49. package/node_modules/crypto-js/rabbit.js +0 -192
  50. package/node_modules/crypto-js/rc4.js +0 -139
  51. package/node_modules/crypto-js/ripemd160.js +0 -267
  52. package/node_modules/crypto-js/sha1.js +0 -150
  53. package/node_modules/crypto-js/sha224.js +0 -80
  54. package/node_modules/crypto-js/sha256.js +0 -199
  55. package/node_modules/crypto-js/sha3.js +0 -326
  56. package/node_modules/crypto-js/sha384.js +0 -83
  57. package/node_modules/crypto-js/sha512.js +0 -326
  58. package/node_modules/crypto-js/tripledes.js +0 -779
  59. package/node_modules/crypto-js/x64-core.js +0 -304
  60. package/node_modules/curve25519-js/.prettierrc +0 -6
  61. package/node_modules/curve25519-js/LICENSE +0 -19
  62. package/node_modules/curve25519-js/README.md +0 -111
  63. package/node_modules/curve25519-js/lib/index.d.ts +0 -69
  64. package/node_modules/curve25519-js/lib/index.js +0 -1669
  65. package/node_modules/curve25519-js/package.json +0 -34
  66. package/node_modules/curve25519-js/tsconfig.json +0 -20
  67. package/node_modules/curve25519-js/tslint.json +0 -10
  68. package/node_modules/md5-typescript/.idea/Md5-typescript.iml +0 -13
  69. package/node_modules/md5-typescript/.idea/jsLibraryMappings.xml +0 -6
  70. package/node_modules/md5-typescript/.idea/libraries/tsconfig_roots.xml +0 -13
  71. package/node_modules/md5-typescript/.idea/modules.xml +0 -8
  72. package/node_modules/md5-typescript/.idea/vcs.xml +0 -6
  73. package/node_modules/md5-typescript/.idea/workspace.xml +0 -345
  74. package/node_modules/md5-typescript/LICENSE +0 -21
  75. package/node_modules/md5-typescript/README.md +0 -13
  76. package/node_modules/md5-typescript/dist/bundles/bundle.umd.js +0 -208
  77. package/node_modules/md5-typescript/dist/bundles/bundle.umd.min.js +0 -1
  78. package/node_modules/md5-typescript/dist/index.d.ts +0 -43
  79. package/node_modules/md5-typescript/dist/index.js +0 -198
  80. package/node_modules/md5-typescript/dist/index.js.map +0 -1
  81. package/node_modules/md5-typescript/dist/index.metadata.json +0 -1
  82. package/node_modules/md5-typescript/package.json +0 -31
  83. package/node_modules/md5-typescript/rollup.config.js +0 -7
  84. package/node_modules/md5-typescript/tsconfig.json +0 -28
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openclaw-channel-dmwork",
3
- "version": "0.5.13",
3
+ "version": "0.5.14",
4
4
  "description": "DMWork channel plugin for OpenClaw via WuKongIM WebSocket",
5
5
  "main": "index.ts",
6
6
  "type": "module",
package/src/channel.ts CHANGED
@@ -125,16 +125,26 @@ function getOrCreateGroupCacheTimestamps(accountId: string): Map<string, number>
125
125
  }
126
126
 
127
127
 
128
- // --- Group → Account mapping: tracks which account each group was received from ---
128
+ // --- Group → Account mapping: tracks which accounts are active in each group ---
129
129
  // Used by handleAction to resolve the correct account when framework passes wrong accountId
130
- const _groupToAccount = new Map<string, string>(); // groupNo accountId
130
+ // A group may have multiple bots (1:N), so we store a Set of accountIds per group.
131
+ const _groupToAccount = new Map<string, Set<string>>(); // groupNo → Set<accountId>
131
132
 
132
133
  export function registerGroupToAccount(groupNo: string, accountId: string): void {
133
- _groupToAccount.set(groupNo, accountId);
134
+ let accounts = _groupToAccount.get(groupNo);
135
+ if (!accounts) {
136
+ accounts = new Set<string>();
137
+ _groupToAccount.set(groupNo, accounts);
138
+ }
139
+ accounts.add(accountId);
134
140
  }
135
141
 
136
142
  export function resolveAccountForGroup(groupNo: string): string | undefined {
137
- return _groupToAccount.get(groupNo);
143
+ const accounts = _groupToAccount.get(groupNo);
144
+ if (!accounts || accounts.size === 0) return undefined;
145
+ // Only resolve when exactly one bot owns the group; multi-bot → ambiguous
146
+ if (accounts.size === 1) return accounts.values().next().value;
147
+ return undefined;
138
148
  }
139
149
 
140
150
  // --- Cache cleanup: evict groups inactive for >4 hours ---
@@ -253,11 +263,14 @@ export const dmworkPlugin: ChannelPlugin<ResolvedDmworkAccount> = {
253
263
  handleAction: async (ctx: any) => {
254
264
  // Resolve correct accountId: framework may pass wrong one when agent has multiple accounts.
255
265
  // Use currentChannelId to look up which account actually owns the group.
266
+ // When multiple bots share the same group, do NOT correct — the caller's accountId is authoritative.
256
267
  let accountId = ctx.accountId ?? DEFAULT_ACCOUNT_ID;
257
268
  const currentChannelId = ctx.toolContext?.currentChannelId;
258
269
  if (currentChannelId) {
259
270
  const rawGroupNo = currentChannelId.replace(/^dmwork:/, '');
260
271
  const correctAccountId = resolveAccountForGroup(rawGroupNo);
272
+ // Only correct when resolveAccountForGroup returns a definitive answer
273
+ // (exactly one bot owns the group); multi-bot → undefined → no correction
261
274
  if (correctAccountId && correctAccountId !== accountId) {
262
275
  ctx.log?.info?.(`dmwork: handleAction accountId corrected: ${accountId} → ${correctAccountId} (group=${rawGroupNo})`);
263
276
  accountId = correctAccountId;
@@ -0,0 +1,208 @@
1
+ /**
2
+ * Tests for multi-bot accountId isolation fix.
3
+ *
4
+ * Verifies that when multiple bots share the same OpenClaw Gateway process,
5
+ * messages are sent from the correct bot account — not from whichever bot
6
+ * last processed a message in the same group.
7
+ */
8
+ import { describe, it, expect, vi, beforeEach } from "vitest";
9
+
10
+ // We need to reset module state between tests since _groupToAccount is module-level
11
+ beforeEach(() => {
12
+ vi.resetModules();
13
+ });
14
+
15
+ // ─── registerGroupToAccount / resolveAccountForGroup unit tests ─────────────
16
+
17
+ describe("registerGroupToAccount + resolveAccountForGroup", () => {
18
+ it("single bot — resolveAccountForGroup returns the registered accountId", async () => {
19
+ const { registerGroupToAccount, resolveAccountForGroup } = await import("./channel.js");
20
+
21
+ registerGroupToAccount("group-001", "botA");
22
+
23
+ expect(resolveAccountForGroup("group-001")).toBe("botA");
24
+ });
25
+
26
+ it("multi-bot same group — resolveAccountForGroup returns undefined", async () => {
27
+ const { registerGroupToAccount, resolveAccountForGroup } = await import("./channel.js");
28
+
29
+ registerGroupToAccount("group-001", "botA");
30
+ registerGroupToAccount("group-001", "botB");
31
+
32
+ expect(resolveAccountForGroup("group-001")).toBeUndefined();
33
+ });
34
+
35
+ it("unregistered group — resolveAccountForGroup returns undefined", async () => {
36
+ const { resolveAccountForGroup } = await import("./channel.js");
37
+
38
+ expect(resolveAccountForGroup("group-unknown")).toBeUndefined();
39
+ });
40
+
41
+ it("duplicate registration of same bot is idempotent", async () => {
42
+ const { registerGroupToAccount, resolveAccountForGroup } = await import("./channel.js");
43
+
44
+ registerGroupToAccount("group-001", "botA");
45
+ registerGroupToAccount("group-001", "botA");
46
+
47
+ // Still size 1 → should return the accountId
48
+ expect(resolveAccountForGroup("group-001")).toBe("botA");
49
+ });
50
+
51
+ it("different groups with different bots resolve independently", async () => {
52
+ const { registerGroupToAccount, resolveAccountForGroup } = await import("./channel.js");
53
+
54
+ registerGroupToAccount("group-001", "botA");
55
+ registerGroupToAccount("group-002", "botB");
56
+
57
+ expect(resolveAccountForGroup("group-001")).toBe("botA");
58
+ expect(resolveAccountForGroup("group-002")).toBe("botB");
59
+ });
60
+ });
61
+
62
+ // ─── handleAction correction logic tests ─────────────────────────────────────
63
+
64
+ // Mock dependencies that handleAction calls
65
+ vi.mock("./actions.js", () => ({
66
+ handleDmworkMessageAction: vi.fn(async () => ({ ok: true })),
67
+ parseTarget: vi.fn(() => ({ channelId: "test", channelType: 2 })),
68
+ }));
69
+
70
+ vi.mock("./agent-tools.js", () => ({
71
+ createDmworkManagementTools: vi.fn(() => []),
72
+ }));
73
+
74
+ vi.mock("./group-md.js", () => ({
75
+ getOrCreateGroupMdCache: vi.fn(() => new Map()),
76
+ registerBotGroupIds: vi.fn(),
77
+ getKnownGroupIds: vi.fn(() => new Set()),
78
+ }));
79
+
80
+ vi.mock("./api-fetch.js", () => ({
81
+ registerBot: vi.fn(),
82
+ sendMessage: vi.fn(),
83
+ sendHeartbeat: vi.fn(),
84
+ sendMediaMessage: vi.fn(),
85
+ inferContentType: vi.fn(),
86
+ ensureTextCharset: vi.fn((s: string) => s),
87
+ fetchBotGroups: vi.fn(async () => []),
88
+ getGroupMd: vi.fn(),
89
+ getGroupMembers: vi.fn(),
90
+ parseImageDimensions: vi.fn(),
91
+ parseImageDimensionsFromFile: vi.fn(),
92
+ getUploadCredentials: vi.fn(),
93
+ uploadFileToCOS: vi.fn(),
94
+ }));
95
+
96
+ describe("handleAction multi-bot isolation", () => {
97
+ it("single bot — corrects wrong accountId to the sole owner", async () => {
98
+ const { dmworkPlugin, registerGroupToAccount } = await import("./channel.js");
99
+ const { handleDmworkMessageAction } = await import("./actions.js");
100
+
101
+ // Only botA is in group-001
102
+ registerGroupToAccount("group-001", "botA");
103
+
104
+ const ctx = {
105
+ accountId: "wrongBot",
106
+ action: "send" as const,
107
+ channel: "dmwork",
108
+ params: { target: "group:group-001", text: "hello" },
109
+ toolContext: { currentChannelId: "dmwork:group-001" },
110
+ cfg: {
111
+ channels: {
112
+ dmwork: {
113
+ accounts: {
114
+ botA: { botToken: "tokenA", apiUrl: "http://api" },
115
+ wrongBot: { botToken: "tokenWrong", apiUrl: "http://api" },
116
+ },
117
+ },
118
+ },
119
+ },
120
+ log: { info: vi.fn() },
121
+ };
122
+
123
+ await dmworkPlugin.actions!.handleAction!(ctx as any);
124
+
125
+ // handleDmworkMessageAction should have been called with botA's token
126
+ expect(handleDmworkMessageAction).toHaveBeenCalledWith(
127
+ expect.objectContaining({ botToken: "tokenA" }),
128
+ );
129
+ // Correction log should have fired
130
+ expect(ctx.log.info).toHaveBeenCalledWith(
131
+ expect.stringContaining("accountId corrected"),
132
+ );
133
+ });
134
+
135
+ it("multi-bot same group — does NOT override ctx.accountId", async () => {
136
+ const { dmworkPlugin, registerGroupToAccount } = await import("./channel.js");
137
+ const { handleDmworkMessageAction } = await import("./actions.js");
138
+
139
+ // Both botA and botB are in group-001
140
+ registerGroupToAccount("group-001", "botA");
141
+ registerGroupToAccount("group-001", "botB");
142
+
143
+ const ctx = {
144
+ accountId: "botA",
145
+ action: "send" as const,
146
+ channel: "dmwork",
147
+ params: { target: "group:group-001", text: "hello from A" },
148
+ toolContext: { currentChannelId: "dmwork:group-001" },
149
+ cfg: {
150
+ channels: {
151
+ dmwork: {
152
+ accounts: {
153
+ botA: { botToken: "tokenA", apiUrl: "http://api" },
154
+ botB: { botToken: "tokenB", apiUrl: "http://api" },
155
+ },
156
+ },
157
+ },
158
+ },
159
+ log: { info: vi.fn() },
160
+ };
161
+
162
+ await dmworkPlugin.actions!.handleAction!(ctx as any);
163
+
164
+ // Should use botA's token (the caller's original accountId), NOT botB's
165
+ expect(handleDmworkMessageAction).toHaveBeenCalledWith(
166
+ expect.objectContaining({ botToken: "tokenA" }),
167
+ );
168
+ // No correction log should have fired
169
+ expect(ctx.log.info).not.toHaveBeenCalledWith(
170
+ expect.stringContaining("accountId corrected"),
171
+ );
172
+ });
173
+
174
+ it("single bot — correct accountId is not re-corrected", async () => {
175
+ const { dmworkPlugin, registerGroupToAccount } = await import("./channel.js");
176
+ const { handleDmworkMessageAction } = await import("./actions.js");
177
+
178
+ registerGroupToAccount("group-001", "botA");
179
+
180
+ const ctx = {
181
+ accountId: "botA", // already correct
182
+ action: "send" as const,
183
+ channel: "dmwork",
184
+ params: { target: "group:group-001", text: "hello" },
185
+ toolContext: { currentChannelId: "dmwork:group-001" },
186
+ cfg: {
187
+ channels: {
188
+ dmwork: {
189
+ accounts: {
190
+ botA: { botToken: "tokenA", apiUrl: "http://api" },
191
+ },
192
+ },
193
+ },
194
+ },
195
+ log: { info: vi.fn() },
196
+ };
197
+
198
+ await dmworkPlugin.actions!.handleAction!(ctx as any);
199
+
200
+ expect(handleDmworkMessageAction).toHaveBeenCalledWith(
201
+ expect.objectContaining({ botToken: "tokenA" }),
202
+ );
203
+ // No correction needed
204
+ expect(ctx.log.info).not.toHaveBeenCalledWith(
205
+ expect.stringContaining("accountId corrected"),
206
+ );
207
+ });
208
+ });
@@ -1,28 +0,0 @@
1
- # Contribution
2
-
3
- # Git Flow
4
-
5
- The crypto-js project uses [git flow](https://github.com/nvie/gitflow) to manage branches.
6
- Do your changes on the `develop` or even better on a `feature/*` branch. Don't do any changes on the `master` branch.
7
-
8
- # Pull request
9
-
10
- Target your pull request on `develop` branch. Other pull request won't be accepted.
11
-
12
- # How to build
13
-
14
- 1. Clone
15
-
16
- 2. Run
17
-
18
- ```sh
19
- npm install
20
- ```
21
-
22
- 3. Run
23
-
24
- ```sh
25
- npm run build
26
- ```
27
-
28
- 4. Check `build` folder
@@ -1,24 +0,0 @@
1
- # License
2
-
3
- [The MIT License (MIT)](http://opensource.org/licenses/MIT)
4
-
5
- Copyright (c) 2009-2013 Jeff Mott
6
- Copyright (c) 2013-2016 Evan Vosberg
7
-
8
- Permission is hereby granted, free of charge, to any person obtaining a copy
9
- of this software and associated documentation files (the "Software"), to deal
10
- in the Software without restriction, including without limitation the rights
11
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
- copies of the Software, and to permit persons to whom the Software is
13
- furnished to do so, subject to the following conditions:
14
-
15
- The above copyright notice and this permission notice shall be included in
16
- all copies or substantial portions of the Software.
17
-
18
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
- THE SOFTWARE.
@@ -1,275 +0,0 @@
1
- # crypto-js
2
-
3
- JavaScript library of crypto standards.
4
-
5
- ## Discontinued
6
-
7
- Active development of CryptoJS has been discontinued. This library is no longer maintained.
8
-
9
- Nowadays, NodeJS and modern browsers have a native `Crypto` module. The latest version of CryptoJS already uses the native Crypto module for random number generation, since `Math.random()` is not crypto-safe. Further development of CryptoJS would result in it only being a wrapper of native Crypto. Therefore, development and maintenance has been discontinued, it is time to go for the native `crypto` module.
10
-
11
- ## Node.js (Install)
12
-
13
- Requirements:
14
-
15
- - Node.js
16
- - npm (Node.js package manager)
17
-
18
- ```bash
19
- npm install crypto-js
20
- ```
21
-
22
- ### Usage
23
-
24
- ES6 import for typical API call signing use case:
25
-
26
- ```javascript
27
- import sha256 from 'crypto-js/sha256';
28
- import hmacSHA512 from 'crypto-js/hmac-sha512';
29
- import Base64 from 'crypto-js/enc-base64';
30
-
31
- const message, nonce, path, privateKey; // ...
32
- const hashDigest = sha256(nonce + message);
33
- const hmacDigest = Base64.stringify(hmacSHA512(path + hashDigest, privateKey));
34
- ```
35
-
36
- Modular include:
37
-
38
- ```javascript
39
- var AES = require("crypto-js/aes");
40
- var SHA256 = require("crypto-js/sha256");
41
- ...
42
- console.log(SHA256("Message"));
43
- ```
44
-
45
- Including all libraries, for access to extra methods:
46
-
47
- ```javascript
48
- var CryptoJS = require("crypto-js");
49
- console.log(CryptoJS.HmacSHA1("Message", "Key"));
50
- ```
51
-
52
- ## Client (browser)
53
-
54
- Requirements:
55
-
56
- - Node.js
57
- - Bower (package manager for frontend)
58
-
59
- ```bash
60
- bower install crypto-js
61
- ```
62
-
63
- ### Usage
64
-
65
- Modular include:
66
-
67
- ```javascript
68
- require.config({
69
- packages: [
70
- {
71
- name: 'crypto-js',
72
- location: 'path-to/bower_components/crypto-js',
73
- main: 'index'
74
- }
75
- ]
76
- });
77
-
78
- require(["crypto-js/aes", "crypto-js/sha256"], function (AES, SHA256) {
79
- console.log(SHA256("Message"));
80
- });
81
- ```
82
-
83
- Including all libraries, for access to extra methods:
84
-
85
- ```javascript
86
- // Above-mentioned will work or use this simple form
87
- require.config({
88
- paths: {
89
- 'crypto-js': 'path-to/bower_components/crypto-js/crypto-js'
90
- }
91
- });
92
-
93
- require(["crypto-js"], function (CryptoJS) {
94
- console.log(CryptoJS.HmacSHA1("Message", "Key"));
95
- });
96
- ```
97
-
98
- ### Usage without RequireJS
99
-
100
- ```html
101
- <script type="text/javascript" src="path-to/bower_components/crypto-js/crypto-js.js"></script>
102
- <script type="text/javascript">
103
- var encrypted = CryptoJS.AES(...);
104
- var encrypted = CryptoJS.SHA256(...);
105
- </script>
106
- ```
107
-
108
- ## API
109
-
110
- See: https://cryptojs.gitbook.io/docs/
111
-
112
- ### AES Encryption
113
-
114
- #### Plain text encryption
115
-
116
- ```javascript
117
- var CryptoJS = require("crypto-js");
118
-
119
- // Encrypt
120
- var ciphertext = CryptoJS.AES.encrypt('my message', 'secret key 123').toString();
121
-
122
- // Decrypt
123
- var bytes = CryptoJS.AES.decrypt(ciphertext, 'secret key 123');
124
- var originalText = bytes.toString(CryptoJS.enc.Utf8);
125
-
126
- console.log(originalText); // 'my message'
127
- ```
128
-
129
- #### Object encryption
130
-
131
- ```javascript
132
- var CryptoJS = require("crypto-js");
133
-
134
- var data = [{id: 1}, {id: 2}]
135
-
136
- // Encrypt
137
- var ciphertext = CryptoJS.AES.encrypt(JSON.stringify(data), 'secret key 123').toString();
138
-
139
- // Decrypt
140
- var bytes = CryptoJS.AES.decrypt(ciphertext, 'secret key 123');
141
- var decryptedData = JSON.parse(bytes.toString(CryptoJS.enc.Utf8));
142
-
143
- console.log(decryptedData); // [{id: 1}, {id: 2}]
144
- ```
145
-
146
- ### List of modules
147
-
148
-
149
- - ```crypto-js/core```
150
- - ```crypto-js/x64-core```
151
- - ```crypto-js/lib-typedarrays```
152
-
153
- ---
154
-
155
- - ```crypto-js/md5```
156
- - ```crypto-js/sha1```
157
- - ```crypto-js/sha256```
158
- - ```crypto-js/sha224```
159
- - ```crypto-js/sha512```
160
- - ```crypto-js/sha384```
161
- - ```crypto-js/sha3```
162
- - ```crypto-js/ripemd160```
163
-
164
- ---
165
-
166
- - ```crypto-js/hmac-md5```
167
- - ```crypto-js/hmac-sha1```
168
- - ```crypto-js/hmac-sha256```
169
- - ```crypto-js/hmac-sha224```
170
- - ```crypto-js/hmac-sha512```
171
- - ```crypto-js/hmac-sha384```
172
- - ```crypto-js/hmac-sha3```
173
- - ```crypto-js/hmac-ripemd160```
174
-
175
- ---
176
-
177
- - ```crypto-js/pbkdf2```
178
-
179
- ---
180
-
181
- - ```crypto-js/aes```
182
- - ```crypto-js/tripledes```
183
- - ```crypto-js/rc4```
184
- - ```crypto-js/rabbit```
185
- - ```crypto-js/rabbit-legacy```
186
- - ```crypto-js/evpkdf```
187
-
188
- ---
189
-
190
- - ```crypto-js/format-openssl```
191
- - ```crypto-js/format-hex```
192
-
193
- ---
194
-
195
- - ```crypto-js/enc-latin1```
196
- - ```crypto-js/enc-utf8```
197
- - ```crypto-js/enc-hex```
198
- - ```crypto-js/enc-utf16```
199
- - ```crypto-js/enc-base64```
200
-
201
- ---
202
-
203
- - ```crypto-js/mode-cfb```
204
- - ```crypto-js/mode-ctr```
205
- - ```crypto-js/mode-ctr-gladman```
206
- - ```crypto-js/mode-ofb```
207
- - ```crypto-js/mode-ecb```
208
-
209
- ---
210
-
211
- - ```crypto-js/pad-pkcs7```
212
- - ```crypto-js/pad-ansix923```
213
- - ```crypto-js/pad-iso10126```
214
- - ```crypto-js/pad-iso97971```
215
- - ```crypto-js/pad-zeropadding```
216
- - ```crypto-js/pad-nopadding```
217
-
218
-
219
- ## Release notes
220
-
221
- ### 4.2.0
222
-
223
- Change default hash algorithm and iteration's for PBKDF2 to prevent weak security by using the default configuration.
224
-
225
- Custom KDF Hasher
226
-
227
- Blowfish support
228
-
229
- ### 4.1.1
230
-
231
- Fix module order in bundled release.
232
-
233
- Include the browser field in the released package.json.
234
-
235
- ### 4.1.0
236
-
237
- Added url safe variant of base64 encoding. [357](https://github.com/brix/crypto-js/pull/357)
238
-
239
- Avoid webpack to add crypto-browser package. [364](https://github.com/brix/crypto-js/pull/364)
240
-
241
- ### 4.0.0
242
-
243
- This is an update including breaking changes for some environments.
244
-
245
- In this version `Math.random()` has been replaced by the random methods of the native crypto module.
246
-
247
- For this reason CryptoJS might not run in some JavaScript environments without native crypto module. Such as IE 10 or before or React Native.
248
-
249
- ### 3.3.0
250
-
251
- Rollback, `3.3.0` is the same as `3.1.9-1`.
252
-
253
- The move of using native secure crypto module will be shifted to a new `4.x.x` version. As it is a breaking change the impact is too big for a minor release.
254
-
255
- ### 3.2.1
256
-
257
- The usage of the native crypto module has been fixed. The import and access of the native crypto module has been improved.
258
-
259
- ### 3.2.0
260
-
261
- In this version `Math.random()` has been replaced by the random methods of the native crypto module.
262
-
263
- For this reason CryptoJS might does not run in some JavaScript environments without native crypto module. Such as IE 10 or before.
264
-
265
- If it's absolute required to run CryptoJS in such an environment, stay with `3.1.x` version. Encrypting and decrypting stays compatible. But keep in mind `3.1.x` versions still use `Math.random()` which is cryptographically not secure, as it's not random enough.
266
-
267
- This version came along with `CRITICAL` `BUG`.
268
-
269
- DO NOT USE THIS VERSION! Please, go for a newer version!
270
-
271
- ### 3.1.x
272
-
273
- The `3.1.x` are based on the original CryptoJS, wrapped in CommonJS modules.
274
-
275
-