kage-baileys 25.3.41 → 25.4.6
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/README.md +71 -44
- package/WAProto/WAProto.proto +83 -0
- package/helpers/interactive-pay.d.ts +6 -1
- package/helpers/interactive-pay.js +80 -10
- package/lib/Defaults/index.d.ts +1 -0
- package/lib/Defaults/index.js +2 -0
- package/lib/Extensions/bootstrap.cjs +3 -3
- package/lib/Socket/business.d.ts +2 -0
- package/lib/Socket/chats.d.ts +2 -0
- package/lib/Socket/communities.d.ts +2 -0
- package/lib/Socket/groups.d.ts +2 -0
- package/lib/Socket/index.d.ts +2 -0
- package/lib/Socket/messages-recv.d.ts +2 -0
- package/lib/Socket/messages-recv.js +96 -60
- package/lib/Socket/messages-send.d.ts +2 -0
- package/lib/Socket/messages-send.js +40 -2
- package/lib/Socket/newsletter.d.ts +2 -0
- package/lib/Socket/socket.d.ts +2 -0
- package/lib/Socket/socket.js +112 -52
- package/lib/Types/Auth.d.ts +5 -1
- package/lib/Types/Kage.d.ts +1 -1
- package/lib/Types/Socket.d.ts +2 -0
- package/lib/Utils/auth-store.d.ts +30 -0
- package/lib/Utils/auth-store.js +77 -0
- package/lib/Utils/group-metadata-cache.d.ts +5 -0
- package/lib/Utils/group-metadata-cache.js +26 -0
- package/lib/Utils/html-app.d.ts +19 -0
- package/lib/Utils/html-app.js +97 -0
- package/lib/Utils/html-multiplayer.d.ts +10 -0
- package/lib/Utils/html-multiplayer.js +95 -0
- package/lib/Utils/index.d.ts +22 -0
- package/lib/Utils/index.js +23 -0
- package/lib/Utils/link-preview-metadata.d.ts +47 -0
- package/lib/Utils/link-preview-metadata.js +89 -0
- package/lib/Utils/modern-messages.d.ts +150 -0
- package/lib/Utils/modern-messages.js +496 -0
- package/lib/Utils/native-flow.d.ts +2 -0
- package/lib/Utils/native-flow.js +142 -0
- package/lib/Utils/newsletter-status.d.ts +158 -0
- package/lib/Utils/newsletter-status.js +651 -0
- package/lib/Utils/pairing-code.d.ts +14 -0
- package/lib/Utils/pairing-code.js +89 -0
- package/lib/Utils/scheduled-message.d.ts +51 -0
- package/lib/Utils/scheduled-message.js +113 -0
- package/lib/Utils/sender-key-memory.d.ts +20 -0
- package/lib/Utils/sender-key-memory.js +52 -0
- package/lib/Utils/status-stickers.d.ts +127 -0
- package/lib/Utils/status-stickers.js +261 -0
- package/lib/Utils/ttl-cache.d.ts +29 -0
- package/lib/Utils/ttl-cache.js +121 -0
- package/lib/Utils/use-mongo-auth-state.d.ts +22 -0
- package/lib/Utils/use-mongo-auth-state.js +68 -0
- package/lib/Utils/use-mysql-auth-state.d.ts +20 -0
- package/lib/Utils/use-mysql-auth-state.js +80 -0
- package/lib/Utils/use-postgres-auth-state.d.ts +20 -0
- package/lib/Utils/use-postgres-auth-state.js +80 -0
- package/lib/Utils/use-redis-auth-state.d.ts +20 -0
- package/lib/Utils/use-redis-auth-state.js +90 -0
- package/lib/Utils/use-single-file-auth-state.d.ts +11 -0
- package/lib/Utils/use-single-file-auth-state.js +109 -0
- package/lib/Utils/use-sqlite-auth-state.d.ts +13 -0
- package/lib/Utils/use-sqlite-auth-state.js +121 -0
- package/lib/Utils/useNekoDBAuth.d.ts +19 -0
- package/lib/Utils/useNekoDBAuth.js +111 -0
- package/lib/Utils/username-validation.d.ts +5 -0
- package/lib/Utils/username-validation.js +23 -0
- package/lib/Utils/voice-recognition.d.ts +53 -0
- package/lib/Utils/voice-recognition.js +219 -0
- package/lib/index.d.ts +24 -0
- package/licenses/dnuzi-MIT.txt +21 -0
- package/licenses/itsliaaa-MIT.txt +22 -0
- package/licenses/kage-antigua-MIT.txt +21 -0
- package/licenses/rexxhayanasi-MIT.txt +22 -0
- package/package.json +25 -4
- package/test/cross-fork-helpers.test.js +54 -0
- package/test/native-flow-payment.test.js +86 -56
- package/test/pairing-code.test.mjs +104 -0
package/README.md
CHANGED
|
@@ -1076,68 +1076,48 @@ await sock.sendMessage(jid, {
|
|
|
1076
1076
|
})
|
|
1077
1077
|
```
|
|
1078
1078
|
|
|
1079
|
-
### `review_and_pay` Native Flow
|
|
1079
|
+
### `review_and_pay` Native Flow
|
|
1080
1080
|
|
|
1081
|
-
|
|
1081
|
+
El flujo necesita el mensaje protobuf y el nodo auxiliar `biz` con `native_flow_name: 'order_details'`. Kage 25.4.3 agrega ese nodo automáticamente en `relayMessage()`, normaliza `messageParamsJson: '{}'` y `messageVersion: 1`, valida el JSON y comprueba que los importes del pedido coincidan. No añade automáticamente el nodo `bot` a chats privados normales; solo debe enviarse cuando el destino sea un bot admitido. `sendReviewAndPay()` prepara el `WebMessageInfo` y el nodo `biz` para otros sockets.
|
|
1082
1082
|
|
|
1083
|
-
|
|
1084
|
-
import { buildReviewAndPayMessage } from 'kage-baileys'
|
|
1083
|
+
Empieza probando sin miniatura ni cuentas de pago para separar el problema de renderizado del proveedor de pagos:
|
|
1085
1084
|
|
|
1086
|
-
|
|
1085
|
+
```javascript
|
|
1086
|
+
await conn.sendReviewAndPay(m.chat, {
|
|
1087
1087
|
header: { title: '', subtitle: '' },
|
|
1088
1088
|
body: 'Texto',
|
|
1089
1089
|
footer: 'Footer',
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
description: 'Pequeña descripción',
|
|
1101
|
-
order_type: 'PAYMENT_REQUEST',
|
|
1102
|
-
items: [{
|
|
1103
|
-
name: 'Título principal',
|
|
1104
|
-
amount: { value: 138, offset: 100 },
|
|
1105
|
-
quantity: 1
|
|
1106
|
-
}]
|
|
1107
|
-
},
|
|
1108
|
-
payment_settings: [
|
|
1109
|
-
{
|
|
1110
|
-
type: 'payment_account',
|
|
1111
|
-
payment_account: {
|
|
1112
|
-
account_type: 'digital_wallet',
|
|
1113
|
-
identifier_type: 'phone_number',
|
|
1114
|
-
identifier_value: '51900000000',
|
|
1115
|
-
institution_name: 'Yape',
|
|
1116
|
-
beneficiary_name: 'Nombre del beneficiario'
|
|
1117
|
-
}
|
|
1118
|
-
}
|
|
1119
|
-
],
|
|
1120
|
-
additional_note: 'Descripción principal',
|
|
1121
|
-
share_payment_status: false,
|
|
1122
|
-
is_soft_deleted: false
|
|
1123
|
-
}
|
|
1090
|
+
currency: 'PEN',
|
|
1091
|
+
totalValue: 137,
|
|
1092
|
+
itemValue: 137,
|
|
1093
|
+
offset: 100,
|
|
1094
|
+
referenceId: 'KFG_001',
|
|
1095
|
+
type: 'physical-goods',
|
|
1096
|
+
itemName: 'Título principal',
|
|
1097
|
+
orderDescription: 'Pequeña descripción',
|
|
1098
|
+
paymentAccounts: [],
|
|
1099
|
+
additionalNote: 'Descripción principal'
|
|
1124
1100
|
})
|
|
1125
|
-
|
|
1126
|
-
await conn.relayMessage(m.chat, content, {})
|
|
1127
1101
|
```
|
|
1128
1102
|
|
|
1129
|
-
|
|
1103
|
+
Cuando el mensaje de texto se muestre, añade una miniatura JPEG válida y menor de 64 KB:
|
|
1130
1104
|
|
|
1131
1105
|
```javascript
|
|
1132
1106
|
await conn.sendReviewAndPay(m.chat, {
|
|
1133
1107
|
body: 'Texto',
|
|
1134
1108
|
footer: 'Footer',
|
|
1135
1109
|
thumbnail: 'https://cdn.example.com/producto.jpg',
|
|
1136
|
-
|
|
1110
|
+
currency: 'PEN',
|
|
1111
|
+
totalValue: 137,
|
|
1112
|
+
itemValue: 137,
|
|
1113
|
+
offset: 100,
|
|
1114
|
+
referenceId: 'KFG_001',
|
|
1115
|
+
itemName: 'Título principal',
|
|
1116
|
+
paymentAccounts: []
|
|
1137
1117
|
})
|
|
1138
1118
|
```
|
|
1139
1119
|
|
|
1140
|
-
`
|
|
1120
|
+
`total_amount` debe coincidir con la suma de `order.items` (importe × cantidad) y usar el mismo `offset`; el constructor calcula `subtotal` y rechaza montos inconsistentes. En el ejemplo, `137` con `offset: 100` representa PEN 1.37. No envíes marcadores como `[NUMERO_PLIN]`: elimina la cuenta de prueba o reemplázala con datos válidos que estés autorizado a utilizar. Que una cuenta bancaria o billetera figure en `payment_settings` no garantiza que WhatsApp la admita como proveedor de pago. Kage construye y transmite el mensaje, pero no procesa cobros ni confirma pagos. El renderizado depende del cliente, la cuenta, la región y las funciones habilitadas por WhatsApp. Para depurar, prueba primero sin miniatura ni cuentas de pago; WhatsApp puede ignorar flujos no habilitados en esa cuenta o cliente. **Disponibilidad regional:** el Centro de ayuda de WhatsApp lista India, Brasil, México e Indonesia para pagar a empresas registradas; fuera de esos países, la función no está disponible. Baileys no puede habilitarla desde el protocolo. En países no incluidos, usa un enlace externo de tu proveedor mediante `cta_url` en vez de `review_and_pay` (consulta https://faq.whatsapp.com/1293279751500598/).
|
|
1141
1121
|
|
|
1142
1122
|
### Helpers de fotos y perfil
|
|
1143
1123
|
|
|
@@ -2295,3 +2275,50 @@ This Kage build incorporates selected fixes reviewed from RedX Baileys 7.0.0-rc1
|
|
|
2295
2275
|
- `newsletterJidFromInvite(codeOrUrl)` resolves the channel JID from metadata.
|
|
2296
2276
|
- WMex response parsing accepts JSON bodies with a binary prefix and safely handles partial newsletter metadata responses.
|
|
2297
2277
|
- Compact binary newsletter metadata is accepted only when exactly one channel JID can be identified; ambiguous payloads are rejected instead of guessed.
|
|
2278
|
+
|
|
2279
|
+
## Kage cross-fork integration (25.4.3)
|
|
2280
|
+
|
|
2281
|
+
This Kage build incorporates the compatible additions identified in the attached Kage Antigua, Dnuzi, ItsLiaaa, and Elaina/Rexx distributions. It keeps Kage's ESM socket, Signal, transport and media core as the single implementation. The additive WAProto schema is loaded by the existing merged-protocol runtime.
|
|
2282
|
+
|
|
2283
|
+
### Native Flow `review_and_pay`
|
|
2284
|
+
|
|
2285
|
+
`buildReviewAndPayMessage()` builds the protobuf-compatible `interactiveMessage` payload. `sendReviewAndPay()` wraps it with `generateWAMessageFromContent`, adds a message ID, and supplies the payment `biz` relay node. The core `relayMessage()` path normalizes `messageParamsJson` and `messageVersion`, validates the order arithmetic, and adds the `biz` node with the `order_details` mapping for `review_and_pay`. The library does not inject a `bot` marker into ordinary private chats. `buttonParamsJson` accepts a JSON string or object and is validated before transmission. Example:
|
|
2286
|
+
|
|
2287
|
+
```js
|
|
2288
|
+
await conn.sendReviewAndPay(chatJid, {
|
|
2289
|
+
header: { title: '', subtitle: '', jpegThumbnail: thumbnailBuffer },
|
|
2290
|
+
body: 'Detalle del pedido',
|
|
2291
|
+
footer: 'Revisa antes de continuar',
|
|
2292
|
+
buttonParamsJson: JSON.stringify({
|
|
2293
|
+
currency: 'PEN',
|
|
2294
|
+
payment_configuration: '',
|
|
2295
|
+
total_amount: { value: 1000, offset: 100 },
|
|
2296
|
+
reference_id: 'ORDER_001',
|
|
2297
|
+
type: 'physical-goods',
|
|
2298
|
+
order: {
|
|
2299
|
+
status: 'pending',
|
|
2300
|
+
description: 'Pedido de prueba',
|
|
2301
|
+
order_type: 'PAYMENT_REQUEST',
|
|
2302
|
+
subtotal: { value: 1000, offset: 100 },
|
|
2303
|
+
items: [{ name: 'Producto', amount: { value: 1000, offset: 100 }, quantity: 1 }]
|
|
2304
|
+
},
|
|
2305
|
+
payment_settings: [],
|
|
2306
|
+
native_payment_methods: []
|
|
2307
|
+
})
|
|
2308
|
+
}, {});
|
|
2309
|
+
```
|
|
2310
|
+
|
|
2311
|
+
This sends a WhatsApp Native Flow payment-request payload only. It does not charge, settle or verify a payment, and rendering depends on WhatsApp client/account/region support and a payment provider activated for that business. The generic helper deliberately does not embed personal payment accounts. The total must match the line-item sum (plus tax/shipping minus discount); Kage calculates a missing subtotal and rejects inconsistent amounts. The core relay automatically attaches the required `biz` companion node even when the caller uses `conn.relayMessage()` directly. WhatsApp Help Center lists India, Brazil, Mexico and Indonesia as markets where customers can pay registered businesses; outside those markets the native payment feature is unavailable. For other countries, use a provider-hosted payment link with a regular `cta_url` button instead.
|
|
2312
|
+
|
|
2313
|
+
### Media status and view-once messages
|
|
2314
|
+
|
|
2315
|
+
Use `getMediaDownloadStatus(message)` to inspect ordinary media availability. Its `status` values distinguish `ready`, `missing_message`, `not_media`, `missing_media_key`, `missing_media_location`, `view_once_protected`, and `view_once_unavailable`. Ordinary media continues to support the normal `downloadMediaMessage()` flow and reupload requests. View-once messages remain protected; a metadata-only stub without a `mediaKey` or `url`/`directPath` cannot be reconstructed by changing the browser identity or by unwrapping JSON. Ask the sender to resend the media normally.
|
|
2316
|
+
|
|
2317
|
+
### Added utility exports
|
|
2318
|
+
|
|
2319
|
+
The root package and `./Utils/*` subpaths now expose additional auth-state adapters (MongoDB, MySQL, PostgreSQL, Redis, SQLite, single-file and NekoDB), TTL cache, sender-key memory helpers, group metadata validation, username validation, modern message constructors, status sticker builders, social link preview helpers, HTML-app validation/multiplayer helpers, scheduled-message helpers and newsletter status helpers. Database drivers are optional peer dependencies and must be installed only when the relevant adapter is used.
|
|
2320
|
+
|
|
2321
|
+
|
|
2322
|
+
## Integrated validation suite
|
|
2323
|
+
|
|
2324
|
+
Run `npm install` before the full suite. `npm test` executes every Kage test, including the Native Flow and protobuf runtime tests that require declared runtime dependencies. `npm run test:offline` executes the isolated offline suite that does not need those external packages. Pairing request construction is tested in `test/pairing-code.test.mjs`, including the single-byte NUL nonce and extraction of the server-issued pairing reference.
|
package/WAProto/WAProto.proto
CHANGED
|
@@ -876,6 +876,8 @@ message BotPluginMetadata {
|
|
|
876
876
|
GOOGLE = 2;
|
|
877
877
|
SUPPORT = 3;
|
|
878
878
|
}
|
|
879
|
+
|
|
880
|
+
optional int32 pluginVersion = 8;
|
|
879
881
|
}
|
|
880
882
|
|
|
881
883
|
message BotProgressIndicatorMetadata {
|
|
@@ -1146,6 +1148,8 @@ message CallLogRecord {
|
|
|
1146
1148
|
|
|
1147
1149
|
|
|
1148
1150
|
message GuestInfo {
|
|
1151
|
+
|
|
1152
|
+
optional string pushName = 1;
|
|
1149
1153
|
}
|
|
1150
1154
|
|
|
1151
1155
|
}
|
|
@@ -1897,6 +1901,8 @@ enum CrossAppSource {
|
|
|
1897
1901
|
}
|
|
1898
1902
|
|
|
1899
1903
|
message InstagramThreadLink {
|
|
1904
|
+
|
|
1905
|
+
optional string url = 1;
|
|
1900
1906
|
}
|
|
1901
1907
|
|
|
1902
1908
|
}
|
|
@@ -2078,15 +2084,23 @@ message AiFbidMigration {
|
|
|
2078
2084
|
}
|
|
2079
2085
|
|
|
2080
2086
|
message BizAiSettingsSync {
|
|
2087
|
+
|
|
2088
|
+
optional bool handoffRemovalTimingEnabled = 1;
|
|
2081
2089
|
}
|
|
2082
2090
|
|
|
2083
2091
|
message BizAiWebOnboarding {
|
|
2092
|
+
|
|
2093
|
+
optional uint32 version = 1;
|
|
2084
2094
|
}
|
|
2085
2095
|
|
|
2086
2096
|
message ContactRefresh {
|
|
2097
|
+
|
|
2098
|
+
optional bool refreshSupported = 1;
|
|
2087
2099
|
}
|
|
2088
2100
|
|
|
2089
2101
|
message HostWriteMutationSupport {
|
|
2102
|
+
|
|
2103
|
+
repeated string mutationNames = 1;
|
|
2090
2104
|
}
|
|
2091
2105
|
|
|
2092
2106
|
message NewsletterChatsMigration {
|
|
@@ -2105,6 +2119,8 @@ message ReverseHistorySync {
|
|
|
2105
2119
|
PRODUCT_UNSPECIFIED = 0;
|
|
2106
2120
|
HATCH = 1;
|
|
2107
2121
|
}
|
|
2122
|
+
|
|
2123
|
+
repeated int32 enabledProducts = 1;
|
|
2108
2124
|
}
|
|
2109
2125
|
|
|
2110
2126
|
}
|
|
@@ -2177,6 +2193,8 @@ bool supportUniversalReachChat = 26;
|
|
|
2177
2193
|
|
|
2178
2194
|
bool supportOmittedConversationMetadata = 28;
|
|
2179
2195
|
|
|
2196
|
+
|
|
2197
|
+
optional bool supportOmittedConversationIndex = 27;
|
|
2180
2198
|
}
|
|
2181
2199
|
|
|
2182
2200
|
enum PlatformType {
|
|
@@ -2499,6 +2517,10 @@ repeated .proto.StickerMetadata favoriteStickers = 22;
|
|
|
2499
2517
|
|
|
2500
2518
|
string omittedConversationMetadataSnapshotId = 26;
|
|
2501
2519
|
|
|
2520
|
+
|
|
2521
|
+
repeated .proto.RecoverableHistoryConversation omittedConversations = 23;
|
|
2522
|
+
|
|
2523
|
+
optional bool omittedConversationsProvided = 24;
|
|
2502
2524
|
}
|
|
2503
2525
|
|
|
2504
2526
|
message HistorySyncMsg {
|
|
@@ -2533,6 +2555,8 @@ message HydratedTemplateButton {
|
|
|
2533
2555
|
TALL = 2;
|
|
2534
2556
|
COMPACT = 3;
|
|
2535
2557
|
}
|
|
2558
|
+
|
|
2559
|
+
optional bool webviewInteraction = 5;
|
|
2536
2560
|
}
|
|
2537
2561
|
|
|
2538
2562
|
}
|
|
@@ -2809,6 +2833,8 @@ message Message {
|
|
|
2809
2833
|
optional uint32 expectedImageCount = 2;
|
|
2810
2834
|
optional uint32 expectedVideoCount = 3;
|
|
2811
2835
|
optional ContextInfo contextInfo = 17;
|
|
2836
|
+
|
|
2837
|
+
optional string caption = 1;
|
|
2812
2838
|
}
|
|
2813
2839
|
|
|
2814
2840
|
message AppStateFatalExceptionNotification {
|
|
@@ -4724,6 +4750,8 @@ message ChatCustomImageWallpaper {
|
|
|
4724
4750
|
}
|
|
4725
4751
|
|
|
4726
4752
|
message ChatDefaultWallpaper {
|
|
4753
|
+
|
|
4754
|
+
optional bool isDoodleEnabled = 1;
|
|
4727
4755
|
}
|
|
4728
4756
|
|
|
4729
4757
|
message ChatSolidColorWallpaper {
|
|
@@ -4790,6 +4818,8 @@ message MusicMessage {
|
|
|
4790
4818
|
int64 endTimeInMs = 2;
|
|
4791
4819
|
string text = 3;
|
|
4792
4820
|
}
|
|
4821
|
+
|
|
4822
|
+
repeated .proto.Message.MusicMessage.Lyrics.Line lines = 1;
|
|
4793
4823
|
}
|
|
4794
4824
|
|
|
4795
4825
|
enum MusicMessageStyle {
|
|
@@ -4858,6 +4888,8 @@ message RequestLocationUpdateMessage {
|
|
|
4858
4888
|
}
|
|
4859
4889
|
|
|
4860
4890
|
message RootSecretDistributeMessage {
|
|
4891
|
+
|
|
4892
|
+
optional string chatJid = 1;
|
|
4861
4893
|
}
|
|
4862
4894
|
|
|
4863
4895
|
message SharedDeviceContactHashKey {
|
|
@@ -4877,9 +4909,13 @@ message SharedDeviceContactHashKey {
|
|
|
4877
4909
|
}
|
|
4878
4910
|
|
|
4879
4911
|
message SharedDeviceContactHashKeyRequest {
|
|
4912
|
+
|
|
4913
|
+
optional uint32 knownEpoch = 1;
|
|
4880
4914
|
}
|
|
4881
4915
|
|
|
4882
4916
|
message SharedDeviceContactHashKeyShare {
|
|
4917
|
+
|
|
4918
|
+
repeated .proto.Message.SharedDeviceContactHashKey keys = 1;
|
|
4883
4919
|
}
|
|
4884
4920
|
|
|
4885
4921
|
message SplitPaymentMessage {
|
|
@@ -4925,8 +4961,12 @@ message StatusLinkPreviewMetadata {
|
|
|
4925
4961
|
FULL = 2;
|
|
4926
4962
|
IMMERSIVE = 3;
|
|
4927
4963
|
}
|
|
4964
|
+
|
|
4965
|
+
optional int32 style = 1;
|
|
4928
4966
|
}
|
|
4929
4967
|
|
|
4968
|
+
|
|
4969
|
+
optional .proto.Message.NewsletterFollowerInviteMessage newsletterFollowerInviteMessage = 108;
|
|
4930
4970
|
}
|
|
4931
4971
|
|
|
4932
4972
|
message MessageAddOn {
|
|
@@ -6775,9 +6815,13 @@ message ThreadPinAction {
|
|
|
6775
6815
|
}
|
|
6776
6816
|
|
|
6777
6817
|
message BBProPendingCustomerBaseAction {
|
|
6818
|
+
|
|
6819
|
+
optional bool pending = 1;
|
|
6778
6820
|
}
|
|
6779
6821
|
|
|
6780
6822
|
message BubbleLockMessageAction {
|
|
6823
|
+
|
|
6824
|
+
optional bool locked = 1;
|
|
6781
6825
|
}
|
|
6782
6826
|
|
|
6783
6827
|
enum BusinessBroadcastCampaignBBProStatus {
|
|
@@ -6797,9 +6841,13 @@ enum BusinessBroadcastCampaignBBProStatus {
|
|
|
6797
6841
|
}
|
|
6798
6842
|
|
|
6799
6843
|
message BusinessFolderActivationAction {
|
|
6844
|
+
|
|
6845
|
+
optional bool activated = 1;
|
|
6800
6846
|
}
|
|
6801
6847
|
|
|
6802
6848
|
message CoexV2VersionAction {
|
|
6849
|
+
|
|
6850
|
+
optional uint64 version = 1;
|
|
6803
6851
|
}
|
|
6804
6852
|
|
|
6805
6853
|
message CommunityNestingStateAction {
|
|
@@ -6812,12 +6860,18 @@ message CommunityNestingStateAction {
|
|
|
6812
6860
|
NESTING_STATE_NESTED = 1;
|
|
6813
6861
|
NESTING_STATE_UNNESTED = 2;
|
|
6814
6862
|
}
|
|
6863
|
+
|
|
6864
|
+
optional int32 nestingState = 1;
|
|
6815
6865
|
}
|
|
6816
6866
|
|
|
6817
6867
|
message ContactManagerMetadataAction {
|
|
6868
|
+
|
|
6869
|
+
optional bool isHidden = 1;
|
|
6818
6870
|
}
|
|
6819
6871
|
|
|
6820
6872
|
message CtwaMessageReceivedAction {
|
|
6873
|
+
|
|
6874
|
+
optional bool isCtwaMessageReceived = 1;
|
|
6821
6875
|
}
|
|
6822
6876
|
|
|
6823
6877
|
message GroupHistoryToggleAction {
|
|
@@ -6830,12 +6884,18 @@ message GroupHistoryToggleAction {
|
|
|
6830
6884
|
GROUP_HISTORY_TOGGLE_MODE_ON = 1;
|
|
6831
6885
|
GROUP_HISTORY_TOGGLE_MODE_OFF = 2;
|
|
6832
6886
|
}
|
|
6887
|
+
|
|
6888
|
+
optional int32 groupHistoryToggleMode = 1;
|
|
6833
6889
|
}
|
|
6834
6890
|
|
|
6835
6891
|
message LabelSublistAction {
|
|
6892
|
+
|
|
6893
|
+
optional int32 subListId = 1;
|
|
6836
6894
|
}
|
|
6837
6895
|
|
|
6838
6896
|
message SharedDeviceAllowlistAction {
|
|
6897
|
+
|
|
6898
|
+
optional bool allowed = 1;
|
|
6839
6899
|
}
|
|
6840
6900
|
|
|
6841
6901
|
message SharedDeviceSecretAction {
|
|
@@ -6861,6 +6921,8 @@ message WASARootSecretAction {
|
|
|
6861
6921
|
ACTIVE = 1;
|
|
6862
6922
|
}
|
|
6863
6923
|
}
|
|
6924
|
+
|
|
6925
|
+
repeated .proto.SyncActionValue.WASARootSecretAction.RootSecretEntry secrets = 1;
|
|
6864
6926
|
}
|
|
6865
6927
|
|
|
6866
6928
|
}
|
|
@@ -7649,6 +7711,8 @@ option allow_alias = true;
|
|
|
7649
7711
|
}
|
|
7650
7712
|
|
|
7651
7713
|
message AISubscriptionUpsellMetadata {
|
|
7714
|
+
|
|
7715
|
+
optional .proto.AISubscriptionRequestType requestType = 1;
|
|
7652
7716
|
}
|
|
7653
7717
|
|
|
7654
7718
|
message AccountLinkingOpaqueData {
|
|
@@ -7667,6 +7731,8 @@ message BizAIMetadataSync {
|
|
|
7667
7731
|
optional .proto.BizAIMetadataSync.ServerEvent.AgentOnboardingStarted agentOnboardingStarted = 2;
|
|
7668
7732
|
|
|
7669
7733
|
message AgentOnboardingStarted {
|
|
7734
|
+
|
|
7735
|
+
optional int64 composerBlockDurationSecs = 1;
|
|
7670
7736
|
}
|
|
7671
7737
|
|
|
7672
7738
|
enum ProtocolEvent {
|
|
@@ -7677,12 +7743,18 @@ message BizAIMetadataSync {
|
|
|
7677
7743
|
AGENT_CHAT_READY = 1;
|
|
7678
7744
|
}
|
|
7679
7745
|
}
|
|
7746
|
+
|
|
7747
|
+
optional .proto.BizAIMetadataSync.ServerEvent serverEvent = 1;
|
|
7680
7748
|
}
|
|
7681
7749
|
|
|
7682
7750
|
message BotHistoryShareMetadata {
|
|
7751
|
+
|
|
7752
|
+
repeated .proto.BotGroupParticipantMetadata participantsMetadata = 1;
|
|
7683
7753
|
}
|
|
7684
7754
|
|
|
7685
7755
|
message BotPttPromptMetadata {
|
|
7756
|
+
|
|
7757
|
+
optional string transcript = 1;
|
|
7686
7758
|
}
|
|
7687
7759
|
|
|
7688
7760
|
message BotResolvedToolCallMetadata {
|
|
@@ -7716,6 +7788,8 @@ message CoexStateSync {
|
|
|
7716
7788
|
optional uint64 dirtyVersion = 3 [packed =false];
|
|
7717
7789
|
optional int32 operation = 4 [packed =false];
|
|
7718
7790
|
}
|
|
7791
|
+
|
|
7792
|
+
repeated .proto.CoexStateSync.CollectionMutations collectionMutations = 1;
|
|
7719
7793
|
}
|
|
7720
7794
|
|
|
7721
7795
|
message CombinedFingerprint {
|
|
@@ -8084,6 +8158,8 @@ message EpochSignatures {
|
|
|
8084
8158
|
}
|
|
8085
8159
|
|
|
8086
8160
|
message EventInviteAdditionalMetadata {
|
|
8161
|
+
|
|
8162
|
+
optional bool isUpdated = 1;
|
|
8087
8163
|
}
|
|
8088
8164
|
|
|
8089
8165
|
message ExtendedContentMessage {
|
|
@@ -8667,6 +8743,8 @@ message NonE2EEAttestation {
|
|
|
8667
8743
|
HYBRID_E2EE = 1;
|
|
8668
8744
|
NON_E2EE = 2;
|
|
8669
8745
|
}
|
|
8746
|
+
|
|
8747
|
+
optional int32 accountType = 1;
|
|
8670
8748
|
}
|
|
8671
8749
|
|
|
8672
8750
|
message OmittedConversationMetadata {
|
|
@@ -9164,3 +9242,8 @@ message WASARootSecretAction {
|
|
|
9164
9242
|
repeated RootSecretEntry secrets = 1;
|
|
9165
9243
|
}
|
|
9166
9244
|
|
|
9245
|
+
message RecoverableHistoryConversation {
|
|
9246
|
+
|
|
9247
|
+
optional string historyChatId = 1;
|
|
9248
|
+
optional string accountLid = 2;
|
|
9249
|
+
}
|
|
@@ -34,6 +34,11 @@ export interface ReviewAndPayOptions {
|
|
|
34
34
|
paymentAccounts?: PaymentAccount[];
|
|
35
35
|
paymentSettings?: PaymentAccount[];
|
|
36
36
|
paymentParams?: Record<string, unknown> | string;
|
|
37
|
+
/** Pre-serialized Native Flow JSON; structurally validated before relay. */
|
|
38
|
+
buttonParamsJson?: Record<string, unknown> | string;
|
|
39
|
+
button_params_json?: Record<string, unknown> | string;
|
|
40
|
+
messageParamsJson?: string;
|
|
41
|
+
messageVersion?: number;
|
|
37
42
|
paymentConfiguration?: string;
|
|
38
43
|
paymentType?: string;
|
|
39
44
|
type?: string;
|
|
@@ -43,6 +48,6 @@ export interface ReviewAndPayOptions {
|
|
|
43
48
|
}
|
|
44
49
|
|
|
45
50
|
export function buildReviewAndPayMessage(options?: ReviewAndPayOptions): Promise<proto.IMessage>;
|
|
46
|
-
export function sendReviewAndPay(conn: { relayMessage(jid: string, content: proto.IMessage, options?: Record<string, unknown>): Promise<unknown> }, jid: string, options?: ReviewAndPayOptions, relayOptions?: Record<string, unknown>): Promise<unknown>;
|
|
51
|
+
export function sendReviewAndPay(conn: { user?: { id?: string; lid?: string }; authState?: { creds?: { me?: { id?: string; lid?: string } } }; relayMessage(jid: string, content: proto.IMessage, options?: Record<string, unknown>): Promise<unknown> }, jid: string, options?: ReviewAndPayOptions, relayOptions?: Record<string, unknown>): Promise<unknown>;
|
|
47
52
|
declare const _default: { buildReviewAndPayMessage: typeof buildReviewAndPayMessage; sendReviewAndPay: typeof sendReviewAndPay };
|
|
48
53
|
export default _default;
|
|
@@ -4,6 +4,9 @@
|
|
|
4
4
|
* this function does not collect, validate or process actual payments.
|
|
5
5
|
*/
|
|
6
6
|
import { normalizeThumbnail } from './media-thumb.js';
|
|
7
|
+
import { generateWAMessageFromContent } from '../lib/Utils/messages.js';
|
|
8
|
+
import { getBizBinaryNode } from '../lib/WABinary/index.js';
|
|
9
|
+
import { prepareNativeFlowMessageForRelay } from '../lib/Utils/native-flow.js';
|
|
7
10
|
|
|
8
11
|
const isObject = value => value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
9
12
|
const positiveInteger = (value, name) => {
|
|
@@ -32,6 +35,9 @@ function normalizePaymentAccounts(accounts) {
|
|
|
32
35
|
if (typeof identifier !== 'string' || !identifier.trim()) {
|
|
33
36
|
throw new TypeError(`paymentAccounts[${index}] needs a nonempty identifier_value`);
|
|
34
37
|
}
|
|
38
|
+
if (/^\[[^\]]+\]$/.test(identifier.trim())) {
|
|
39
|
+
throw new TypeError(`paymentAccounts[${index}].identifier_value is still a placeholder; replace it with a real value or omit that account`);
|
|
40
|
+
}
|
|
35
41
|
const result = { ...entry, type: entry.type || 'payment_account', payment_account: { ...paymentAccount } };
|
|
36
42
|
delete result.paymentAccount;
|
|
37
43
|
if (result.payment_account.identifierValue !== undefined && result.payment_account.identifier_value === undefined) {
|
|
@@ -72,7 +78,7 @@ function normalizePaymentParams(options) {
|
|
|
72
78
|
const totalAmount = options.totalAmount ?? supplied?.total_amount ?? supplied?.totalAmount;
|
|
73
79
|
const orderItems = options.items ?? supplied?.order?.items ?? [{
|
|
74
80
|
name: options.itemName ?? 'Producto',
|
|
75
|
-
amount: amountObject(options.itemValue ??
|
|
81
|
+
amount: amountObject(options.itemValue ?? options.totalValue ?? 137, options.offset ?? 100, 'item.amount'),
|
|
76
82
|
quantity: positiveInteger(options.quantity ?? 1, 'quantity')
|
|
77
83
|
}];
|
|
78
84
|
if (!Array.isArray(orderItems) || orderItems.length === 0) throw new TypeError('order.items must contain at least one item');
|
|
@@ -81,7 +87,7 @@ function normalizePaymentParams(options) {
|
|
|
81
87
|
if (!isObject(item)) throw new TypeError(`order.items[${index}] must be an object`);
|
|
82
88
|
const name = item.name ?? item.title;
|
|
83
89
|
if (typeof name !== 'string' || !name.trim()) throw new TypeError(`order.items[${index}].name is required`);
|
|
84
|
-
const itemAmount = item.amount ?? { value: options.itemValue ??
|
|
90
|
+
const itemAmount = item.amount ?? { value: options.itemValue ?? options.totalValue ?? 137, offset: options.offset ?? 100 };
|
|
85
91
|
return {
|
|
86
92
|
...item,
|
|
87
93
|
name: name.trim(),
|
|
@@ -91,21 +97,41 @@ function normalizePaymentParams(options) {
|
|
|
91
97
|
});
|
|
92
98
|
|
|
93
99
|
const accounts = options.paymentAccounts ?? options.paymentSettings ?? options.payment_settings ?? supplied?.payment_settings ?? [];
|
|
100
|
+
const offset = normalizedItems[0].amount.offset;
|
|
101
|
+
if (normalizedItems.some(item => item.amount.offset !== offset)) {
|
|
102
|
+
throw new TypeError('All order item amounts must use the same offset');
|
|
103
|
+
}
|
|
104
|
+
const itemTotal = normalizedItems.reduce((sum, item) => {
|
|
105
|
+
return sum + BigInt(item.amount.value) * BigInt(item.quantity);
|
|
106
|
+
}, 0n);
|
|
107
|
+
if (itemTotal > BigInt(Number.MAX_SAFE_INTEGER)) throw new RangeError('Order item total exceeds the safe integer range');
|
|
108
|
+
const normalizedTotal = amountObject(
|
|
109
|
+
totalAmount ?? options.totalValue ?? { value: Number(itemTotal), offset },
|
|
110
|
+
offset,
|
|
111
|
+
'total_amount'
|
|
112
|
+
);
|
|
113
|
+
if (normalizedTotal.offset !== offset || BigInt(normalizedTotal.value) !== itemTotal) {
|
|
114
|
+
throw new TypeError('total_amount must equal the sum of order.items (value × quantity) and use the same offset');
|
|
115
|
+
}
|
|
94
116
|
const params = {
|
|
95
117
|
currency,
|
|
96
118
|
payment_configuration: options.paymentConfiguration ?? supplied?.payment_configuration ?? '',
|
|
97
|
-
|
|
98
|
-
|
|
119
|
+
...(options.paymentType ?? supplied?.payment_type
|
|
120
|
+
? { payment_type: options.paymentType ?? supplied.payment_type }
|
|
121
|
+
: {}),
|
|
122
|
+
total_amount: normalizedTotal,
|
|
99
123
|
reference_id: String(options.referenceId ?? options.reference_id ?? supplied?.reference_id ?? `KAGE_${Date.now()}`),
|
|
100
124
|
type: options.type ?? supplied?.type ?? 'physical-goods',
|
|
101
125
|
order: {
|
|
102
126
|
...(isObject(supplied?.order) ? supplied.order : {}),
|
|
103
127
|
status: options.orderStatus ?? supplied?.order?.status ?? 'pending',
|
|
104
128
|
description: options.orderDescription ?? supplied?.order?.description ?? 'Descripción',
|
|
129
|
+
subtotal: { value: Number(itemTotal), offset },
|
|
105
130
|
order_type: options.orderType ?? supplied?.order?.order_type ?? 'PAYMENT_REQUEST',
|
|
106
131
|
items: normalizedItems
|
|
107
132
|
},
|
|
108
133
|
payment_settings: normalizePaymentAccounts(accounts),
|
|
134
|
+
native_payment_methods: options.nativePaymentMethods ?? supplied?.native_payment_methods ?? [],
|
|
109
135
|
additional_note: options.additionalNote ?? options.additional_note ?? supplied?.additional_note ?? '',
|
|
110
136
|
share_payment_status: options.sharePaymentStatus ?? supplied?.share_payment_status ?? false,
|
|
111
137
|
is_soft_deleted: options.isSoftDeleted ?? supplied?.is_soft_deleted ?? false
|
|
@@ -120,6 +146,32 @@ function normalizePaymentParams(options) {
|
|
|
120
146
|
return params;
|
|
121
147
|
}
|
|
122
148
|
|
|
149
|
+
function getRawButtonParamsJson(options) {
|
|
150
|
+
const candidate = options.buttonParamsJson
|
|
151
|
+
?? options.button_params_json
|
|
152
|
+
?? options.nativeFlowButton?.buttonParamsJson
|
|
153
|
+
?? options.nativeFlowMessage?.buttons?.find(button => button?.name === 'review_and_pay')?.buttonParamsJson;
|
|
154
|
+
if (candidate == null) return null;
|
|
155
|
+
|
|
156
|
+
let serialized;
|
|
157
|
+
if (typeof candidate === 'string') {
|
|
158
|
+
serialized = candidate;
|
|
159
|
+
} else if (isObject(candidate)) {
|
|
160
|
+
serialized = JSON.stringify(candidate);
|
|
161
|
+
} else {
|
|
162
|
+
throw new TypeError('buttonParamsJson must be a JSON object or JSON string');
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
let parsed;
|
|
166
|
+
try { parsed = JSON.parse(serialized); }
|
|
167
|
+
catch (error) { throw new TypeError(`buttonParamsJson is not valid JSON: ${error.message}`); }
|
|
168
|
+
if (!isObject(parsed)) throw new TypeError('buttonParamsJson must contain a JSON object');
|
|
169
|
+
if (Buffer.byteLength(serialized, 'utf8') > 64_000) {
|
|
170
|
+
throw new RangeError('review_and_pay button parameters exceed 64 KB');
|
|
171
|
+
}
|
|
172
|
+
return serialized;
|
|
173
|
+
}
|
|
174
|
+
|
|
123
175
|
/** Build a relayMessage-compatible interactiveMessage with a review_and_pay button. */
|
|
124
176
|
export async function buildReviewAndPayMessage(options = {}) {
|
|
125
177
|
if (!isObject(options)) throw new TypeError('buildReviewAndPayMessage options must be an object');
|
|
@@ -131,8 +183,7 @@ export async function buildReviewAndPayMessage(options = {}) {
|
|
|
131
183
|
fetchTimeout: options.fetchTimeout ?? 20_000,
|
|
132
184
|
strict: true
|
|
133
185
|
});
|
|
134
|
-
const
|
|
135
|
-
const buttonParamsJson = JSON.stringify(paymentParams);
|
|
186
|
+
const buttonParamsJson = getRawButtonParamsJson(options) ?? JSON.stringify(normalizePaymentParams(options));
|
|
136
187
|
if (Buffer.byteLength(buttonParamsJson, 'utf8') > 64_000) throw new RangeError('review_and_pay button parameters exceed 64 KB');
|
|
137
188
|
|
|
138
189
|
const title = options.title ?? headerOptions.title ?? '';
|
|
@@ -153,19 +204,21 @@ export async function buildReviewAndPayMessage(options = {}) {
|
|
|
153
204
|
};
|
|
154
205
|
if (!thumbnail) delete header.jpegThumbnail;
|
|
155
206
|
|
|
156
|
-
|
|
207
|
+
const payload = {
|
|
157
208
|
interactiveMessage: {
|
|
158
209
|
header,
|
|
159
210
|
body: { text: body },
|
|
160
211
|
footer: { text: footer },
|
|
161
212
|
nativeFlowMessage: {
|
|
162
213
|
buttons: [{ name: 'review_and_pay', buttonParamsJson }],
|
|
163
|
-
messageParamsJson: '{}',
|
|
164
|
-
messageVersion: 1
|
|
214
|
+
messageParamsJson: typeof options.messageParamsJson === 'string' ? options.messageParamsJson : '{}',
|
|
215
|
+
messageVersion: Number.isInteger(options.messageVersion) && options.messageVersion > 0 ? options.messageVersion : 1
|
|
165
216
|
},
|
|
166
217
|
contextInfo: options.contextInfo ? { ...options.contextInfo } : {}
|
|
167
218
|
}
|
|
168
219
|
};
|
|
220
|
+
prepareNativeFlowMessageForRelay(payload);
|
|
221
|
+
return payload;
|
|
169
222
|
}
|
|
170
223
|
|
|
171
224
|
/** Build and relay the Native Flow payment request through an authenticated Baileys socket. */
|
|
@@ -173,7 +226,24 @@ export async function sendReviewAndPay(conn, jid, options = {}, relayOptions = {
|
|
|
173
226
|
if (!conn || typeof conn.relayMessage !== 'function') throw new TypeError('A connected Baileys socket with relayMessage is required');
|
|
174
227
|
if (typeof jid !== 'string' || !jid.trim()) throw new TypeError('A destination JID is required');
|
|
175
228
|
const payload = await buildReviewAndPayMessage(options);
|
|
176
|
-
|
|
229
|
+
const userJid = conn.user?.id || conn.authState?.creds?.me?.id;
|
|
230
|
+
const userJidLid = conn.user?.lid || conn.authState?.creds?.me?.lid;
|
|
231
|
+
if (!userJid) throw new Error('Socket is not authenticated: user JID is unavailable');
|
|
232
|
+
|
|
233
|
+
// Build a real WebMessageInfo first, then relay it with the business node
|
|
234
|
+
// required for Native Flow rendering. This also supplies a stable message ID.
|
|
235
|
+
const waMessage = generateWAMessageFromContent(jid, payload, { userJid, userJidLid });
|
|
236
|
+
const additionalNodes = Array.isArray(relayOptions?.additionalNodes)
|
|
237
|
+
? [...relayOptions.additionalNodes]
|
|
238
|
+
: [];
|
|
239
|
+
const hasBizNode = additionalNodes.some(node => node?.tag === 'biz');
|
|
240
|
+
if (!hasBizNode) additionalNodes.push(getBizBinaryNode(waMessage.message));
|
|
241
|
+
|
|
242
|
+
return conn.relayMessage(jid, waMessage.message, {
|
|
243
|
+
...(relayOptions || {}),
|
|
244
|
+
messageId: relayOptions?.messageId || waMessage.key.id,
|
|
245
|
+
additionalNodes
|
|
246
|
+
});
|
|
177
247
|
}
|
|
178
248
|
|
|
179
249
|
export default { buildReviewAndPayMessage, sendReviewAndPay };
|
package/lib/Defaults/index.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ export declare const WA_CERT_DETAILS: {
|
|
|
28
28
|
PUBLIC_KEY: Buffer<ArrayBuffer>;
|
|
29
29
|
};
|
|
30
30
|
export declare const PROCESSABLE_HISTORY_TYPES: proto.HistorySync.HistorySyncType[];
|
|
31
|
+
export declare const DEFAULT_CACHE_MAX_KEYS: number;
|
|
31
32
|
export declare const DEFAULT_CACHE_TTLS: {
|
|
32
33
|
SIGNAL_STORE: number;
|
|
33
34
|
MSG_RETRY: number;
|
package/lib/Defaults/index.js
CHANGED
|
@@ -45,6 +45,8 @@ export const DEFAULT_CACHE_TTLS = {
|
|
|
45
45
|
CALL_OFFER: 5 * 60, // 5 minutes
|
|
46
46
|
USER_DEVICES: 5 * 60 // 5 minutes
|
|
47
47
|
};
|
|
48
|
+
/** Maximum number of entries retained by in-memory helper caches. */
|
|
49
|
+
export const DEFAULT_CACHE_MAX_KEYS = 20000;
|
|
48
50
|
export const DEFAULT_CONNECTION_CONFIG = {
|
|
49
51
|
version: version,
|
|
50
52
|
browser: Browsers.androidPhone('Chrome'),
|
|
@@ -89,9 +89,9 @@ function installKageUtilities(socket, config = {}) {
|
|
|
89
89
|
});
|
|
90
90
|
define(socket, 'sendReviewAndPay', async (jid, options = {}, relayOptions = {}) => {
|
|
91
91
|
const payment = await import('../../helpers/interactive-pay.js');
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
return
|
|
92
|
+
// review_and_pay is sent as raw interactiveMessage content, just like
|
|
93
|
+
// socket.relayMessage(jid, { interactiveMessage: ... }, relayOptions).
|
|
94
|
+
return payment.sendReviewAndPay(socket, jid, options || {}, relayOptions || {});
|
|
95
95
|
});
|
|
96
96
|
} catch (error) {
|
|
97
97
|
warn(config, 'ReviewAndPay', error);
|
package/lib/Socket/business.d.ts
CHANGED
|
@@ -201,6 +201,8 @@ export declare const makeBusinessSocket: (config: SocketConfig) => {
|
|
|
201
201
|
digestKeyBundle: () => Promise<void>;
|
|
202
202
|
rotateSignedPreKey: () => Promise<void>;
|
|
203
203
|
requestPairingCode: (phoneNumber: string, customPairingCode?: string) => Promise<string>;
|
|
204
|
+
/** Cancel the active pairing-code request and restore the previous temporary auth fields. */
|
|
205
|
+
cancelPairingCode: () => boolean;
|
|
204
206
|
updateServerTimeOffset: ({ attrs }: BinaryNode) => void;
|
|
205
207
|
sendUnifiedSession: () => Promise<void>;
|
|
206
208
|
wamBuffer: import("../index.js").BinaryInfo;
|