kage-baileys 25.3.40 → 25.4.2
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 +42 -0
- package/WAProto/WAProto.proto +83 -15
- package/helpers/interactive-pay.d.ts +5 -0
- package/helpers/interactive-pay.js +29 -4
- package/lib/Defaults/index.d.ts +1 -0
- package/lib/Defaults/index.js +2 -0
- package/lib/Extensions/bootstrap.cjs +3 -3
- package/lib/Types/Kage.d.ts +1 -1
- 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 +21 -0
- package/lib/Utils/index.js +22 -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/newsletter-status.d.ts +158 -0
- package/lib/Utils/newsletter-status.js +651 -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 -3
- package/scripts/verify-package.mjs +13 -1
- package/scripts/verify-proto.mjs +344 -0
- package/test/cross-fork-helpers.test.js +54 -0
- package/test/native-flow-payment.test.js +22 -2
- package/test/proto-runtime.test.js +35 -0
- package/test/proto-schema.test.js +28 -0
package/README.md
CHANGED
|
@@ -2295,3 +2295,45 @@ This Kage build incorporates selected fixes reviewed from RedX Baileys 7.0.0-rc1
|
|
|
2295
2295
|
- `newsletterJidFromInvite(codeOrUrl)` resolves the channel JID from metadata.
|
|
2296
2296
|
- WMex response parsing accepts JSON bodies with a binary prefix and safely handles partial newsletter metadata responses.
|
|
2297
2297
|
- Compact binary newsletter metadata is accepted only when exactly one channel JID can be identified; ambiguous payloads are rejected instead of guessed.
|
|
2298
|
+
|
|
2299
|
+
## Kage cross-fork integration (25.4.1)
|
|
2300
|
+
|
|
2301
|
+
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.
|
|
2302
|
+
|
|
2303
|
+
### Native Flow `review_and_pay`
|
|
2304
|
+
|
|
2305
|
+
`buildReviewAndPayMessage()` builds the protobuf-compatible `interactiveMessage` payload and `sendReviewAndPay()` relays it directly through the authenticated socket. `buttonParamsJson` accepts either a JSON string or an object; strings are validated and preserved exactly. Example:
|
|
2306
|
+
|
|
2307
|
+
```js
|
|
2308
|
+
await conn.sendReviewAndPay(chatJid, {
|
|
2309
|
+
header: { title: '', subtitle: '', jpegThumbnail: thumbnailBuffer },
|
|
2310
|
+
body: 'Detalle del pedido',
|
|
2311
|
+
footer: 'Revisa antes de continuar',
|
|
2312
|
+
buttonParamsJson: JSON.stringify({
|
|
2313
|
+
currency: 'PEN',
|
|
2314
|
+
payment_configuration: '',
|
|
2315
|
+
payment_type: 'upr',
|
|
2316
|
+
total_amount: { value: 1000, offset: 100 },
|
|
2317
|
+
reference_id: 'ORDER_001',
|
|
2318
|
+
type: 'physical-goods',
|
|
2319
|
+
order: {
|
|
2320
|
+
status: 'pending',
|
|
2321
|
+
description: 'Pedido de prueba',
|
|
2322
|
+
order_type: 'PAYMENT_REQUEST',
|
|
2323
|
+
items: [{ name: 'Producto', amount: { value: 1000, offset: 100 }, quantity: 1 }]
|
|
2324
|
+
},
|
|
2325
|
+
payment_settings: []
|
|
2326
|
+
})
|
|
2327
|
+
}, {});
|
|
2328
|
+
```
|
|
2329
|
+
|
|
2330
|
+
This sends a WhatsApp Native Flow payment-request UI payload only. It does not charge, settle or verify a payment, and rendering depends on WhatsApp client/account support and valid payment-provider data. The generic helper deliberately does not embed personal payment accounts.
|
|
2331
|
+
|
|
2332
|
+
### Media status and view-once messages
|
|
2333
|
+
|
|
2334
|
+
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.
|
|
2335
|
+
|
|
2336
|
+
### Added utility exports
|
|
2337
|
+
|
|
2338
|
+
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.
|
|
2339
|
+
|
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
|
}
|
|
@@ -7150,7 +7212,6 @@ message WebMessageInfo {
|
|
|
7150
7212
|
optional GroupHistoryBundleInfo groupHistoryBundleInfo = 75;
|
|
7151
7213
|
optional InteractiveMessageAdditionalMetadata interactiveMessageAdditionalMetadata = 76;
|
|
7152
7214
|
optional QuarantinedMessage quarantinedMessage = 77;
|
|
7153
|
-
// Additional WebMessageInfo metadata merged from the Elaina/Dnuzi schema lineage.
|
|
7154
7215
|
optional uint32 nonJidMentions = 78;
|
|
7155
7216
|
optional string hsmTag = 79;
|
|
7156
7217
|
optional uint64 ephemeralExpirationTimestamp = 80;
|
|
@@ -7490,20 +7551,6 @@ POLL_ADDED_OPTION_REMOVED = 291;
|
|
|
7490
7551
|
}
|
|
7491
7552
|
|
|
7492
7553
|
|
|
7493
|
-
optional uint32 nonJidMentions = 78;
|
|
7494
|
-
|
|
7495
|
-
optional string hsmTag = 79;
|
|
7496
|
-
|
|
7497
|
-
optional uint64 ephemeralExpirationTimestamp = 80;
|
|
7498
|
-
|
|
7499
|
-
optional ScheduledMessageMetadata scheduledMessageMetadata = 81;
|
|
7500
|
-
|
|
7501
|
-
string decisionId = 82;
|
|
7502
|
-
|
|
7503
|
-
repeated string decisionSources = 83;
|
|
7504
|
-
|
|
7505
|
-
.proto.EventInviteAdditionalMetadata eventInviteAdditionalMetadata = 84;
|
|
7506
|
-
|
|
7507
7554
|
}
|
|
7508
7555
|
|
|
7509
7556
|
message WebNotificationsInfo {
|
|
@@ -7664,6 +7711,8 @@ option allow_alias = true;
|
|
|
7664
7711
|
}
|
|
7665
7712
|
|
|
7666
7713
|
message AISubscriptionUpsellMetadata {
|
|
7714
|
+
|
|
7715
|
+
optional .proto.AISubscriptionRequestType requestType = 1;
|
|
7667
7716
|
}
|
|
7668
7717
|
|
|
7669
7718
|
message AccountLinkingOpaqueData {
|
|
@@ -7682,6 +7731,8 @@ message BizAIMetadataSync {
|
|
|
7682
7731
|
optional .proto.BizAIMetadataSync.ServerEvent.AgentOnboardingStarted agentOnboardingStarted = 2;
|
|
7683
7732
|
|
|
7684
7733
|
message AgentOnboardingStarted {
|
|
7734
|
+
|
|
7735
|
+
optional int64 composerBlockDurationSecs = 1;
|
|
7685
7736
|
}
|
|
7686
7737
|
|
|
7687
7738
|
enum ProtocolEvent {
|
|
@@ -7692,12 +7743,18 @@ message BizAIMetadataSync {
|
|
|
7692
7743
|
AGENT_CHAT_READY = 1;
|
|
7693
7744
|
}
|
|
7694
7745
|
}
|
|
7746
|
+
|
|
7747
|
+
optional .proto.BizAIMetadataSync.ServerEvent serverEvent = 1;
|
|
7695
7748
|
}
|
|
7696
7749
|
|
|
7697
7750
|
message BotHistoryShareMetadata {
|
|
7751
|
+
|
|
7752
|
+
repeated .proto.BotGroupParticipantMetadata participantsMetadata = 1;
|
|
7698
7753
|
}
|
|
7699
7754
|
|
|
7700
7755
|
message BotPttPromptMetadata {
|
|
7756
|
+
|
|
7757
|
+
optional string transcript = 1;
|
|
7701
7758
|
}
|
|
7702
7759
|
|
|
7703
7760
|
message BotResolvedToolCallMetadata {
|
|
@@ -7731,6 +7788,8 @@ message CoexStateSync {
|
|
|
7731
7788
|
optional uint64 dirtyVersion = 3 [packed =false];
|
|
7732
7789
|
optional int32 operation = 4 [packed =false];
|
|
7733
7790
|
}
|
|
7791
|
+
|
|
7792
|
+
repeated .proto.CoexStateSync.CollectionMutations collectionMutations = 1;
|
|
7734
7793
|
}
|
|
7735
7794
|
|
|
7736
7795
|
message CombinedFingerprint {
|
|
@@ -8099,6 +8158,8 @@ message EpochSignatures {
|
|
|
8099
8158
|
}
|
|
8100
8159
|
|
|
8101
8160
|
message EventInviteAdditionalMetadata {
|
|
8161
|
+
|
|
8162
|
+
optional bool isUpdated = 1;
|
|
8102
8163
|
}
|
|
8103
8164
|
|
|
8104
8165
|
message ExtendedContentMessage {
|
|
@@ -8682,6 +8743,8 @@ message NonE2EEAttestation {
|
|
|
8682
8743
|
HYBRID_E2EE = 1;
|
|
8683
8744
|
NON_E2EE = 2;
|
|
8684
8745
|
}
|
|
8746
|
+
|
|
8747
|
+
optional int32 accountType = 1;
|
|
8685
8748
|
}
|
|
8686
8749
|
|
|
8687
8750
|
message OmittedConversationMetadata {
|
|
@@ -9179,3 +9242,8 @@ message WASARootSecretAction {
|
|
|
9179
9242
|
repeated RootSecretEntry secrets = 1;
|
|
9180
9243
|
}
|
|
9181
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 button JSON; forwarded unchanged after JSON validation. */
|
|
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;
|
|
@@ -120,6 +120,32 @@ function normalizePaymentParams(options) {
|
|
|
120
120
|
return params;
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
+
function getRawButtonParamsJson(options) {
|
|
124
|
+
const candidate = options.buttonParamsJson
|
|
125
|
+
?? options.button_params_json
|
|
126
|
+
?? options.nativeFlowButton?.buttonParamsJson
|
|
127
|
+
?? options.nativeFlowMessage?.buttons?.find(button => button?.name === 'review_and_pay')?.buttonParamsJson;
|
|
128
|
+
if (candidate == null) return null;
|
|
129
|
+
|
|
130
|
+
let serialized;
|
|
131
|
+
if (typeof candidate === 'string') {
|
|
132
|
+
serialized = candidate;
|
|
133
|
+
} else if (isObject(candidate)) {
|
|
134
|
+
serialized = JSON.stringify(candidate);
|
|
135
|
+
} else {
|
|
136
|
+
throw new TypeError('buttonParamsJson must be a JSON object or JSON string');
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
let parsed;
|
|
140
|
+
try { parsed = JSON.parse(serialized); }
|
|
141
|
+
catch (error) { throw new TypeError(`buttonParamsJson is not valid JSON: ${error.message}`); }
|
|
142
|
+
if (!isObject(parsed)) throw new TypeError('buttonParamsJson must contain a JSON object');
|
|
143
|
+
if (Buffer.byteLength(serialized, 'utf8') > 64_000) {
|
|
144
|
+
throw new RangeError('review_and_pay button parameters exceed 64 KB');
|
|
145
|
+
}
|
|
146
|
+
return serialized;
|
|
147
|
+
}
|
|
148
|
+
|
|
123
149
|
/** Build a relayMessage-compatible interactiveMessage with a review_and_pay button. */
|
|
124
150
|
export async function buildReviewAndPayMessage(options = {}) {
|
|
125
151
|
if (!isObject(options)) throw new TypeError('buildReviewAndPayMessage options must be an object');
|
|
@@ -131,8 +157,7 @@ export async function buildReviewAndPayMessage(options = {}) {
|
|
|
131
157
|
fetchTimeout: options.fetchTimeout ?? 20_000,
|
|
132
158
|
strict: true
|
|
133
159
|
});
|
|
134
|
-
const
|
|
135
|
-
const buttonParamsJson = JSON.stringify(paymentParams);
|
|
160
|
+
const buttonParamsJson = getRawButtonParamsJson(options) ?? JSON.stringify(normalizePaymentParams(options));
|
|
136
161
|
if (Buffer.byteLength(buttonParamsJson, 'utf8') > 64_000) throw new RangeError('review_and_pay button parameters exceed 64 KB');
|
|
137
162
|
|
|
138
163
|
const title = options.title ?? headerOptions.title ?? '';
|
|
@@ -160,8 +185,8 @@ export async function buildReviewAndPayMessage(options = {}) {
|
|
|
160
185
|
footer: { text: footer },
|
|
161
186
|
nativeFlowMessage: {
|
|
162
187
|
buttons: [{ name: 'review_and_pay', buttonParamsJson }],
|
|
163
|
-
messageParamsJson: '{}',
|
|
164
|
-
messageVersion: 1
|
|
188
|
+
messageParamsJson: typeof options.messageParamsJson === 'string' ? options.messageParamsJson : '{}',
|
|
189
|
+
messageVersion: Number.isInteger(options.messageVersion) && options.messageVersion > 0 ? options.messageVersion : 1
|
|
165
190
|
},
|
|
166
191
|
contextInfo: options.contextInfo ? { ...options.contextInfo } : {}
|
|
167
192
|
}
|
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/Types/Kage.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import type { KageMessageContent } from './Message.js';
|
|
|
6
6
|
|
|
7
7
|
export type KageSocketExtensions = {
|
|
8
8
|
buildReviewAndPayMessage: (options?: import('../../helpers/interactive-pay.js').ReviewAndPayOptions) => Promise<proto.IMessage>;
|
|
9
|
-
sendReviewAndPay: (jid: string, options?: import('../../helpers/interactive-pay.js').ReviewAndPayOptions, relayOptions?: Record<string, unknown>) => Promise<
|
|
9
|
+
sendReviewAndPay: (jid: string, options?: import('../../helpers/interactive-pay.js').ReviewAndPayOptions, relayOptions?: Record<string, unknown>) => Promise<unknown>;
|
|
10
10
|
sendPhoto: (jid: string, image: WAMediaUpload, options?: Record<string, unknown>) => Promise<WAMessage | undefined>;
|
|
11
11
|
getProfilePhoto: (jid: string, type?: 'preview' | 'image', timeoutMs?: number) => Promise<string | undefined>;
|
|
12
12
|
setProfilePhoto: (jid: string, image: WAMediaUpload, dimensions?: { width?: number; height?: number }) => Promise<void>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/* Elaina Baileys maintained distribution. Upstream notices and license are preserved in LICENSE and NOTICE.md. */
|
|
2
|
+
export const CREDS_KEY: string;
|
|
3
|
+
export function encodeAuthValue(value: any): string;
|
|
4
|
+
export function decodeAuthValue(type: string, raw: any): any;
|
|
5
|
+
export function loadOptionalModule(name: string, usedBy: string): Promise<any>;
|
|
6
|
+
export interface AuthStoreEntry {
|
|
7
|
+
type: string;
|
|
8
|
+
id: string;
|
|
9
|
+
value: string;
|
|
10
|
+
}
|
|
11
|
+
export interface AuthStore {
|
|
12
|
+
read: (type: string, id: string) => Promise<any>;
|
|
13
|
+
readMany: (type: string, ids: string[]) => Promise<Record<string, any>>;
|
|
14
|
+
write: (type: string, id: string, value: string) => Promise<void>;
|
|
15
|
+
apply: (writes: AuthStoreEntry[], removals: Omit<AuthStoreEntry, 'value'>[]) => Promise<void>;
|
|
16
|
+
clear: () => Promise<void>;
|
|
17
|
+
close?: () => Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
export function makeAuthStateFromStore(store: AuthStore): Promise<{
|
|
20
|
+
state: {
|
|
21
|
+
creds: any;
|
|
22
|
+
keys: {
|
|
23
|
+
get: (type: any, ids: any) => Promise<{}>;
|
|
24
|
+
set: (data: any) => Promise<void>;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
saveCreds: () => Promise<void>;
|
|
28
|
+
clearAuth: () => Promise<void>;
|
|
29
|
+
close: () => Promise<void>;
|
|
30
|
+
}>;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/* Elaina Baileys maintained distribution. Upstream notices and license are preserved in LICENSE and NOTICE.md. */
|
|
2
|
+
import { proto } from '../../WAProto/index.js';
|
|
3
|
+
import { initAuthCreds } from './auth-utils.js';
|
|
4
|
+
import { BufferJSON } from './generics.js';
|
|
5
|
+
export const CREDS_KEY = 'creds';
|
|
6
|
+
export const encodeAuthValue = (value) => JSON.stringify(value, BufferJSON.replacer);
|
|
7
|
+
export const decodeAuthValue = (type, raw) => {
|
|
8
|
+
if (raw === null || raw === undefined) {
|
|
9
|
+
return null;
|
|
10
|
+
}
|
|
11
|
+
const value = typeof raw === 'string' ? JSON.parse(raw, BufferJSON.reviver) : raw;
|
|
12
|
+
if (type === 'app-state-sync-key' && value) {
|
|
13
|
+
return proto.Message.AppStateSyncKeyData.fromObject(value);
|
|
14
|
+
}
|
|
15
|
+
return value;
|
|
16
|
+
};
|
|
17
|
+
export const loadOptionalModule = async (name, usedBy) => {
|
|
18
|
+
try {
|
|
19
|
+
const mod = await import(name);
|
|
20
|
+
return mod.default ?? mod;
|
|
21
|
+
}
|
|
22
|
+
catch (err) {
|
|
23
|
+
const helpful = new Error(`\`${name}\` is required for \`${usedBy}\`. Install it as a peer dependency: \`npm install ${name}\`.`);
|
|
24
|
+
helpful.cause = err;
|
|
25
|
+
throw helpful;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
export const makeAuthStateFromStore = async (store) => {
|
|
29
|
+
const stored = await store.read(CREDS_KEY, CREDS_KEY);
|
|
30
|
+
const creds = decodeAuthValue(CREDS_KEY, stored) ?? initAuthCreds();
|
|
31
|
+
const state = {
|
|
32
|
+
creds,
|
|
33
|
+
keys: {
|
|
34
|
+
get: async (type, ids) => {
|
|
35
|
+
const data = {};
|
|
36
|
+
const rows = await store.readMany(type, ids);
|
|
37
|
+
for (const id of ids) {
|
|
38
|
+
const value = decodeAuthValue(type, rows[id]);
|
|
39
|
+
if (value) {
|
|
40
|
+
data[id] = value;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return data;
|
|
44
|
+
},
|
|
45
|
+
set: async (data) => {
|
|
46
|
+
const writes = [];
|
|
47
|
+
const removals = [];
|
|
48
|
+
for (const type in data) {
|
|
49
|
+
for (const id in data[type]) {
|
|
50
|
+
const value = data[type][id];
|
|
51
|
+
if (value) {
|
|
52
|
+
writes.push({ type, id, value: encodeAuthValue(value) });
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
removals.push({ type, id });
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (writes.length || removals.length) {
|
|
60
|
+
await store.apply(writes, removals);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
return {
|
|
66
|
+
state,
|
|
67
|
+
saveCreds: async () => {
|
|
68
|
+
await store.write(CREDS_KEY, CREDS_KEY, encodeAuthValue(creds));
|
|
69
|
+
},
|
|
70
|
+
clearAuth: async () => {
|
|
71
|
+
await store.clear();
|
|
72
|
+
},
|
|
73
|
+
close: async () => {
|
|
74
|
+
await store.close?.();
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/* Elaina Baileys maintained distribution. Upstream notices and license are preserved in LICENSE and NOTICE.md. */
|
|
2
|
+
|
|
3
|
+
export declare const GROUP_ADDRESSING_MODES: readonly string[]
|
|
4
|
+
export declare function isUsableGroupMetadata(metadata: any): boolean
|
|
5
|
+
export declare function describeUnusableGroupMetadata(metadata: any): string
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/* Elaina Baileys maintained distribution. Upstream notices and license are preserved in LICENSE and NOTICE.md. */
|
|
2
|
+
|
|
3
|
+
export const GROUP_ADDRESSING_MODES = Object.freeze(['pn', 'lid'])
|
|
4
|
+
|
|
5
|
+
export const isUsableGroupMetadata = metadata => {
|
|
6
|
+
if (!metadata || typeof metadata !== 'object') {
|
|
7
|
+
return false
|
|
8
|
+
}
|
|
9
|
+
if (!Array.isArray(metadata.participants)) {
|
|
10
|
+
return false
|
|
11
|
+
}
|
|
12
|
+
return GROUP_ADDRESSING_MODES.includes(metadata.addressingMode)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const describeUnusableGroupMetadata = metadata => {
|
|
16
|
+
if (!metadata || typeof metadata !== 'object') {
|
|
17
|
+
return 'nothing cached'
|
|
18
|
+
}
|
|
19
|
+
if (!Array.isArray(metadata.participants)) {
|
|
20
|
+
return 'no participants'
|
|
21
|
+
}
|
|
22
|
+
if (metadata.addressingMode === undefined || metadata.addressingMode === null) {
|
|
23
|
+
return 'no addressingMode'
|
|
24
|
+
}
|
|
25
|
+
return `addressingMode ${JSON.stringify(metadata.addressingMode)} is not pn or lid`
|
|
26
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare const HTML_APP_MESSAGE_CEILING: number
|
|
2
|
+
export declare const HTML_APP_BYTE_BUDGET: number
|
|
3
|
+
export declare const HTML_APP_BYTE_LIMIT: number
|
|
4
|
+
|
|
5
|
+
export declare function wireBytes(html: string): number
|
|
6
|
+
|
|
7
|
+
export interface HtmlAppReport {
|
|
8
|
+
ok: boolean
|
|
9
|
+
bytes: number
|
|
10
|
+
wireBytes: number
|
|
11
|
+
embeddedBytes: number
|
|
12
|
+
problems: string[]
|
|
13
|
+
warnings: string[]
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export declare function checkHtmlApp(html: string, options?: {
|
|
17
|
+
height?: number
|
|
18
|
+
maxBytes?: number
|
|
19
|
+
}): HtmlAppReport
|