@oxidezap/whatsapp-rust-bridge 0.23.0 → 0.24.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.
package/dist/host.js CHANGED
@@ -1 +1 @@
1
- import{A as B,B as F,C as D,D as e,E as I,F as q,G as C,H,I as N,J as R,K as V,L as j,M as E,N as G,O as J,P as K,Q as L,R as O,S as P,T as Q,U,V as X,W as Y,X as Z,Y as $,Z as ee,a as i,b as r,c as a,d as n,e as d,f as p,g as l,h as m,i as h,j as c,k as u,l as w,m as y,n as b,o as f,p as g,q as S,r as x,s as k,t as _,u as v,v as M,w as W,x as z,y as T,z as A}from"./bridge.js";export{D as verifySignature,F as updateLogger,B as setLogger,Z as proto,A as projectLegacySessionRecordV1,T as md5,q as longToBigInt,z as logMessage,$ as initWasmEngine,e as initSync,W as inflateZlib,M as importLegacySessionRecordV1,v as hkdf,_ as hasLogger,k as getWasmMemoryBytes,x as getWasmAllocationSnapshot,S as getPublicFromPrivateKey,g as getEnabledFeatures,f as generateKeyPair,b as encodeSessionRecordComponents,O as encodeServerAckWireBatch,y as encodeSenderKeyRecordComponents,L as encodeReceiptWireBatch,N as encodeProto,G as encodeMessageWireBatch,Y as encodeEventWireEnvelope,w as decryptPollVotePayload,u as decryptPollVote,c as decryptEventResponsePayload,h as decodeSessionRecordComponents,K as decodeServerAckWireBatch,m as decodeSenderKeyRecordComponents,J as decodeReceiptWireBatch,V as decodeProtoBatch,R as decodeProto,E as decodeMessageWireBatch,X as decodeEventWireEnvelope,ee as createWhatsAppClient,l as calculateSignature,p as calculateAgreement,d as beginWasmAllocationProfile,n as WasmWhatsAppClient,I as UnpairedSurrogateError,j as MESSAGE_WIRE_INFO_RECORD_WIDTH,H as InvalidUtf8CountingReader,a as IntoUnderlyingSource,r as IntoUnderlyingSink,i as IntoUnderlyingByteSource,U as EVENT_SEGMENT_KIND_SERVER_ACK,Q as EVENT_SEGMENT_KIND_RECEIPT,P as EVENT_SEGMENT_KIND_MESSAGE,C as BinaryReader};
1
+ import{$ as oe,A as B,B as F,C as D,D as I,E as q,F as C,G as e,H,I as N,J as R,K as V,L as j,M as E,N as G,O as J,P as K,Q as L,R as O,S as P,T as Q,U,V as X,W as Y,X as Z,Y as $,Z as ee,_ as te,a as i,aa as se,b as r,c as a,d as n,e as d,f as p,g as l,h as m,i as h,j as c,k as u,l as w,m as y,n as b,o as f,p as g,q as S,r as x,s as k,t as _,u as v,v as M,w as W,x as z,y as T,z as A}from"./bridge.js";export{C as verifySignature,q as updateLogger,I as sha256,D as setLogger,te as proto,F as projectLegacySessionRecordV1,B as md5,N as longToBigInt,A as logMessage,oe as initWasmEngine,e as initSync,T as inflateZlib,z as importLegacySessionRecordV1,W as hkdf,M as hasLogger,v as getWasmMemoryBytes,_ as getWasmAllocationSnapshot,k as getPublicFromPrivateKey,x as getEnabledFeatures,S as generateKeyPair,g as encodeSessionRecordComponents,U as encodeServerAckWireBatch,f as encodeSenderKeyRecordComponents,Q as encodeReceiptWireBatch,j as encodeProto,L as encodeMessageWireBatch,ee as encodeEventWireEnvelope,b as decryptPollVotePayload,y as decryptPollVote,w as decryptEventResponsePayload,u as decodeSessionRecordComponents,P as decodeServerAckWireBatch,c as decodeSenderKeyRecordComponents,O as decodeReceiptWireBatch,G as decodeProtoBatch,E as decodeProto,K as decodeMessageWireBatch,$ as decodeEventWireEnvelope,se as createWhatsAppClient,h as calculateSignature,m as calculateAgreement,l as beginWasmAllocationProfile,p as aesGcm256Encrypt,d as aesGcm256Decrypt,n as WasmWhatsAppClient,H as UnpairedSurrogateError,J as MESSAGE_WIRE_INFO_RECORD_WIDTH,V as InvalidUtf8CountingReader,a as IntoUnderlyingSource,r as IntoUnderlyingSink,i as IntoUnderlyingByteSource,Z as EVENT_SEGMENT_KIND_SERVER_ACK,Y as EVENT_SEGMENT_KIND_RECEIPT,X as EVENT_SEGMENT_KIND_MESSAGE,R as BinaryReader};
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{A as g,B as u,C as S,D as q,E as _,F as c,G as h,H as l,I as m,J as o,K as y,L as d,M as p,N as w,O as i,P as n,Q as r,R as a,S as t,T as e,U as s,V as qq,W as vq,X as zq,Y as Aq,Z as Cq,a as H,b as I,c as J,d as K,e as L,f as M,g as N,h as O,i as P,j as Q,k as R,l as T,m as V,n as W,o as X,p as Y,q as Z,r as $,s as b,t as j,u as k,v as x,w as B,x as F,y as U,z as f}from"./bridge.js";import{readFileSync as v}from"node:fs";var z=new URL("whatsapp_rust_bridge_bg.wasm",import.meta.url),A=v(z);q({module:A});export{S as verifySignature,u as updateLogger,g as setLogger,zq as proto,f as projectLegacySessionRecordV1,U as md5,c as longToBigInt,F as logMessage,Aq as initWasmEngine,q as initSync,B as inflateZlib,x as importLegacySessionRecordV1,k as hkdf,j as hasLogger,b as getWasmMemoryBytes,$ as getWasmAllocationSnapshot,Z as getPublicFromPrivateKey,Y as getEnabledFeatures,X as generateKeyPair,W as encodeSessionRecordComponents,a as encodeServerAckWireBatch,V as encodeSenderKeyRecordComponents,r as encodeReceiptWireBatch,m as encodeProto,w as encodeMessageWireBatch,vq as encodeEventWireEnvelope,T as decryptPollVotePayload,R as decryptPollVote,Q as decryptEventResponsePayload,P as decodeSessionRecordComponents,n as decodeServerAckWireBatch,O as decodeSenderKeyRecordComponents,i as decodeReceiptWireBatch,y as decodeProtoBatch,o as decodeProto,p as decodeMessageWireBatch,qq as decodeEventWireEnvelope,Cq as createWhatsAppClient,N as calculateSignature,M as calculateAgreement,L as beginWasmAllocationProfile,K as WasmWhatsAppClient,_ as UnpairedSurrogateError,d as MESSAGE_WIRE_INFO_RECORD_WIDTH,l as InvalidUtf8CountingReader,J as IntoUnderlyingSource,I as IntoUnderlyingSink,H as IntoUnderlyingByteSource,s as EVENT_SEGMENT_KIND_SERVER_ACK,e as EVENT_SEGMENT_KIND_RECEIPT,t as EVENT_SEGMENT_KIND_MESSAGE,h as BinaryReader};
1
+ import{$ as Eq,A as g,B as u,C as S,D as _,E as c,F as h,G as q,H as l,I as m,J as o,K as y,L as d,M as p,N as w,O as i,P as n,Q as r,R as a,S as t,T as e,U as s,V as qq,W as vq,X as zq,Y as Aq,Z as Cq,_ as Dq,a as H,aa as Gq,b as I,c as J,d as K,e as L,f as M,g as N,h as O,i as P,j as Q,k as R,l as T,m as V,n as W,o as X,p as Y,q as Z,r as $,s as b,t as j,u as k,v as x,w as B,x as F,y as U,z as f}from"./bridge.js";import{readFileSync as v}from"node:fs";var z=new URL("whatsapp_rust_bridge_bg.wasm",import.meta.url),A=v(z);q({module:A});export{h as verifySignature,c as updateLogger,_ as sha256,S as setLogger,Dq as proto,u as projectLegacySessionRecordV1,g as md5,m as longToBigInt,f as logMessage,Eq as initWasmEngine,q as initSync,U as inflateZlib,F as importLegacySessionRecordV1,B as hkdf,x as hasLogger,k as getWasmMemoryBytes,j as getWasmAllocationSnapshot,b as getPublicFromPrivateKey,$ as getEnabledFeatures,Z as generateKeyPair,Y as encodeSessionRecordComponents,s as encodeServerAckWireBatch,X as encodeSenderKeyRecordComponents,e as encodeReceiptWireBatch,d as encodeProto,r as encodeMessageWireBatch,Cq as encodeEventWireEnvelope,W as decryptPollVotePayload,V as decryptPollVote,T as decryptEventResponsePayload,R as decodeSessionRecordComponents,t as decodeServerAckWireBatch,Q as decodeSenderKeyRecordComponents,a as decodeReceiptWireBatch,w as decodeProtoBatch,p as decodeProto,n as decodeMessageWireBatch,Aq as decodeEventWireEnvelope,Gq as createWhatsAppClient,P as calculateSignature,O as calculateAgreement,N as beginWasmAllocationProfile,M as aesGcm256Encrypt,L as aesGcm256Decrypt,K as WasmWhatsAppClient,l as UnpairedSurrogateError,i as MESSAGE_WIRE_INFO_RECORD_WIDTH,y as InvalidUtf8CountingReader,J as IntoUnderlyingSource,I as IntoUnderlyingSink,H as IntoUnderlyingByteSource,zq as EVENT_SEGMENT_KIND_SERVER_ACK,vq as EVENT_SEGMENT_KIND_RECEIPT,qq as EVENT_SEGMENT_KIND_MESSAGE,o as BinaryReader};
package/dist/surface.d.ts CHANGED
@@ -14,4 +14,9 @@ export { proto } from "./proto-namespace.js";
14
14
  import type { WhatsAppEventHandler, JsTransportCallbacks, JsHttpClientConfig, JsStoreCallbacks, CacheConfig, ClientPolicies } from "./whatsapp_rust_bridge.js";
15
15
  import type { WasmWhatsAppClient } from "./whatsapp_rust_bridge.js";
16
16
  export declare const initWasmEngine: (logger?: any, crypto?: any) => void;
17
+ /**
18
+ * The factory promise is the initialization barrier. Once it resolves,
19
+ * persistence, adapters, and the core client are ready; it does not imply a
20
+ * socket, authentication, a started run loop, or completed history sync.
21
+ */
17
22
  export declare const createWhatsAppClient: (transport: JsTransportCallbacks, httpClient: JsHttpClientConfig, onEvent?: WhatsAppEventHandler | null, store?: JsStoreCallbacks | null, cache?: CacheConfig | null, version?: readonly [number, number, number] | null, wantedPreKeyCount?: number | null, dangerSkipCertChainVerify?: boolean | null, policies?: ClientPolicies | null) => Promise<WasmWhatsAppClient>;
@@ -44,10 +44,9 @@ export interface JsTransportHandle {
44
44
 
45
45
  /**
46
46
  * Every Promise handed back to the bridge must settle, including on failure:
47
- * reject rather than leaving it pending. The bridge awaits it through a
48
- * wasm-bindgen `JsFuture`, whose resolve/reject pair is only released when the
49
- * promise settles, so a promise that never settles retains two JS handles for
50
- * the life of the process.
47
+ * reject rather than leaving it pending. The bridge awaits them through a
48
+ * wasm-bindgen `JsFuture`; an overlapping teardown cancels only the wait that
49
+ * would otherwise form a callback/teardown cycle.
51
50
  */
52
51
  export interface JsTransportCallbacks {
53
52
  connect(handle: JsTransportHandle): void | Promise<void>;
@@ -3768,6 +3767,13 @@ export class WasmWhatsAppClient {
3768
3767
  deleteQuickReply(id: string): Promise<void>;
3769
3768
  /**
3770
3769
  * Disconnect the client and flush pending state to storage.
3770
+ *
3771
+ * This is an explicit teardown barrier: the promise does not resolve until
3772
+ * the core has flushed persistence and the bridge-owned background tasks
3773
+ * have been stopped. The shared gate makes concurrent `disconnect()` and
3774
+ * `logout()` calls idempotent instead of entering the core teardown paths
3775
+ * together. If a host disconnect callback re-enters teardown, the callback
3776
+ * wait is cancelled so the two teardown operations cannot wait on each other.
3771
3777
  */
3772
3778
  disconnect(): Promise<void>;
3773
3779
  /**
@@ -4704,6 +4710,17 @@ export class WasmWhatsAppClient {
4704
4710
  withdrawParkedCalls(): number;
4705
4711
  }
4706
4712
 
4713
+ /**
4714
+ * Decrypt bytes returned by [`aes_gcm_256_encrypt`].
4715
+ */
4716
+ export function aesGcm256Decrypt(key: Uint8Array, nonce: Uint8Array, aad: Uint8Array, ciphertext_with_tag: Uint8Array): Uint8Array;
4717
+
4718
+ /**
4719
+ * Encrypt with the active signal crypto provider. The returned bytes are
4720
+ * `ciphertext || authentication tag`.
4721
+ */
4722
+ export function aesGcm256Encrypt(key: Uint8Array, nonce: Uint8Array, aad: Uint8Array, plaintext: Uint8Array): Uint8Array;
4723
+
4707
4724
  /**
4708
4725
  * Start a new peak-observation window without disturbing live/cumulative
4709
4726
  * counters. The benchmark harness calls this immediately before constructing
@@ -4777,6 +4794,11 @@ export function projectLegacySessionRecordV1(bytes: Uint8Array): LegacySessionPr
4777
4794
 
4778
4795
  export function setLogger(logger: ILogger): void;
4779
4796
 
4797
+ /**
4798
+ * Hash arbitrary bytes with SHA-256.
4799
+ */
4800
+ export function sha256(input: Uint8Array): Uint8Array;
4801
+
4780
4802
  export function updateLogger(logger: ILogger): void;
4781
4803
 
4782
4804
  export function verifySignature(public_key: Uint8Array, message: Uint8Array, signature: Uint8Array): boolean;
@@ -4786,6 +4808,8 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
4786
4808
  export interface InitOutput {
4787
4809
  readonly memory: WebAssembly.Memory;
4788
4810
  readonly __wbg_wasmwhatsappclient_free: (a: number, b: number) => void;
4811
+ readonly aesGcm256Decrypt: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
4812
+ readonly aesGcm256Encrypt: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => void;
4789
4813
  readonly beginWasmAllocationProfile: () => void;
4790
4814
  readonly calculateAgreement: (a: number, b: number, c: number, d: number, e: number) => void;
4791
4815
  readonly calculateSignature: (a: number, b: number, c: number, d: number, e: number) => void;
@@ -4810,6 +4834,7 @@ export interface InitOutput {
4810
4834
  readonly md5: (a: number, b: number) => number;
4811
4835
  readonly projectLegacySessionRecordV1: (a: number, b: number, c: number) => void;
4812
4836
  readonly setLogger: (a: number, b: number) => void;
4837
+ readonly sha256: (a: number, b: number, c: number) => void;
4813
4838
  readonly updateLogger: (a: number) => void;
4814
4839
  readonly verifySignature: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
4815
4840
  readonly wasmwhatsappclient_acknowledgeStanza: (a: number, b: number) => number;
@@ -5005,12 +5030,12 @@ export interface InitOutput {
5005
5030
  readonly intounderlyingsink_write: (a: number, b: number) => number;
5006
5031
  readonly intounderlyingsource_cancel: (a: number) => void;
5007
5032
  readonly intounderlyingsource_pull: (a: number, b: number) => number;
5008
- readonly __wasm_bindgen_func_elem_4671: (a: number, b: number, c: number) => void;
5009
- readonly __wasm_bindgen_func_elem_28645: (a: number, b: number, c: number, d: number) => void;
5010
- readonly __wasm_bindgen_func_elem_28647: (a: number, b: number, c: number, d: number) => void;
5011
- readonly __wasm_bindgen_func_elem_9915: (a: number, b: number, c: number) => void;
5012
- readonly __wasm_bindgen_func_elem_4670: (a: number, b: number, c: number) => void;
5013
- readonly __wasm_bindgen_func_elem_4669: (a: number, b: number) => void;
5033
+ readonly __wasm_bindgen_func_elem_4665: (a: number, b: number, c: number) => void;
5034
+ readonly __wasm_bindgen_func_elem_28635: (a: number, b: number, c: number, d: number) => void;
5035
+ readonly __wasm_bindgen_func_elem_28637: (a: number, b: number, c: number, d: number) => void;
5036
+ readonly __wasm_bindgen_func_elem_9904: (a: number, b: number, c: number) => void;
5037
+ readonly __wasm_bindgen_func_elem_4664: (a: number, b: number, c: number) => void;
5038
+ readonly __wasm_bindgen_func_elem_4663: (a: number, b: number) => void;
5014
5039
  readonly __wbindgen_export: (a: number, b: number) => number;
5015
5040
  readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
5016
5041
  readonly __wbindgen_export3: (a: number) => void;
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oxidezap/whatsapp-rust-bridge",
3
- "version": "0.23.0",
3
+ "version": "0.24.0",
4
4
  "description": "A high-performance utilities for WhatsApp, powered by Rust and WebAssembly.",
5
5
  "author": "João Lucas <jlucaso@hotmail.com>",
6
6
  "license": "MIT",
@@ -38,6 +38,7 @@
38
38
  "scripts": {
39
39
  "bench": "bun run build && bun run benches/binary.ts && bun run benches/signal.ts && bun run benches/curve.ts && bun run benches/crypto.ts",
40
40
  "bench:node": "bun run build && node --expose-gc benches/binary.ts && node --expose-gc benches/signal.ts && node --expose-gc benches/curve.ts && node --expose-gc benches/crypto.ts",
41
+ "bench:crypto": "bun run benches/crypto.ts",
41
42
  "bench:proto": "bun run benches/proto-encode.ts",
42
43
  "bench:wire": "bun run benches/wire-batch-decode.ts",
43
44
  "bench:wire:message": "bun run benches/message-wire-batch.ts",