@wppconnect/wa-proto 2.3000.1052070306 → 2.3000.1052191878
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/SECURITY_BACKPORTS.md +17 -0
- package/WAProto.proto +4 -1
- package/dist/index.d.ts +11 -2
- package/dist/index.js +18 -0
- package/package.json +11 -3
- package/scripts/test-package.js +42 -0
- package/test/deepmerge-security.test.js +72 -0
- package/vendor/deepmerge/LICENSE +21 -0
- package/vendor/deepmerge/README.md +3 -0
- package/vendor/deepmerge/index.cjs +113 -0
- package/vendor/deepmerge/index.d.ts +20 -0
- package/vendor/deepmerge/is-mergeable-object.cjs +24 -0
- package/vendor/deepmerge/package.json +19 -0
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Private deepmerge backport
|
|
2
|
+
|
|
3
|
+
This repository-maintained artifact is based on deepmerge4.3.1 and the prototype-poisoning fix from upstream PR274, commit c5ad573121574db1c625b0aabcc6114ed7df6c5a. Its local version4.3.2+wppconnect.1 identifies our security patch and preserves4.x dependency compatibility. It is not a published upstream release. The package is private and must not be published to a registry.
|
|
4
|
+
|
|
5
|
+
Both copy loops reject the __proto__ key before assigning properties. Other merging behavior is preserved. The is-mergeable-object1.1.0 helper is included locally because the original Git source declares it only as a development dependency. Original MIT notices are retained.
|
|
6
|
+
|
|
7
|
+
Source references:
|
|
8
|
+
|
|
9
|
+
- https://github.com/TehShrike/deepmerge/tree/5b87756a5671635679001cbac72aa42f23472c81
|
|
10
|
+
- https://github.com/TehShrike/deepmerge/pull/274/commits/c5ad573121574db1c625b0aabcc6114ed7df6c5a
|
|
11
|
+
- https://github.com/TehShrike/is-mergeable-object/tree/v1.1.0
|
|
12
|
+
|
|
13
|
+
The readable files in vendor/deepmerge and the local tarball represent the same runtime implementation. Native installed-package tests compare their contents. No install scripts, registry publication or changes to unrelated installed dependencies are needed.
|
|
14
|
+
|
|
15
|
+
Only development tooling uses this backport here; published protocol runtime dependencies are unchanged. The browser-helper override removes extract-zip while retaining the patched Rebrowser23 connector. Native regression tests and the actual WhatsApp bundle fetch/compile path validate that consumer.
|
|
16
|
+
|
|
17
|
+
Keep the regression tests when removing this backport after a validated upstream release is available.
|
package/WAProto.proto
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
syntax = "proto3";
|
|
2
2
|
package waproto;
|
|
3
3
|
|
|
4
|
-
/// WhatsApp Version: 2.3000.
|
|
4
|
+
/// WhatsApp Version: 2.3000.1052191878
|
|
5
5
|
|
|
6
6
|
message ACP2Setting {
|
|
7
7
|
optional bool enabled = 1;
|
|
@@ -506,6 +506,7 @@ message BotCapabilityMetadata {
|
|
|
506
506
|
AI_MUSE_JARVIS_SCHEMA_ENABLED = 81;
|
|
507
507
|
AI_STUDY_QUIZ_ENABLED = 82;
|
|
508
508
|
HATCH_CVM_ENABLED = 83;
|
|
509
|
+
RICH_RESPONSE_SOCIAL_ENTITY_PREFETCH_SCHEDULER_ENABLED = 84;
|
|
509
510
|
}
|
|
510
511
|
}
|
|
511
512
|
|
|
@@ -1377,6 +1378,8 @@ message ClientPayload {
|
|
|
1377
1378
|
DESKTOP = 2;
|
|
1378
1379
|
WEARABLE = 3;
|
|
1379
1380
|
VR = 4;
|
|
1381
|
+
SMART_DISPLAY = 5;
|
|
1382
|
+
SMART_SPEAKER = 6;
|
|
1380
1383
|
}
|
|
1381
1384
|
enum DistributionChannel {
|
|
1382
1385
|
APPSTORE = 0;
|
package/dist/index.d.ts
CHANGED
|
@@ -7332,7 +7332,10 @@ export namespace waproto {
|
|
|
7332
7332
|
AI_STUDY_QUIZ_ENABLED = 82,
|
|
7333
7333
|
|
|
7334
7334
|
/** HATCH_CVM_ENABLED value */
|
|
7335
|
-
HATCH_CVM_ENABLED = 83
|
|
7335
|
+
HATCH_CVM_ENABLED = 83,
|
|
7336
|
+
|
|
7337
|
+
/** RICH_RESPONSE_SOCIAL_ENTITY_PREFETCH_SCHEDULER_ENABLED value */
|
|
7338
|
+
RICH_RESPONSE_SOCIAL_ENTITY_PREFETCH_SCHEDULER_ENABLED = 84
|
|
7336
7339
|
}
|
|
7337
7340
|
}
|
|
7338
7341
|
|
|
@@ -18651,7 +18654,13 @@ export namespace waproto {
|
|
|
18651
18654
|
WEARABLE = 3,
|
|
18652
18655
|
|
|
18653
18656
|
/** VR value */
|
|
18654
|
-
VR = 4
|
|
18657
|
+
VR = 4,
|
|
18658
|
+
|
|
18659
|
+
/** SMART_DISPLAY value */
|
|
18660
|
+
SMART_DISPLAY = 5,
|
|
18661
|
+
|
|
18662
|
+
/** SMART_SPEAKER value */
|
|
18663
|
+
SMART_SPEAKER = 6
|
|
18655
18664
|
}
|
|
18656
18665
|
|
|
18657
18666
|
/** DistributionChannel enum. */
|
package/dist/index.js
CHANGED
|
@@ -19936,6 +19936,10 @@ $root.waproto = (function() {
|
|
|
19936
19936
|
case 83:
|
|
19937
19937
|
message.capabilities[message.capabilities.length] = 83;
|
|
19938
19938
|
break;
|
|
19939
|
+
case "RICH_RESPONSE_SOCIAL_ENTITY_PREFETCH_SCHEDULER_ENABLED":
|
|
19940
|
+
case 84:
|
|
19941
|
+
message.capabilities[message.capabilities.length] = 84;
|
|
19942
|
+
break;
|
|
19939
19943
|
default:
|
|
19940
19944
|
if (typeof object.capabilities[i] === "number" && (object.capabilities[i] | 0) === object.capabilities[i])
|
|
19941
19945
|
message.capabilities[message.capabilities.length] = object.capabilities[i];
|
|
@@ -20084,6 +20088,7 @@ $root.waproto = (function() {
|
|
|
20084
20088
|
* @property {number} AI_MUSE_JARVIS_SCHEMA_ENABLED=81 AI_MUSE_JARVIS_SCHEMA_ENABLED value
|
|
20085
20089
|
* @property {number} AI_STUDY_QUIZ_ENABLED=82 AI_STUDY_QUIZ_ENABLED value
|
|
20086
20090
|
* @property {number} HATCH_CVM_ENABLED=83 HATCH_CVM_ENABLED value
|
|
20091
|
+
* @property {number} RICH_RESPONSE_SOCIAL_ENTITY_PREFETCH_SCHEDULER_ENABLED=84 RICH_RESPONSE_SOCIAL_ENTITY_PREFETCH_SCHEDULER_ENABLED value
|
|
20087
20092
|
*/
|
|
20088
20093
|
BotCapabilityMetadata.BotCapabilityType = (function() {
|
|
20089
20094
|
var valuesById = $Object.create(null), values = $Object.create(valuesById);
|
|
@@ -20171,6 +20176,7 @@ $root.waproto = (function() {
|
|
|
20171
20176
|
values[valuesById[81] = "AI_MUSE_JARVIS_SCHEMA_ENABLED"] = 81;
|
|
20172
20177
|
values[valuesById[82] = "AI_STUDY_QUIZ_ENABLED"] = 82;
|
|
20173
20178
|
values[valuesById[83] = "HATCH_CVM_ENABLED"] = 83;
|
|
20179
|
+
values[valuesById[84] = "RICH_RESPONSE_SOCIAL_ENTITY_PREFETCH_SCHEDULER_ENABLED"] = 84;
|
|
20174
20180
|
return values;
|
|
20175
20181
|
})();
|
|
20176
20182
|
|
|
@@ -53062,6 +53068,14 @@ $root.waproto = (function() {
|
|
|
53062
53068
|
case 4:
|
|
53063
53069
|
message.deviceType = 4;
|
|
53064
53070
|
break;
|
|
53071
|
+
case "SMART_DISPLAY":
|
|
53072
|
+
case 5:
|
|
53073
|
+
message.deviceType = 5;
|
|
53074
|
+
break;
|
|
53075
|
+
case "SMART_SPEAKER":
|
|
53076
|
+
case 6:
|
|
53077
|
+
message.deviceType = 6;
|
|
53078
|
+
break;
|
|
53065
53079
|
default:
|
|
53066
53080
|
if (typeof object.deviceType === "number" && (object.deviceType | 0) === object.deviceType)
|
|
53067
53081
|
message.deviceType = object.deviceType;
|
|
@@ -53594,6 +53608,8 @@ $root.waproto = (function() {
|
|
|
53594
53608
|
* @property {number} DESKTOP=2 DESKTOP value
|
|
53595
53609
|
* @property {number} WEARABLE=3 WEARABLE value
|
|
53596
53610
|
* @property {number} VR=4 VR value
|
|
53611
|
+
* @property {number} SMART_DISPLAY=5 SMART_DISPLAY value
|
|
53612
|
+
* @property {number} SMART_SPEAKER=6 SMART_SPEAKER value
|
|
53597
53613
|
*/
|
|
53598
53614
|
UserAgent.DeviceType = (function() {
|
|
53599
53615
|
var valuesById = $Object.create(null), values = $Object.create(valuesById);
|
|
@@ -53602,6 +53618,8 @@ $root.waproto = (function() {
|
|
|
53602
53618
|
values[valuesById[2] = "DESKTOP"] = 2;
|
|
53603
53619
|
values[valuesById[3] = "WEARABLE"] = 3;
|
|
53604
53620
|
values[valuesById[4] = "VR"] = 4;
|
|
53621
|
+
values[valuesById[5] = "SMART_DISPLAY"] = 5;
|
|
53622
|
+
values[valuesById[6] = "SMART_SPEAKER"] = 6;
|
|
53605
53623
|
return values;
|
|
53606
53624
|
})();
|
|
53607
53625
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wppconnect/wa-proto",
|
|
3
|
-
"version": "2.3000.
|
|
3
|
+
"version": "2.3000.1052191878",
|
|
4
4
|
"description": "Protobuf files from WhatsApp WEB",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
"compile": "npm run compile:js && npm run compile:ts",
|
|
20
20
|
"compile:js": "node scripts/patch-protobufjs-parser.js && pbjs -t static-module --sparse -w commonjs -o ./dist/index.js ./WAProto.proto",
|
|
21
21
|
"compile:ts": "pbts -o ./dist/index.d.ts ./dist/index.js",
|
|
22
|
-
"fetch": "node index.js"
|
|
22
|
+
"fetch": "node index.js",
|
|
23
|
+
"test:package": "node scripts/test-package.js"
|
|
23
24
|
},
|
|
24
25
|
"dependencies": {
|
|
25
26
|
"long": "^5.3.2",
|
|
@@ -29,6 +30,13 @@
|
|
|
29
30
|
"acorn": "^8.19.0",
|
|
30
31
|
"acorn-walk": "^8.3.5",
|
|
31
32
|
"protobufjs-cli": "^2.7.1",
|
|
32
|
-
"puppeteer-real-browser": "^1.4.4"
|
|
33
|
+
"puppeteer-real-browser": "^1.4.4",
|
|
34
|
+
"deepmerge": "file:vendor/deepmerge-4.3.2+wppconnect.1.tgz"
|
|
35
|
+
},
|
|
36
|
+
"overrides": {
|
|
37
|
+
"deepmerge": "$deepmerge",
|
|
38
|
+
"rebrowser-puppeteer-core": {
|
|
39
|
+
"@puppeteer/browsers": "3.2.4"
|
|
40
|
+
}
|
|
33
41
|
}
|
|
34
42
|
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 WPPConnect Team
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
const assert = require('node:assert/strict');
|
|
17
|
+
const fs = require('node:fs');
|
|
18
|
+
const os = require('node:os');
|
|
19
|
+
const path = require('node:path');
|
|
20
|
+
const { spawnSync } = require('node:child_process');
|
|
21
|
+
|
|
22
|
+
const root = path.resolve(__dirname, '..');
|
|
23
|
+
const scratch = fs.mkdtempSync(path.join(os.tmpdir(), 'wpp-proto-package-'));
|
|
24
|
+
const npm = process.env.npm_execpath;
|
|
25
|
+
assert(npm && /npm-cli\.js$/.test(npm), 'Run using npm run test:package');
|
|
26
|
+
function run(args, cwd) {
|
|
27
|
+
const result = spawnSync(process.execPath, args, { cwd, encoding: 'utf8', timeout: 180000 });
|
|
28
|
+
assert.equal(result.status, 0, result.stdout + result.stderr + (result.error?.message || ''));
|
|
29
|
+
return result.stdout;
|
|
30
|
+
}
|
|
31
|
+
try {
|
|
32
|
+
const packed = JSON.parse(run([npm, 'pack', '--ignore-scripts', '--json', '--pack-destination', scratch], root))[0];
|
|
33
|
+
const consumer = path.join(scratch, 'consumer');
|
|
34
|
+
fs.mkdirSync(consumer);
|
|
35
|
+
fs.writeFileSync(path.join(consumer, 'package.json'), JSON.stringify({ name: 'proto-package-consumer', version: '0.0.0', private: true }));
|
|
36
|
+
run([npm, 'install', '--omit=dev', '--ignore-scripts', '--no-audit', '--no-fund', path.join(scratch, packed.filename)], consumer);
|
|
37
|
+
const code = `const assert=require('node:assert/strict');const root=require('@wppconnect/wa-proto');const proto=Object.values(root).find(value=>value&&value.Message&&typeof value.Message.encode==='function');assert(proto,'Published Message codec missing');const bytes=proto.Message.encode({conversation:'package-regression'}).finish();assert.equal(proto.Message.decode(bytes).conversation,'package-regression');for(const name of ['puppeteer-real-browser','deepmerge','extract-zip']){assert.throws(()=>require.resolve(name),{code:'MODULE_NOT_FOUND'});}console.log('Published protocol roundtrip passed without development browser dependencies.');`;
|
|
38
|
+
process.stdout.write(run(['-e', code], consumer));
|
|
39
|
+
} finally {
|
|
40
|
+
assert.equal(path.dirname(path.resolve(scratch)), path.resolve(os.tmpdir()));
|
|
41
|
+
fs.rmSync(scratch, { recursive: true, force: true });
|
|
42
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2026 WPPConnect Team
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
const assert = require('node:assert/strict');
|
|
17
|
+
const { createRequire } = require('node:module');
|
|
18
|
+
const { test } = require('node:test');
|
|
19
|
+
const owner = createRequire(require.resolve('puppeteer-extra'));
|
|
20
|
+
const merge = owner('deepmerge');
|
|
21
|
+
|
|
22
|
+
const malicious = () => JSON.parse('{"__proto__":{"isAdmin":true}}');
|
|
23
|
+
function assertSafe(value) {
|
|
24
|
+
assert.equal(Object.getPrototypeOf(value), Object.prototype);
|
|
25
|
+
assert.equal(value.isAdmin, undefined);
|
|
26
|
+
assert.equal(Object.hasOwn(value, '__proto__'), false);
|
|
27
|
+
assert.equal({}.isAdmin, undefined);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
test('browser options cannot inherit attacker values from a null-prototype target', () => {
|
|
31
|
+
const target = Object.assign(Object.create(null), { debug: false });
|
|
32
|
+
const result = merge(target, malicious());
|
|
33
|
+
assertSafe(result);
|
|
34
|
+
assert.equal(result.debug, false);
|
|
35
|
+
});
|
|
36
|
+
test('browser options cannot inherit attacker values through a null placeholder', () => {
|
|
37
|
+
const input = { session: malicious() };
|
|
38
|
+
assertSafe(merge({ session: null }, input).session);
|
|
39
|
+
});
|
|
40
|
+
test('browser options reject a proto key already present in the defaults', () => {
|
|
41
|
+
const result = merge(malicious(), { debug: false });
|
|
42
|
+
assertSafe(result);
|
|
43
|
+
assert.equal(result.debug, false);
|
|
44
|
+
});
|
|
45
|
+
test('browser options cannot inherit attacker values through a primitive placeholder', () => {
|
|
46
|
+
assertSafe(merge({ session: 1 }, { session: malicious() }).session);
|
|
47
|
+
});
|
|
48
|
+
test('cloned browser option arrays retain safe element prototypes', () => {
|
|
49
|
+
const result = merge({ list: [] }, { list: [malicious()] });
|
|
50
|
+
assertSafe(result.list[0]);
|
|
51
|
+
});
|
|
52
|
+
test('browser option merging retains arrays, symbols, custom merging and source objects', () => {
|
|
53
|
+
const key = Symbol('option');
|
|
54
|
+
const first = { args: ['--one'], nested: { a: 1 }, [key]: 1 };
|
|
55
|
+
const second = { args: ['--two'], nested: { b: 2 } };
|
|
56
|
+
assert.deepEqual(merge.all([first, second]).args, ['--one', '--two']);
|
|
57
|
+
assert.deepEqual(first.args, ['--one']);
|
|
58
|
+
assert.equal(merge(first, second)[key], 1);
|
|
59
|
+
assert.deepEqual(merge(first, second, { arrayMerge: (_a, b) => b }).args, ['--two']);
|
|
60
|
+
assert.deepEqual(merge(first, second, { customMerge: (name) => name === 'nested' ? (a, b) => ({ a: a.a + b.b }) : undefined }).nested, { a: 3 });
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const fs = require('node:fs');
|
|
64
|
+
const path = require('node:path');
|
|
65
|
+
test('installed browser merger matches the reviewed private runtime files', () => {
|
|
66
|
+
const installed = path.dirname(owner.resolve('deepmerge'));
|
|
67
|
+
for (const file of ['index.cjs', 'is-mergeable-object.cjs']) {
|
|
68
|
+
const actual = fs.readFileSync(path.join(installed, file), 'utf8').replace(/\r\n/g, '\n');
|
|
69
|
+
const expected = fs.readFileSync(path.join(__dirname, '../vendor/deepmerge', file), 'utf8').replace(/\r\n/g, '\n');
|
|
70
|
+
assert.equal(actual, expected);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2012 James Halliday, Josh Duff, and other contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
# Private local security backport
|
|
2
|
+
|
|
3
|
+
This package contains deepmerge4.3.1 plus the prototype-poisoning fix from upstream PR274, commit c5ad573121574db1c625b0aabcc6114ed7df6c5a. Version4.3.2+wppconnect.1 identifies this private local patch and its4.x compatibility; it is not an upstream release and is never published to a registry. The original package name is preserved for transitive dependency matching. The is-mergeable-object1.1.0 helper is included locally. Both libraries are MIT-licensed; original notices are preserved.
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
var defaultIsMergeableObject = require('./is-mergeable-object.cjs')
|
|
2
|
+
|
|
3
|
+
function emptyTarget(val) {
|
|
4
|
+
return Array.isArray(val) ? [] : {}
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
function cloneUnlessOtherwiseSpecified(value, options) {
|
|
8
|
+
return (options.clone !== false && options.isMergeableObject(value))
|
|
9
|
+
? deepmerge(emptyTarget(value), value, options)
|
|
10
|
+
: value
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function defaultArrayMerge(target, source, options) {
|
|
14
|
+
return target.concat(source).map(function(element) {
|
|
15
|
+
return cloneUnlessOtherwiseSpecified(element, options)
|
|
16
|
+
})
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function getMergeFunction(key, options) {
|
|
20
|
+
if (!options.customMerge) {
|
|
21
|
+
return deepmerge
|
|
22
|
+
}
|
|
23
|
+
var customMerge = options.customMerge(key)
|
|
24
|
+
return typeof customMerge === 'function' ? customMerge : deepmerge
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function getEnumerableOwnPropertySymbols(target) {
|
|
28
|
+
return Object.getOwnPropertySymbols
|
|
29
|
+
? Object.getOwnPropertySymbols(target).filter(function(symbol) {
|
|
30
|
+
return Object.propertyIsEnumerable.call(target, symbol)
|
|
31
|
+
})
|
|
32
|
+
: []
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function getKeys(target) {
|
|
36
|
+
return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target))
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function propertyIsOnObject(object, property) {
|
|
40
|
+
try {
|
|
41
|
+
return property in object
|
|
42
|
+
} catch(_) {
|
|
43
|
+
return false
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function propertyIsForbidden(key) {
|
|
48
|
+
return key === '__proto__'
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// Protects from prototype poisoning and unexpected merging up the prototype chain.
|
|
52
|
+
function propertyIsUnsafe(target, key) {
|
|
53
|
+
return propertyIsOnObject(target, key) // Properties are safe to merge if they don't exist in the target yet,
|
|
54
|
+
&& !(Object.hasOwnProperty.call(target, key) // unsafe if they exist up the prototype chain,
|
|
55
|
+
&& Object.propertyIsEnumerable.call(target, key)) // and also unsafe if they're nonenumerable.
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function mergeObject(target, source, options) {
|
|
59
|
+
var destination = {}
|
|
60
|
+
if (options.isMergeableObject(target)) {
|
|
61
|
+
getKeys(target).forEach(function(key) {
|
|
62
|
+
if (propertyIsForbidden(key)) {
|
|
63
|
+
return
|
|
64
|
+
}
|
|
65
|
+
destination[key] = cloneUnlessOtherwiseSpecified(target[key], options)
|
|
66
|
+
})
|
|
67
|
+
}
|
|
68
|
+
getKeys(source).forEach(function(key) {
|
|
69
|
+
if (propertyIsForbidden(key) || propertyIsUnsafe(target, key)) {
|
|
70
|
+
return
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) {
|
|
74
|
+
destination[key] = getMergeFunction(key, options)(target[key], source[key], options)
|
|
75
|
+
} else {
|
|
76
|
+
destination[key] = cloneUnlessOtherwiseSpecified(source[key], options)
|
|
77
|
+
}
|
|
78
|
+
})
|
|
79
|
+
return destination
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function deepmerge(target, source, options) {
|
|
83
|
+
options = options || {}
|
|
84
|
+
options.arrayMerge = options.arrayMerge || defaultArrayMerge
|
|
85
|
+
options.isMergeableObject = options.isMergeableObject || defaultIsMergeableObject
|
|
86
|
+
// cloneUnlessOtherwiseSpecified is added to `options` so that custom arrayMerge()
|
|
87
|
+
// implementations can use it. The caller may not replace it.
|
|
88
|
+
options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified
|
|
89
|
+
|
|
90
|
+
var sourceIsArray = Array.isArray(source)
|
|
91
|
+
var targetIsArray = Array.isArray(target)
|
|
92
|
+
var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray
|
|
93
|
+
|
|
94
|
+
if (!sourceAndTargetTypesMatch) {
|
|
95
|
+
return cloneUnlessOtherwiseSpecified(source, options)
|
|
96
|
+
} else if (sourceIsArray) {
|
|
97
|
+
return options.arrayMerge(target, source, options)
|
|
98
|
+
} else {
|
|
99
|
+
return mergeObject(target, source, options)
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
deepmerge.all = function deepmergeAll(array, options) {
|
|
104
|
+
if (!Array.isArray(array)) {
|
|
105
|
+
throw new Error('first argument should be an array')
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return array.reduce(function(prev, next) {
|
|
109
|
+
return deepmerge(prev, next, options)
|
|
110
|
+
}, {})
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
module.exports = deepmerge
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
declare function deepmerge<T>(x: Partial<T>, y: Partial<T>, options?: deepmerge.Options): T;
|
|
2
|
+
declare function deepmerge<T1, T2>(x: Partial<T1>, y: Partial<T2>, options?: deepmerge.Options): T1 & T2;
|
|
3
|
+
|
|
4
|
+
declare namespace deepmerge {
|
|
5
|
+
export interface Options {
|
|
6
|
+
arrayMerge?(target: any[], source: any[], options?: ArrayMergeOptions): any[];
|
|
7
|
+
clone?: boolean;
|
|
8
|
+
customMerge?: (key: string, options?: Options) => ((x: any, y: any) => any) | undefined;
|
|
9
|
+
isMergeableObject?(value: object): boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface ArrayMergeOptions {
|
|
12
|
+
isMergeableObject(value: object): boolean;
|
|
13
|
+
cloneUnlessOtherwiseSpecified(value: object, options?: Options): object;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function all (objects: object[], options?: Options): object;
|
|
17
|
+
export function all<T> (objects: Partial<T>[], options?: Options): T;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export = deepmerge;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
module.exports = function isMergeableObject(value) {
|
|
2
|
+
return isNonNullObject(value)
|
|
3
|
+
&& !isSpecial(value)
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
function isNonNullObject(value) {
|
|
7
|
+
return !!value && typeof value === 'object'
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function isSpecial(value) {
|
|
11
|
+
var stringValue = Object.prototype.toString.call(value)
|
|
12
|
+
|
|
13
|
+
return stringValue === '[object RegExp]'
|
|
14
|
+
|| stringValue === '[object Date]'
|
|
15
|
+
|| isReactElement(value)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// see https://github.com/facebook/react/blob/b5ac963fb791d1298e7f396236383bc955f916c1/src/isomorphic/classic/element/ReactElement.js#L21-L25
|
|
19
|
+
var canUseSymbol = typeof Symbol === 'function' && Symbol.for
|
|
20
|
+
var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for('react.element') : 0xeac7
|
|
21
|
+
|
|
22
|
+
function isReactElement(value) {
|
|
23
|
+
return value.$$typeof === REACT_ELEMENT_TYPE
|
|
24
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "deepmerge",
|
|
3
|
+
"version": "4.3.2+wppconnect.1",
|
|
4
|
+
"private": true,
|
|
5
|
+
"description": "Private unpublished WPPConnect patch of deepmerge4.3.1. This version is local, not an upstream registry release.",
|
|
6
|
+
"main": "index.cjs",
|
|
7
|
+
"types": "index.d.ts",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"files": [
|
|
10
|
+
"index.cjs",
|
|
11
|
+
"is-mergeable-object.cjs",
|
|
12
|
+
"index.d.ts",
|
|
13
|
+
"LICENSE",
|
|
14
|
+
"README.md"
|
|
15
|
+
],
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">=0.10.0"
|
|
18
|
+
}
|
|
19
|
+
}
|