+57
-41
@@ -392,3 +392,3 @@ "use strict"; | ||
| const requestPairingCode = async (phoneNumber, pairKey) => { | ||
| await waitForSocketOpen(); | ||
| var _a, _b; | ||
| const pairingCode = pairKey || (0, Utils_1.bytesToCrockford)((0, crypto_1.randomBytes)(5)); | ||
@@ -404,49 +404,65 @@ if (pairKey && pairKey.length !== 8) { | ||
| ev.emit('creds.update', authState.creds); | ||
| await sendNode({ | ||
| tag: 'iq', | ||
| attrs: { | ||
| to: WABinary_1.S_WHATSAPP_NET, | ||
| type: 'set', | ||
| id: generateMessageTag(), | ||
| xmlns: 'md' | ||
| }, | ||
| content: [ | ||
| { | ||
| tag: 'link_code_companion_reg', | ||
| const maxRetries = 2; | ||
| for (let attempt = 1; attempt <= maxRetries; attempt++) { | ||
| try { | ||
| await waitForSocketOpen(); | ||
| await sendNode({ | ||
| tag: 'iq', | ||
| attrs: { | ||
| jid: authState.creds.me.id, | ||
| stage: 'companion_hello', | ||
| // eslint-disable-next-line camelcase | ||
| should_show_push_notification: 'true' | ||
| to: WABinary_1.S_WHATSAPP_NET, | ||
| type: 'set', | ||
| id: generateMessageTag(), | ||
| xmlns: 'md' | ||
| }, | ||
| content: [ | ||
| { | ||
| tag: 'link_code_pairing_wrapped_companion_ephemeral_pub', | ||
| attrs: {}, | ||
| content: await generatePairingKey() | ||
| }, | ||
| { | ||
| tag: 'companion_server_auth_key_pub', | ||
| attrs: {}, | ||
| content: authState.creds.noiseKey.public | ||
| }, | ||
| { | ||
| tag: 'companion_platform_id', | ||
| attrs: {}, | ||
| content: (0, Utils_1.getPlatformId)(browser[1]) | ||
| }, | ||
| { | ||
| tag: 'companion_platform_display', | ||
| attrs: {}, | ||
| content: `${browser[1]} (${browser[0]})` | ||
| }, | ||
| { | ||
| tag: 'link_code_pairing_nonce', | ||
| attrs: {}, | ||
| content: '0' | ||
| tag: 'link_code_companion_reg', | ||
| attrs: { | ||
| jid: authState.creds.me.id, | ||
| stage: 'companion_hello', | ||
| // eslint-disable-next-line camelcase | ||
| should_show_push_notification: 'true' | ||
| }, | ||
| content: [ | ||
| { | ||
| tag: 'link_code_pairing_wrapped_companion_ephemeral_pub', | ||
| attrs: {}, | ||
| content: await generatePairingKey() | ||
| }, | ||
| { | ||
| tag: 'companion_server_auth_key_pub', | ||
| attrs: {}, | ||
| content: authState.creds.noiseKey.public | ||
| }, | ||
| { | ||
| tag: 'companion_platform_id', | ||
| attrs: {}, | ||
| content: (0, Utils_1.getPlatformId)(browser[1]) | ||
| }, | ||
| { | ||
| tag: 'companion_platform_display', | ||
| attrs: {}, | ||
| content: `${browser[1]} (${browser[0]})` | ||
| }, | ||
| { | ||
| tag: 'link_code_pairing_nonce', | ||
| attrs: {}, | ||
| content: '0' | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| }); | ||
| break; | ||
| } | ||
| catch (error) { | ||
| const statusCode = ((_b = (_a = error === null || error === void 0 ? void 0 : error.output) === null || _a === void 0 ? void 0 : _a.payload) === null || _b === void 0 ? void 0 : _b.statusCode) || (error === null || error === void 0 ? void 0 : error.statusCode); | ||
| const canRetry = statusCode === 428 || statusCode === Types_1.DisconnectReason.connectionClosed || statusCode === Types_1.DisconnectReason.connectionLost; | ||
| if (!canRetry || attempt >= maxRetries) { | ||
| throw error; | ||
| } | ||
| ] | ||
| }); | ||
| logger.warn({ attempt, statusCode, trace: error === null || error === void 0 ? void 0 : error.stack }, 'pairing code request failed, retrying'); | ||
| await (0, Utils_1.delay)(500 * attempt); | ||
| } | ||
| } | ||
| return authState.creds.pairingCode; | ||
@@ -453,0 +469,0 @@ }; |
+1
-1
| { | ||
| "name": "wileys", | ||
| "version": "0.4.4", | ||
| "version": "0.4.5", | ||
| "description": "WhatsApp Web API Library", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 2 instances in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 2 instances in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
9802780
0.01%31445
0.05%