@zapo-js/fake-server 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (238) hide show
  1. package/README.md +176 -0
  2. package/dist/api/AppStateSyncManager.d.ts +27 -0
  3. package/dist/api/AppStateSyncManager.d.ts.map +1 -0
  4. package/dist/api/AppStateSyncManager.js +151 -0
  5. package/dist/api/AppStateSyncManager.js.map +1 -0
  6. package/dist/api/FakePairingDriver.d.ts +27 -0
  7. package/dist/api/FakePairingDriver.d.ts.map +1 -0
  8. package/dist/api/FakePairingDriver.js +36 -0
  9. package/dist/api/FakePairingDriver.js.map +1 -0
  10. package/dist/api/FakePeer.d.ts +143 -0
  11. package/dist/api/FakePeer.d.ts.map +1 -0
  12. package/dist/api/FakePeer.js +408 -0
  13. package/dist/api/FakePeer.js.map +1 -0
  14. package/dist/api/FakeWaServer.d.ts +167 -0
  15. package/dist/api/FakeWaServer.d.ts.map +1 -0
  16. package/dist/api/FakeWaServer.js +652 -0
  17. package/dist/api/FakeWaServer.js.map +1 -0
  18. package/dist/api/PreKeyDispenser.d.ts +23 -0
  19. package/dist/api/PreKeyDispenser.d.ts.map +1 -0
  20. package/dist/api/PreKeyDispenser.js +98 -0
  21. package/dist/api/PreKeyDispenser.js.map +1 -0
  22. package/dist/api/Scenario.d.ts +24 -0
  23. package/dist/api/Scenario.d.ts.map +1 -0
  24. package/dist/api/Scenario.js +38 -0
  25. package/dist/api/Scenario.js.map +1 -0
  26. package/dist/api/ServerRegistries.d.ts +110 -0
  27. package/dist/api/ServerRegistries.d.ts.map +1 -0
  28. package/dist/api/ServerRegistries.js +268 -0
  29. package/dist/api/ServerRegistries.js.map +1 -0
  30. package/dist/api/iq-handlers.d.ts +47 -0
  31. package/dist/api/iq-handlers.d.ts.map +1 -0
  32. package/dist/api/iq-handlers.js +498 -0
  33. package/dist/api/iq-handlers.js.map +1 -0
  34. package/dist/cli.d.ts +4 -0
  35. package/dist/cli.d.ts.map +1 -0
  36. package/dist/cli.js +249 -0
  37. package/dist/cli.js.map +1 -0
  38. package/dist/index.d.ts +51 -0
  39. package/dist/index.d.ts.map +1 -0
  40. package/dist/index.js +74 -0
  41. package/dist/index.js.map +1 -0
  42. package/dist/infra/WaFakeConnection.d.ts +23 -0
  43. package/dist/infra/WaFakeConnection.d.ts.map +1 -0
  44. package/dist/infra/WaFakeConnection.js +54 -0
  45. package/dist/infra/WaFakeConnection.js.map +1 -0
  46. package/dist/infra/WaFakeConnectionPipeline.d.ts +51 -0
  47. package/dist/infra/WaFakeConnectionPipeline.d.ts.map +1 -0
  48. package/dist/infra/WaFakeConnectionPipeline.js +224 -0
  49. package/dist/infra/WaFakeConnectionPipeline.js.map +1 -0
  50. package/dist/infra/WaFakeFrameSocket.d.ts +29 -0
  51. package/dist/infra/WaFakeFrameSocket.d.ts.map +1 -0
  52. package/dist/infra/WaFakeFrameSocket.js +122 -0
  53. package/dist/infra/WaFakeFrameSocket.js.map +1 -0
  54. package/dist/infra/WaFakeMediaHttpsServer.d.ts +16 -0
  55. package/dist/infra/WaFakeMediaHttpsServer.d.ts.map +1 -0
  56. package/dist/infra/WaFakeMediaHttpsServer.js +131 -0
  57. package/dist/infra/WaFakeMediaHttpsServer.js.map +1 -0
  58. package/dist/infra/WaFakeNoiseHandshake.d.ts +23 -0
  59. package/dist/infra/WaFakeNoiseHandshake.d.ts.map +1 -0
  60. package/dist/infra/WaFakeNoiseHandshake.js +76 -0
  61. package/dist/infra/WaFakeNoiseHandshake.js.map +1 -0
  62. package/dist/infra/WaFakeTransport.d.ts +15 -0
  63. package/dist/infra/WaFakeTransport.d.ts.map +1 -0
  64. package/dist/infra/WaFakeTransport.js +34 -0
  65. package/dist/infra/WaFakeTransport.js.map +1 -0
  66. package/dist/infra/WaFakeWsServer.d.ts +29 -0
  67. package/dist/infra/WaFakeWsServer.d.ts.map +1 -0
  68. package/dist/infra/WaFakeWsServer.js +101 -0
  69. package/dist/infra/WaFakeWsServer.js.map +1 -0
  70. package/dist/protocol/auth/cert-chain.d.ts +18 -0
  71. package/dist/protocol/auth/cert-chain.d.ts.map +1 -0
  72. package/dist/protocol/auth/cert-chain.js +44 -0
  73. package/dist/protocol/auth/cert-chain.js.map +1 -0
  74. package/dist/protocol/auth/client-payload-validate.d.ts +21 -0
  75. package/dist/protocol/auth/client-payload-validate.d.ts.map +1 -0
  76. package/dist/protocol/auth/client-payload-validate.js +61 -0
  77. package/dist/protocol/auth/client-payload-validate.js.map +1 -0
  78. package/dist/protocol/auth/fake-primary-device.d.ts +19 -0
  79. package/dist/protocol/auth/fake-primary-device.d.ts.map +1 -0
  80. package/dist/protocol/auth/fake-primary-device.js +53 -0
  81. package/dist/protocol/auth/fake-primary-device.js.map +1 -0
  82. package/dist/protocol/auth/pair-device.d.ts +26 -0
  83. package/dist/protocol/auth/pair-device.d.ts.map +1 -0
  84. package/dist/protocol/auth/pair-device.js +104 -0
  85. package/dist/protocol/auth/pair-device.js.map +1 -0
  86. package/dist/protocol/auth/success-node.d.ts +15 -0
  87. package/dist/protocol/auth/success-node.d.ts.map +1 -0
  88. package/dist/protocol/auth/success-node.js +30 -0
  89. package/dist/protocol/auth/success-node.js.map +1 -0
  90. package/dist/protocol/iq/abprops.d.ts +14 -0
  91. package/dist/protocol/iq/abprops.d.ts.map +1 -0
  92. package/dist/protocol/iq/abprops.js +34 -0
  93. package/dist/protocol/iq/abprops.js.map +1 -0
  94. package/dist/protocol/iq/appstate-sync.d.ts +38 -0
  95. package/dist/protocol/iq/appstate-sync.d.ts.map +1 -0
  96. package/dist/protocol/iq/appstate-sync.js +154 -0
  97. package/dist/protocol/iq/appstate-sync.js.map +1 -0
  98. package/dist/protocol/iq/business.d.ts +13 -0
  99. package/dist/protocol/iq/business.d.ts.map +1 -0
  100. package/dist/protocol/iq/business.js +64 -0
  101. package/dist/protocol/iq/business.js.map +1 -0
  102. package/dist/protocol/iq/dirty-bits.d.ts +8 -0
  103. package/dist/protocol/iq/dirty-bits.d.ts.map +1 -0
  104. package/dist/protocol/iq/dirty-bits.js +23 -0
  105. package/dist/protocol/iq/dirty-bits.js.map +1 -0
  106. package/dist/protocol/iq/group-ops.d.ts +34 -0
  107. package/dist/protocol/iq/group-ops.d.ts.map +1 -0
  108. package/dist/protocol/iq/group-ops.js +164 -0
  109. package/dist/protocol/iq/group-ops.js.map +1 -0
  110. package/dist/protocol/iq/newsletter.d.ts +4 -0
  111. package/dist/protocol/iq/newsletter.d.ts.map +1 -0
  112. package/dist/protocol/iq/newsletter.js +18 -0
  113. package/dist/protocol/iq/newsletter.js.map +1 -0
  114. package/dist/protocol/iq/prekey-fetch.d.ts +18 -0
  115. package/dist/protocol/iq/prekey-fetch.d.ts.map +1 -0
  116. package/dist/protocol/iq/prekey-fetch.js +92 -0
  117. package/dist/protocol/iq/prekey-fetch.js.map +1 -0
  118. package/dist/protocol/iq/privacy-token.d.ts +9 -0
  119. package/dist/protocol/iq/privacy-token.d.ts.map +1 -0
  120. package/dist/protocol/iq/privacy-token.js +30 -0
  121. package/dist/protocol/iq/privacy-token.js.map +1 -0
  122. package/dist/protocol/iq/privacy.d.ts +22 -0
  123. package/dist/protocol/iq/privacy.d.ts.map +1 -0
  124. package/dist/protocol/iq/privacy.js +133 -0
  125. package/dist/protocol/iq/privacy.js.map +1 -0
  126. package/dist/protocol/iq/profile.d.ts +22 -0
  127. package/dist/protocol/iq/profile.d.ts.map +1 -0
  128. package/dist/protocol/iq/profile.js +80 -0
  129. package/dist/protocol/iq/profile.js.map +1 -0
  130. package/dist/protocol/iq/router.d.ts +39 -0
  131. package/dist/protocol/iq/router.d.ts.map +1 -0
  132. package/dist/protocol/iq/router.js +118 -0
  133. package/dist/protocol/iq/router.js.map +1 -0
  134. package/dist/protocol/iq/usync.d.ts +8 -0
  135. package/dist/protocol/iq/usync.d.ts.map +1 -0
  136. package/dist/protocol/iq/usync.js +68 -0
  137. package/dist/protocol/iq/usync.js.map +1 -0
  138. package/dist/protocol/push/app-state-key-share.d.ts +17 -0
  139. package/dist/protocol/push/app-state-key-share.d.ts.map +1 -0
  140. package/dist/protocol/push/app-state-key-share.js +30 -0
  141. package/dist/protocol/push/app-state-key-share.js.map +1 -0
  142. package/dist/protocol/push/call-failure.d.ts +16 -0
  143. package/dist/protocol/push/call-failure.d.ts.map +1 -0
  144. package/dist/protocol/push/call-failure.js +32 -0
  145. package/dist/protocol/push/call-failure.js.map +1 -0
  146. package/dist/protocol/push/chatstate.d.ts +15 -0
  147. package/dist/protocol/push/chatstate.d.ts.map +1 -0
  148. package/dist/protocol/push/chatstate.js +27 -0
  149. package/dist/protocol/push/chatstate.js.map +1 -0
  150. package/dist/protocol/push/error-stanza.d.ts +8 -0
  151. package/dist/protocol/push/error-stanza.d.ts.map +1 -0
  152. package/dist/protocol/push/error-stanza.js +17 -0
  153. package/dist/protocol/push/error-stanza.js.map +1 -0
  154. package/dist/protocol/push/history-sync.d.ts +46 -0
  155. package/dist/protocol/push/history-sync.d.ts.map +1 -0
  156. package/dist/protocol/push/history-sync.js +117 -0
  157. package/dist/protocol/push/history-sync.js.map +1 -0
  158. package/dist/protocol/push/message.d.ts +21 -0
  159. package/dist/protocol/push/message.d.ts.map +1 -0
  160. package/dist/protocol/push/message.js +42 -0
  161. package/dist/protocol/push/message.js.map +1 -0
  162. package/dist/protocol/push/notification.d.ts +21 -0
  163. package/dist/protocol/push/notification.d.ts.map +1 -0
  164. package/dist/protocol/push/notification.js +34 -0
  165. package/dist/protocol/push/notification.js.map +1 -0
  166. package/dist/protocol/push/presence.d.ts +11 -0
  167. package/dist/protocol/push/presence.d.ts.map +1 -0
  168. package/dist/protocol/push/presence.js +18 -0
  169. package/dist/protocol/push/presence.js.map +1 -0
  170. package/dist/protocol/push/receipt.d.ts +14 -0
  171. package/dist/protocol/push/receipt.d.ts.map +1 -0
  172. package/dist/protocol/push/receipt.js +25 -0
  173. package/dist/protocol/push/receipt.js.map +1 -0
  174. package/dist/protocol/signal/fake-app-state-crypto.d.ts +49 -0
  175. package/dist/protocol/signal/fake-app-state-crypto.d.ts.map +1 -0
  176. package/dist/protocol/signal/fake-app-state-crypto.js +202 -0
  177. package/dist/protocol/signal/fake-app-state-crypto.js.map +1 -0
  178. package/dist/protocol/signal/fake-peer-double-ratchet.d.ts +38 -0
  179. package/dist/protocol/signal/fake-peer-double-ratchet.d.ts.map +1 -0
  180. package/dist/protocol/signal/fake-peer-double-ratchet.js +408 -0
  181. package/dist/protocol/signal/fake-peer-double-ratchet.js.map +1 -0
  182. package/dist/protocol/signal/fake-peer-group-recv-session.d.ts +10 -0
  183. package/dist/protocol/signal/fake-peer-group-recv-session.d.ts.map +1 -0
  184. package/dist/protocol/signal/fake-peer-group-recv-session.js +129 -0
  185. package/dist/protocol/signal/fake-peer-group-recv-session.js.map +1 -0
  186. package/dist/protocol/signal/fake-peer-identity.d.ts +7 -0
  187. package/dist/protocol/signal/fake-peer-identity.d.ts.map +1 -0
  188. package/dist/protocol/signal/fake-peer-identity.js +12 -0
  189. package/dist/protocol/signal/fake-peer-identity.js.map +1 -0
  190. package/dist/protocol/signal/fake-peer-key-bundle.d.ts +24 -0
  191. package/dist/protocol/signal/fake-peer-key-bundle.d.ts.map +1 -0
  192. package/dist/protocol/signal/fake-peer-key-bundle.js +29 -0
  193. package/dist/protocol/signal/fake-peer-key-bundle.js.map +1 -0
  194. package/dist/protocol/signal/fake-peer-recv-session.d.ts +60 -0
  195. package/dist/protocol/signal/fake-peer-recv-session.d.ts.map +1 -0
  196. package/dist/protocol/signal/fake-peer-recv-session.js +284 -0
  197. package/dist/protocol/signal/fake-peer-recv-session.js.map +1 -0
  198. package/dist/protocol/signal/fake-peer-session.d.ts +87 -0
  199. package/dist/protocol/signal/fake-peer-session.d.ts.map +1 -0
  200. package/dist/protocol/signal/fake-peer-session.js +207 -0
  201. package/dist/protocol/signal/fake-peer-session.js.map +1 -0
  202. package/dist/protocol/signal/fake-sender-key.d.ts +15 -0
  203. package/dist/protocol/signal/fake-sender-key.d.ts.map +1 -0
  204. package/dist/protocol/signal/fake-sender-key.js +91 -0
  205. package/dist/protocol/signal/fake-sender-key.js.map +1 -0
  206. package/dist/protocol/signal/prekey-upload.d.ts +22 -0
  207. package/dist/protocol/signal/prekey-upload.d.ts.map +1 -0
  208. package/dist/protocol/signal/prekey-upload.js +113 -0
  209. package/dist/protocol/signal/prekey-upload.js.map +1 -0
  210. package/dist/protocol/stream/stream-error.d.ts +8 -0
  211. package/dist/protocol/stream/stream-error.d.ts.map +1 -0
  212. package/dist/protocol/stream/stream-error.js +64 -0
  213. package/dist/protocol/stream/stream-error.js.map +1 -0
  214. package/dist/state/fake-app-state-collection.d.ts +35 -0
  215. package/dist/state/fake-app-state-collection.d.ts.map +1 -0
  216. package/dist/state/fake-app-state-collection.js +139 -0
  217. package/dist/state/fake-app-state-collection.js.map +1 -0
  218. package/dist/state/fake-media-store.d.ts +35 -0
  219. package/dist/state/fake-media-store.d.ts.map +1 -0
  220. package/dist/state/fake-media-store.js +57 -0
  221. package/dist/state/fake-media-store.js.map +1 -0
  222. package/dist/transport/codec.d.ts +10 -0
  223. package/dist/transport/codec.d.ts.map +1 -0
  224. package/dist/transport/codec.js +17 -0
  225. package/dist/transport/codec.js.map +1 -0
  226. package/dist/transport/crypto.d.ts +11 -0
  227. package/dist/transport/crypto.d.ts.map +1 -0
  228. package/dist/transport/crypto.js +36 -0
  229. package/dist/transport/crypto.js.map +1 -0
  230. package/dist/transport/index.d.ts +4 -0
  231. package/dist/transport/index.d.ts.map +1 -0
  232. package/dist/transport/index.js +20 -0
  233. package/dist/transport/index.js.map +1 -0
  234. package/dist/transport/protos.d.ts +10 -0
  235. package/dist/transport/protos.d.ts.map +1 -0
  236. package/dist/transport/protos.js +13 -0
  237. package/dist/transport/protos.js.map +1 -0
  238. package/package.json +43 -0
@@ -0,0 +1,164 @@
1
+ "use strict";
2
+ /** Builders/parsers for `w:g2` group IQ operations. */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.parseGroupParticipantChangeIq = parseGroupParticipantChangeIq;
5
+ exports.buildGroupParticipantChangeResult = buildGroupParticipantChangeResult;
6
+ exports.parseCreateGroupIq = parseCreateGroupIq;
7
+ exports.parseSetSubjectIq = parseSetSubjectIq;
8
+ exports.parseSetDescriptionIq = parseSetDescriptionIq;
9
+ exports.parseLeaveGroupIq = parseLeaveGroupIq;
10
+ exports.buildGroupMetadataNode = buildGroupMetadataNode;
11
+ const router_1 = require("./router");
12
+ function parseGroupParticipantChangeIq(iq) {
13
+ if (!Array.isArray(iq.content))
14
+ return null;
15
+ for (const child of iq.content) {
16
+ if (child.tag === 'add' ||
17
+ child.tag === 'remove' ||
18
+ child.tag === 'promote' ||
19
+ child.tag === 'demote') {
20
+ const groupJid = iq.attrs.to;
21
+ if (!groupJid)
22
+ return null;
23
+ const participantJids = [];
24
+ if (Array.isArray(child.content)) {
25
+ for (const participant of child.content) {
26
+ if (participant.tag === 'participant' && participant.attrs.jid) {
27
+ participantJids.push(participant.attrs.jid);
28
+ }
29
+ }
30
+ }
31
+ return {
32
+ action: child.tag,
33
+ groupJid,
34
+ participantJids
35
+ };
36
+ }
37
+ }
38
+ return null;
39
+ }
40
+ function buildGroupParticipantChangeResult(iq, action, participantJids) {
41
+ const result = (0, router_1.buildIqResult)(iq);
42
+ return {
43
+ ...result,
44
+ content: [
45
+ {
46
+ tag: action,
47
+ attrs: {},
48
+ content: participantJids.map((jid) => ({
49
+ tag: 'participant',
50
+ attrs: { jid, error: '200' }
51
+ }))
52
+ }
53
+ ]
54
+ };
55
+ }
56
+ function parseCreateGroupIq(iq) {
57
+ if (!Array.isArray(iq.content))
58
+ return null;
59
+ const create = iq.content.find((child) => child.tag === 'create');
60
+ if (!create)
61
+ return null;
62
+ const subject = create.attrs.subject ?? '';
63
+ const participantJids = [];
64
+ let description;
65
+ if (Array.isArray(create.content)) {
66
+ for (const child of create.content) {
67
+ if (child.tag === 'participant' && child.attrs.jid) {
68
+ participantJids.push(child.attrs.jid);
69
+ }
70
+ else if (child.tag === 'description' && Array.isArray(child.content)) {
71
+ const body = child.content.find((c) => c.tag === 'body');
72
+ if (body && typeof body.content === 'string') {
73
+ description = body.content;
74
+ }
75
+ else if (body && body.content instanceof Uint8Array) {
76
+ description = new TextDecoder().decode(body.content);
77
+ }
78
+ }
79
+ }
80
+ }
81
+ return { subject, participantJids, description };
82
+ }
83
+ function parseSetSubjectIq(iq) {
84
+ if (!Array.isArray(iq.content))
85
+ return null;
86
+ const subject = iq.content.find((child) => child.tag === 'subject');
87
+ if (!subject)
88
+ return null;
89
+ const groupJid = iq.attrs.to;
90
+ if (!groupJid)
91
+ return null;
92
+ return {
93
+ groupJid,
94
+ subject: decodeNodeContentToString(subject.content) ?? ''
95
+ };
96
+ }
97
+ function parseSetDescriptionIq(iq) {
98
+ if (!Array.isArray(iq.content))
99
+ return null;
100
+ const desc = iq.content.find((child) => child.tag === 'description');
101
+ if (!desc)
102
+ return null;
103
+ const groupJid = iq.attrs.to;
104
+ if (!groupJid)
105
+ return null;
106
+ if (desc.attrs.delete === 'true') {
107
+ return { groupJid, description: null, descriptionId: desc.attrs.id };
108
+ }
109
+ let body = null;
110
+ if (Array.isArray(desc.content)) {
111
+ const bodyNode = desc.content.find((c) => c.tag === 'body');
112
+ if (bodyNode) {
113
+ body = decodeNodeContentToString(bodyNode.content) ?? '';
114
+ }
115
+ }
116
+ return { groupJid, description: body, descriptionId: desc.attrs.id };
117
+ }
118
+ function parseLeaveGroupIq(iq) {
119
+ if (!Array.isArray(iq.content))
120
+ return null;
121
+ const leave = iq.content.find((child) => child.tag === 'leave');
122
+ if (!leave || !Array.isArray(leave.content))
123
+ return null;
124
+ const out = [];
125
+ for (const child of leave.content) {
126
+ if (child.tag === 'group' && child.attrs.id) {
127
+ out.push(child.attrs.id);
128
+ }
129
+ }
130
+ return out;
131
+ }
132
+ function buildGroupMetadataNode(input) {
133
+ const children = input.participantJids.map((jid) => ({
134
+ tag: 'participant',
135
+ attrs: { jid }
136
+ }));
137
+ if (input.description !== undefined) {
138
+ children.push({
139
+ tag: 'description',
140
+ attrs: { id: input.descriptionId ?? `${Date.now()}` },
141
+ content: [{ tag: 'body', attrs: {}, content: input.description }]
142
+ });
143
+ }
144
+ return {
145
+ tag: 'group',
146
+ attrs: {
147
+ id: input.groupJid,
148
+ subject: input.subject,
149
+ creation: String(input.creationSeconds),
150
+ creator: input.creator,
151
+ s_t: String(input.creationSeconds),
152
+ s_o: input.creator
153
+ },
154
+ content: children
155
+ };
156
+ }
157
+ function decodeNodeContentToString(content) {
158
+ if (typeof content === 'string')
159
+ return content;
160
+ if (content instanceof Uint8Array)
161
+ return new TextDecoder().decode(content);
162
+ return undefined;
163
+ }
164
+ //# sourceMappingURL=group-ops.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"group-ops.js","sourceRoot":"","sources":["../../../src/protocol/iq/group-ops.ts"],"names":[],"mappings":";AAAA,uDAAuD;;AAQvD,sEA+BC;AAED,8EAmBC;AAED,gDA0BC;AAED,8CAaC;AAED,sDAqBC;AAED,8CAWC;AAED,wDAgCC;AAzKD,qCAAwC;AAIxC,SAAgB,6BAA6B,CAAC,EAAc;IAKxD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC;QAAE,OAAO,IAAI,CAAA;IAC3C,KAAK,MAAM,KAAK,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC;QAC7B,IACI,KAAK,CAAC,GAAG,KAAK,KAAK;YACnB,KAAK,CAAC,GAAG,KAAK,QAAQ;YACtB,KAAK,CAAC,GAAG,KAAK,SAAS;YACvB,KAAK,CAAC,GAAG,KAAK,QAAQ,EACxB,CAAC;YACC,MAAM,QAAQ,GAAG,EAAE,CAAC,KAAK,CAAC,EAAE,CAAA;YAC5B,IAAI,CAAC,QAAQ;gBAAE,OAAO,IAAI,CAAA;YAC1B,MAAM,eAAe,GAAa,EAAE,CAAA;YACpC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC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K,CAAC,aAAa,IAAI,GAAG,IAAI,CAAC,GAAG,EAAE,EAAE,EAAE;YACrD,OAAO,EAAE,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,EAAE,OAAO,EAAE,KAAK,CAAC,WAAW,EAAE,CAAC;SACpE,CAAC,CAAA;IACN,CAAC;IACD,OAAO;QACH,GAAG,EAAE,OAAO;QACZ,KAAK,EAAE;YACH,EAAE,EAAE,KAAK,CAAC,QAAQ;YAClB,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,QAAQ,EAAE,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC;YACvC,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,GAAG,EAAE,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC;YAClC,GAAG,EAAE,KAAK,CAAC,OAAO;SACrB;QACD,OAAO,EAAE,QAAQ;KACpB,CAAA;AACL,CAAC;AAED,SAAS,yBAAyB,CAAC,OAA8B;IAC7D,IAAI,OAAO,OAAO,KAAK,QAAQ;QAAE,OAAO,OAAO,CAAA;IAC/C,IAAI,OAAO,YAAY,UAAU;QAAE,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;IAC3E,OAAO,SAAS,CAAA;AACpB,CAAC"}
@@ -0,0 +1,4 @@
1
+ /** Builds the `newsletter/my_addons` IQ result expected by the lib. */
2
+ import type { BinaryNode } from '../../transport/codec';
3
+ export declare function buildNewsletterMyAddonsResult(iq: BinaryNode): BinaryNode;
4
+ //# sourceMappingURL=newsletter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"newsletter.d.ts","sourceRoot":"","sources":["../../../src/protocol/iq/newsletter.ts"],"names":[],"mappings":"AAAA,uEAAuE;AAEvE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAIvD,wBAAgB,6BAA6B,CAAC,EAAE,EAAE,UAAU,GAAG,UAAU,CAWxE"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ /** Builds the `newsletter/my_addons` IQ result expected by the lib. */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.buildNewsletterMyAddonsResult = buildNewsletterMyAddonsResult;
5
+ const router_1 = require("./router");
6
+ function buildNewsletterMyAddonsResult(iq) {
7
+ const result = (0, router_1.buildIqResult)(iq);
8
+ return {
9
+ ...result,
10
+ content: [
11
+ {
12
+ tag: 'my_addons',
13
+ attrs: {}
14
+ }
15
+ ]
16
+ };
17
+ }
18
+ //# sourceMappingURL=newsletter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"newsletter.js","sourceRoot":"","sources":["../../../src/protocol/iq/newsletter.ts"],"names":[],"mappings":";AAAA,uEAAuE;;AAMvE,sEAWC;AAbD,qCAAwC;AAExC,SAAgB,6BAA6B,CAAC,EAAc;IACxD,MAAM,MAAM,GAAG,IAAA,sBAAa,EAAC,EAAE,CAAC,CAAA;IAChC,OAAO;QACH,GAAG,MAAM;QACT,OAAO,EAAE;YACL;gBACI,GAAG,EAAE,WAAW;gBAChB,KAAK,EAAE,EAAE;aACZ;SACJ;KACJ,CAAA;AACL,CAAC"}
@@ -0,0 +1,18 @@
1
+ /** Builder for `encrypt` prekey-fetch IQ responses. */
2
+ import type { BinaryNode } from '../../transport/codec';
3
+ export interface PreKeyBundleForUser {
4
+ readonly userJid: string;
5
+ readonly registrationId: number;
6
+ readonly identityPublicKey: Uint8Array;
7
+ readonly signedPreKey: {
8
+ readonly id: number;
9
+ readonly publicKey: Uint8Array;
10
+ readonly signature: Uint8Array;
11
+ };
12
+ readonly oneTimePreKey?: {
13
+ readonly id: number;
14
+ readonly publicKey: Uint8Array;
15
+ };
16
+ }
17
+ export declare function buildPreKeyFetchResult(inboundIq: BinaryNode, bundles: readonly PreKeyBundleForUser[]): BinaryNode;
18
+ //# sourceMappingURL=prekey-fetch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prekey-fetch.d.ts","sourceRoot":"","sources":["../../../src/protocol/iq/prekey-fetch.ts"],"names":[],"mappings":"AAAA,uDAAuD;AAEvD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAEvD,MAAM,WAAW,mBAAmB;IAChC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAA;IAC/B,QAAQ,CAAC,iBAAiB,EAAE,UAAU,CAAA;IACtC,QAAQ,CAAC,YAAY,EAAE;QACnB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;QACnB,QAAQ,CAAC,SAAS,EAAE,UAAU,CAAA;QAC9B,QAAQ,CAAC,SAAS,EAAE,UAAU,CAAA;KACjC,CAAA;IACD,QAAQ,CAAC,aAAa,CAAC,EAAE;QACrB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;QACnB,QAAQ,CAAC,SAAS,EAAE,UAAU,CAAA;KACjC,CAAA;CACJ;AAED,wBAAgB,sBAAsB,CAClC,SAAS,EAAE,UAAU,EACrB,OAAO,EAAE,SAAS,mBAAmB,EAAE,GACxC,UAAU,CAgFZ"}
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ /** Builder for `encrypt` prekey-fetch IQ responses. */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.buildPreKeyFetchResult = buildPreKeyFetchResult;
5
+ function buildPreKeyFetchResult(inboundIq, bundles) {
6
+ const id = inboundIq.attrs.id;
7
+ if (!id) {
8
+ throw new Error('cannot build prekey-fetch result without an inbound id');
9
+ }
10
+ const userNodes = bundles.map((bundle) => {
11
+ const children = [
12
+ {
13
+ tag: 'registration',
14
+ attrs: {},
15
+ content: bigEndianBytes(bundle.registrationId, 4)
16
+ },
17
+ {
18
+ tag: 'identity',
19
+ attrs: {},
20
+ content: bundle.identityPublicKey
21
+ },
22
+ {
23
+ tag: 'skey',
24
+ attrs: {},
25
+ content: [
26
+ {
27
+ tag: 'id',
28
+ attrs: {},
29
+ content: bigEndianBytes(bundle.signedPreKey.id, 3)
30
+ },
31
+ {
32
+ tag: 'value',
33
+ attrs: {},
34
+ content: bundle.signedPreKey.publicKey
35
+ },
36
+ {
37
+ tag: 'signature',
38
+ attrs: {},
39
+ content: bundle.signedPreKey.signature
40
+ }
41
+ ]
42
+ }
43
+ ];
44
+ if (bundle.oneTimePreKey) {
45
+ children.push({
46
+ tag: 'key',
47
+ attrs: {},
48
+ content: [
49
+ {
50
+ tag: 'id',
51
+ attrs: {},
52
+ content: bigEndianBytes(bundle.oneTimePreKey.id, 3)
53
+ },
54
+ {
55
+ tag: 'value',
56
+ attrs: {},
57
+ content: bundle.oneTimePreKey.publicKey
58
+ }
59
+ ]
60
+ });
61
+ }
62
+ return {
63
+ tag: 'user',
64
+ attrs: { jid: bundle.userJid },
65
+ content: children
66
+ };
67
+ });
68
+ return {
69
+ tag: 'iq',
70
+ attrs: {
71
+ id,
72
+ from: inboundIq.attrs.to ?? 's.whatsapp.net',
73
+ type: 'result'
74
+ },
75
+ content: [
76
+ {
77
+ tag: 'list',
78
+ attrs: {},
79
+ content: userNodes
80
+ }
81
+ ]
82
+ };
83
+ }
84
+ function bigEndianBytes(value, length) {
85
+ const out = new Uint8Array(length);
86
+ for (let i = length - 1; i >= 0; i -= 1) {
87
+ out[i] = value & 0xff;
88
+ value >>>= 8;
89
+ }
90
+ return out;
91
+ }
92
+ //# sourceMappingURL=prekey-fetch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prekey-fetch.js","sourceRoot":"","sources":["../../../src/protocol/iq/prekey-fetch.ts"],"names":[],"mappings":";AAAA,uDAAuD;;AAmBvD,wDAmFC;AAnFD,SAAgB,sBAAsB,CAClC,SAAqB,EACrB,OAAuC;IAEvC,MAAM,EAAE,GAAG,SAAS,CAAC,KAAK,CAAC,EAAE,CAAA;IAC7B,IAAI,CAAC,EAAE,EAAE,CAAC;QACN,MAAM,IAAI,KAAK,CAAC,wDAAwD,CAAC,CAAA;IAC7E,CAAC;IAED,M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AM;YACX,KAAK,EAAE,EAAE,GAAG,EAAE,MAAM,CAAC,OAAO,EAAE;YAC9B,OAAO,EAAE,QAAQ;SACpB,CAAA;IACL,CAAC,CAAC,CAAA;IAEF,OAAO;QACH,GAAG,EAAE,IAAI;QACT,KAAK,EAAE;YACH,EAAE;YACF,IAAI,EAAE,SAAS,CAAC,KAAK,CAAC,EAAE,IAAI,gBAAgB;YAC5C,IAAI,EAAE,QAAQ;SACjB;QACD,OAAO,EAAE;YACL;gBACI,GAAG,EAAE,MAAM;gBACX,KAAK,EAAE,EAAE;gBACT,OAAO,EAAE,SAAS;aACrB;SACJ;KACJ,CAAA;AACL,CAAC;AAED,SAAS,cAAc,CAAC,KAAa,EAAE,MAAc;IACjD,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,CAAA;IAClC,KAAK,IAAI,CAAC,GAAG,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QACtC,GAAG,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,IAAI,CAAA;QACrB,KAAK,MAAM,CAAC,CAAA;IAChB,CAAC;IACD,OAAO,GAAG,CAAA;AACd,CAAC"}
@@ -0,0 +1,9 @@
1
+ /** Parser helpers for outbound trusted-contact privacy token IQs. */
2
+ import type { BinaryNode } from '../../transport/codec';
3
+ export interface FakePrivacyTokenIssue {
4
+ readonly jid: string;
5
+ readonly timestampS: number;
6
+ readonly type: string;
7
+ }
8
+ export declare function parsePrivacyTokenIssueIq(iq: BinaryNode): readonly FakePrivacyTokenIssue[] | null;
9
+ //# sourceMappingURL=privacy-token.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"privacy-token.d.ts","sourceRoot":"","sources":["../../../src/protocol/iq/privacy-token.ts"],"names":[],"mappings":"AAAA,qEAAqE;AAErE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAEvD,MAAM,WAAW,qBAAqB;IAClC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CACxB;AAED,wBAAgB,wBAAwB,CAAC,EAAE,EAAE,UAAU,GAAG,SAAS,qBAAqB,EAAE,GAAG,IAAI,CAmBhG"}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ /** Parser helpers for outbound trusted-contact privacy token IQs. */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.parsePrivacyTokenIssueIq = parsePrivacyTokenIssueIq;
5
+ function parsePrivacyTokenIssueIq(iq) {
6
+ if (!Array.isArray(iq.content))
7
+ return null;
8
+ const tokens = iq.content.find((child) => child.tag === 'tokens');
9
+ if (!tokens || !Array.isArray(tokens.content))
10
+ return null;
11
+ const out = [];
12
+ for (const child of tokens.content) {
13
+ if (child.tag !== 'token')
14
+ continue;
15
+ const jid = child.attrs.jid;
16
+ const t = child.attrs.t;
17
+ if (!jid || !t)
18
+ continue;
19
+ const timestampS = Number.parseInt(t, 10);
20
+ if (!Number.isFinite(timestampS))
21
+ continue;
22
+ out.push({
23
+ jid,
24
+ timestampS,
25
+ type: child.attrs.type ?? 'trusted_contact'
26
+ });
27
+ }
28
+ return out;
29
+ }
30
+ //# sourceMappingURL=privacy-token.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"privacy-token.js","sourceRoot":"","sources":["../../../src/protocol/iq/privacy-token.ts"],"names":[],"mappings":";AAAA,qEAAqE;;AAUrE,4DAmBC;AAnBD,SAAgB,wBAAwB,CAAC,EAAc;IACnD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC;QAAE,OAAO,IAAI,CAAA;IAC3C,MAAM,MAAM,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,KAAK,QAAQ,CAAC,CAAA;IACjE,IAAI,CAAC,MAAM,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC;QAAE,OAAO,IAAI,CAAA;IAC1D,MAAM,GAAG,GAA4B,EAAE,CAAA;IACvC,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,OAAO,EAAE,CAAC;QACjC,IAAI,KAAK,CAAC,GAAG,KAAK,OAAO;YAAE,SAAQ;QACnC,MAAM,GAAG,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAA;QAC3B,MAAM,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAA;QACvB,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;YAAE,SAAQ;QACxB,MAAM,UAAU,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;QACzC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC;YAAE,SAAQ;QAC1C,GAAG,CAAC,IAAI,CAAC;YACL,GAAG;YACH,UAAU;YACV,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,IAAI,IAAI,iBAAiB;SAC9C,CAAC,CAAA;IACN,CAAC;IACD,OAAO,GAAG,CAAA;AACd,CAAC"}
@@ -0,0 +1,22 @@
1
+ /** Builders/parsers for `privacy` and `blocklist` IQs. */
2
+ import type { BinaryNode } from '../../transport/codec';
3
+ export type FakePrivacyCategoryName = 'readreceipts' | 'last' | 'online' | 'profile' | 'status' | 'groupadd' | 'calladd' | 'messages' | 'defense';
4
+ export type FakePrivacyValue = string;
5
+ export interface FakePrivacySettingsState {
6
+ readonly settings: Readonly<Record<FakePrivacyCategoryName, FakePrivacyValue>>;
7
+ readonly disallowed: Readonly<Record<FakePrivacyCategoryName, readonly string[]>>;
8
+ }
9
+ export declare const FAKE_DEFAULT_PRIVACY_SETTINGS: FakePrivacySettingsState;
10
+ export declare function buildPrivacySettingsResult(iq: BinaryNode, state: FakePrivacySettingsState): BinaryNode;
11
+ export declare function buildPrivacyDisallowedListResult(iq: BinaryNode, category: FakePrivacyCategoryName, jids: readonly string[]): BinaryNode;
12
+ export declare function buildBlocklistResult(iq: BinaryNode, jids: readonly string[]): BinaryNode;
13
+ export declare function parsePrivacySetCategoryIq(iq: BinaryNode): {
14
+ readonly category: FakePrivacyCategoryName;
15
+ readonly value: string;
16
+ } | null;
17
+ export declare function parseBlocklistChangeIq(iq: BinaryNode): {
18
+ readonly jid: string;
19
+ readonly action: 'block' | 'unblock';
20
+ } | null;
21
+ export declare function parsePrivacyDisallowedListGetIq(iq: BinaryNode): FakePrivacyCategoryName | null;
22
+ //# sourceMappingURL=privacy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"privacy.d.ts","sourceRoot":"","sources":["../../../src/protocol/iq/privacy.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAE1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAIvD,MAAM,MAAM,uBAAuB,GAC7B,cAAc,GACd,MAAM,GACN,QAAQ,GACR,SAAS,GACT,QAAQ,GACR,UAAU,GACV,SAAS,GACT,UAAU,GACV,SAAS,CAAA;AAEf,MAAM,MAAM,gBAAgB,GAAG,MAAM,CAAA;AAErC,MAAM,WAAW,wBAAwB;IACrC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,uBAAuB,EAAE,gBAAgB,CAAC,CAAC,CAAA;IAC9E,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,uBAAuB,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC,CAAA;CACpF;AAED,eAAO,MAAM,6BAA6B,EAAE,wBAuB3C,CAAA;AAED,wBAAgB,0BAA0B,CACtC,EAAE,EAAE,UAAU,EACd,KAAK,EAAE,wBAAwB,GAChC,UAAU,CAeZ;AAED,wBAAgB,gCAAgC,CAC5C,EAAE,EAAE,UAAU,EACd,QAAQ,EAAE,uBAAuB,EACjC,IAAI,EAAE,SAAS,MAAM,EAAE,GACxB,UAAU,CAyBZ;AAED,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,UAAU,CAexF;AAED,wBAAgB,yBAAyB,CAAC,EAAE,EAAE,UAAU,GAAG;IACvD,QAAQ,CAAC,QAAQ,EAAE,uBAAuB,CAAA;IAC1C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CACzB,GAAG,IAAI,CAUP;AAED,wBAAgB,sBAAsB,CAAC,EAAE,EAAE,UAAU,GAAG;IACpD,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,MAAM,EAAE,OAAO,GAAG,SAAS,CAAA;CACvC,GAAG,IAAI,CAQP;AAED,wBAAgB,+BAA+B,CAAC,EAAE,EAAE,UAAU,GAAG,uBAAuB,GAAG,IAAI,CAQ9F"}
@@ -0,0 +1,133 @@
1
+ "use strict";
2
+ /** Builders/parsers for `privacy` and `blocklist` IQs. */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.FAKE_DEFAULT_PRIVACY_SETTINGS = void 0;
5
+ exports.buildPrivacySettingsResult = buildPrivacySettingsResult;
6
+ exports.buildPrivacyDisallowedListResult = buildPrivacyDisallowedListResult;
7
+ exports.buildBlocklistResult = buildBlocklistResult;
8
+ exports.parsePrivacySetCategoryIq = parsePrivacySetCategoryIq;
9
+ exports.parseBlocklistChangeIq = parseBlocklistChangeIq;
10
+ exports.parsePrivacyDisallowedListGetIq = parsePrivacyDisallowedListGetIq;
11
+ const router_1 = require("./router");
12
+ exports.FAKE_DEFAULT_PRIVACY_SETTINGS = {
13
+ settings: {
14
+ readreceipts: 'all',
15
+ last: 'all',
16
+ online: 'all',
17
+ profile: 'all',
18
+ status: 'contacts',
19
+ groupadd: 'all',
20
+ calladd: 'all',
21
+ messages: 'all',
22
+ defense: 'off'
23
+ },
24
+ disallowed: {
25
+ readreceipts: [],
26
+ last: [],
27
+ online: [],
28
+ profile: [],
29
+ status: [],
30
+ groupadd: [],
31
+ calladd: [],
32
+ messages: [],
33
+ defense: []
34
+ }
35
+ };
36
+ function buildPrivacySettingsResult(iq, state) {
37
+ const result = (0, router_1.buildIqResult)(iq);
38
+ return {
39
+ ...result,
40
+ content: [
41
+ {
42
+ tag: 'privacy',
43
+ attrs: {},
44
+ content: Object.keys(state.settings).map((name) => ({
45
+ tag: 'category',
46
+ attrs: { name, value: state.settings[name] }
47
+ }))
48
+ }
49
+ ]
50
+ };
51
+ }
52
+ function buildPrivacyDisallowedListResult(iq, category, jids) {
53
+ const result = (0, router_1.buildIqResult)(iq);
54
+ return {
55
+ ...result,
56
+ content: [
57
+ {
58
+ tag: 'privacy',
59
+ attrs: {},
60
+ content: [
61
+ {
62
+ tag: 'list',
63
+ attrs: {
64
+ name: category,
65
+ value: 'contact_blacklist',
66
+ dhash: 'fake-dhash'
67
+ },
68
+ content: jids.map((jid) => ({
69
+ tag: 'user',
70
+ attrs: { jid }
71
+ }))
72
+ }
73
+ ]
74
+ }
75
+ ]
76
+ };
77
+ }
78
+ function buildBlocklistResult(iq, jids) {
79
+ const result = (0, router_1.buildIqResult)(iq);
80
+ return {
81
+ ...result,
82
+ content: [
83
+ {
84
+ tag: 'list',
85
+ attrs: { dhash: 'fake-blocklist-dhash' },
86
+ content: jids.map((jid) => ({
87
+ tag: 'item',
88
+ attrs: { jid }
89
+ }))
90
+ }
91
+ ]
92
+ };
93
+ }
94
+ function parsePrivacySetCategoryIq(iq) {
95
+ if (!Array.isArray(iq.content))
96
+ return null;
97
+ const privacy = iq.content.find((child) => child.tag === 'privacy');
98
+ if (!privacy || !Array.isArray(privacy.content))
99
+ return null;
100
+ const category = privacy.content.find((child) => child.tag === 'category');
101
+ if (!category)
102
+ return null;
103
+ const name = category.attrs.name;
104
+ const value = category.attrs.value;
105
+ if (!name || !value)
106
+ return null;
107
+ return { category: name, value };
108
+ }
109
+ function parseBlocklistChangeIq(iq) {
110
+ if (!Array.isArray(iq.content))
111
+ return null;
112
+ const item = iq.content.find((child) => child.tag === 'item');
113
+ if (!item)
114
+ return null;
115
+ const jid = item.attrs.jid;
116
+ const action = item.attrs.action;
117
+ if (!jid || (action !== 'block' && action !== 'unblock'))
118
+ return null;
119
+ return { jid, action };
120
+ }
121
+ function parsePrivacyDisallowedListGetIq(iq) {
122
+ if (!Array.isArray(iq.content))
123
+ return null;
124
+ const privacy = iq.content.find((child) => child.tag === 'privacy');
125
+ if (!privacy || !Array.isArray(privacy.content))
126
+ return null;
127
+ const list = privacy.content.find((child) => child.tag === 'list');
128
+ if (!list)
129
+ return null;
130
+ const name = list.attrs.name;
131
+ return name ?? null;
132
+ }
133
+ //# sourceMappingURL=privacy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"privacy.js","sourceRoot":"","sources":["../../../src/protocol/iq/privacy.ts"],"names":[],"mappings":";AAAA,0DAA0D;;;AAiD1D,gEAkBC;AAED,4EA6BC;AAED,oDAeC;AAED,8DAaC;AAED,wDAWC;AAED,0EAQC;AArJD,qCAAwC;AAoB3B,QAAA,6BAA6B,GAA6B;IACnE,QAAQ,EAAE;QACN,YAAY,EAAE,KAAK;QACnB,IAAI,EAAE,KAAK;QACX,MAAM,EAAE,KAAK;QACb,OAAO,EAAE,KAAK;QACd,MAAM,EAAE,UAAU;QAClB,QAAQ,EAAE,KAAK;QACf,OAAO,EAAE,KAAK;QACd,QAAQ,EAAE,KAAK;QACf,OAAO,EAAE,KAAK;KACjB;IACD,UAAU,EAAE;QACR,YAAY,EAAE,EAAE;QAChB,IAAI,EAAE,EAAE;QACR,MAAM,EAAE,EAAE;QACV,OAAO,EAAE,EAAE;QACX,MAAM,EAAE,EAAE;QACV,QAAQ,EAAE,EAAE;QACZ,OAAO,EAAE,EAAE;QACX,QAAQ,EAAE,EAAE;QACZ,OAAO,EAAE,EAAE;KACd;CACJ,CAAA;AAED,SAAgB,0BAA0B,CACtC,EAAc,EACd,KAA+B;IAE/B,MAAM,MAAM,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E,CAAC,KAAK,CAAC,GAAG,KAAK,MAAM,CAAC,CAAA;IAC7D,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAA;IACtB,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAA;IAC1B,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAA;IAChC,IAAI,CAAC,GAAG,IAAI,CAAC,MAAM,KAAK,OAAO,IAAI,MAAM,KAAK,SAAS,CAAC;QAAE,OAAO,IAAI,CAAA;IACrE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,CAAA;AAC1B,CAAC;AAED,SAAgB,+BAA+B,CAAC,EAAc;IAC1D,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,OAAO,CAAC;QAAE,OAAO,IAAI,CAAA;IAC3C,MAAM,OAAO,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,KAAK,SAAS,CAAC,CAAA;IACnE,IAAI,CAAC,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC;QAAE,OAAO,IAAI,CAAA;IAC5D,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,KAAiB,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,KAAK,MAAM,CAAC,CAAA;IAC9E,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAA;IACtB,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAA2C,CAAA;IACnE,OAAO,IAAI,IAAI,IAAI,CAAA;AACvB,CAAC"}
@@ -0,0 +1,22 @@
1
+ /** Builders/parsers for profile picture and status IQs. */
2
+ import type { BinaryNode } from '../../transport/codec';
3
+ export interface FakeProfilePictureResult {
4
+ readonly url?: string;
5
+ readonly directPath?: string;
6
+ readonly id?: string;
7
+ readonly type?: 'image' | 'preview';
8
+ }
9
+ export declare function buildGetProfilePictureResult(iq: BinaryNode, picture: FakeProfilePictureResult): BinaryNode;
10
+ export declare function buildSetProfilePictureResult(iq: BinaryNode, newId: string): BinaryNode;
11
+ export declare function parseGetProfilePictureIq(iq: BinaryNode): {
12
+ readonly targetJid: string;
13
+ readonly type: 'image' | 'preview';
14
+ } | null;
15
+ export declare function parseSetProfilePictureIq(iq: BinaryNode): {
16
+ readonly targetJid: string | undefined;
17
+ readonly imageBytes: Uint8Array;
18
+ } | null;
19
+ export declare function parseSetStatusIq(iq: BinaryNode): {
20
+ readonly text: string;
21
+ } | null;
22
+ //# sourceMappingURL=profile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"profile.d.ts","sourceRoot":"","sources":["../../../src/protocol/iq/profile.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAE3D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAIvD,MAAM,WAAW,wBAAwB;IACrC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;CACtC;AAED,wBAAgB,4BAA4B,CACxC,EAAE,EAAE,UAAU,EACd,OAAO,EAAE,wBAAwB,GAClC,UAAU,CAgBZ;AAED,wBAAgB,4BAA4B,CAAC,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU,CAWtF;AAED,wBAAgB,wBAAwB,CAAC,EAAE,EAAE,UAAU,GAAG;IACtD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,SAAS,CAAA;CACrC,GAAG,IAAI,CAWP;AAED,wBAAgB,wBAAwB,CAAC,EAAE,EAAE,UAAU,GAAG;IACtD,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAA;IACtC,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAA;CAClC,GAAG,IAAI,CAQP;AAED,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,UAAU,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CASjF"}
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ /** Builders/parsers for profile picture and status IQs. */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.buildGetProfilePictureResult = buildGetProfilePictureResult;
5
+ exports.buildSetProfilePictureResult = buildSetProfilePictureResult;
6
+ exports.parseGetProfilePictureIq = parseGetProfilePictureIq;
7
+ exports.parseSetProfilePictureIq = parseSetProfilePictureIq;
8
+ exports.parseSetStatusIq = parseSetStatusIq;
9
+ const router_1 = require("./router");
10
+ function buildGetProfilePictureResult(iq, picture) {
11
+ const attrs = {};
12
+ if (picture.url)
13
+ attrs.url = picture.url;
14
+ if (picture.directPath)
15
+ attrs.direct_path = picture.directPath;
16
+ if (picture.id)
17
+ attrs.id = picture.id;
18
+ if (picture.type)
19
+ attrs.type = picture.type;
20
+ const result = (0, router_1.buildIqResult)(iq);
21
+ return {
22
+ ...result,
23
+ content: [
24
+ {
25
+ tag: 'picture',
26
+ attrs
27
+ }
28
+ ]
29
+ };
30
+ }
31
+ function buildSetProfilePictureResult(iq, newId) {
32
+ const result = (0, router_1.buildIqResult)(iq);
33
+ return {
34
+ ...result,
35
+ content: [
36
+ {
37
+ tag: 'picture',
38
+ attrs: { id: newId }
39
+ }
40
+ ]
41
+ };
42
+ }
43
+ function parseGetProfilePictureIq(iq) {
44
+ const targetJid = iq.attrs.target;
45
+ if (!targetJid)
46
+ return null;
47
+ let type = 'preview';
48
+ if (Array.isArray(iq.content)) {
49
+ const picture = iq.content.find((child) => child.tag === 'picture');
50
+ if (picture && picture.attrs.type === 'image') {
51
+ type = 'image';
52
+ }
53
+ }
54
+ return { targetJid, type };
55
+ }
56
+ function parseSetProfilePictureIq(iq) {
57
+ if (!Array.isArray(iq.content))
58
+ return null;
59
+ const picture = iq.content.find((child) => child.tag === 'picture');
60
+ if (!picture || !(picture.content instanceof Uint8Array))
61
+ return null;
62
+ return {
63
+ targetJid: iq.attrs.target,
64
+ imageBytes: picture.content
65
+ };
66
+ }
67
+ function parseSetStatusIq(iq) {
68
+ if (!Array.isArray(iq.content))
69
+ return null;
70
+ const status = iq.content.find((child) => child.tag === 'status');
71
+ if (!status)
72
+ return null;
73
+ if (typeof status.content === 'string')
74
+ return { text: status.content };
75
+ if (status.content instanceof Uint8Array) {
76
+ return { text: new TextDecoder().decode(status.content) };
77
+ }
78
+ return { text: '' };
79
+ }
80
+ //# sourceMappingURL=profile.js.map