@oxidezap/whatsapp-rust-bridge 0.22.0 → 0.23.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.d.ts ADDED
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Host-loaded entrypoint: same bridge, host-supplied WebAssembly.
3
+ *
4
+ * The default entrypoint (`ts/index.ts`) reads `whatsapp_rust_bridge_bg.wasm`
5
+ * off disk with `node:fs`, which does not exist on some hosts (workerd has no
6
+ * `node:fs` at all; others forbid filesystem reads). This module is identical
7
+ * except for how the wasm arrives: the host imports it with whatever its
8
+ * platform provides and passes it to wasm-bindgen's `initSync`:
9
+ *
10
+ * ```ts
11
+ * // Cloudflare Workers / workerd (static wasm import yields a Module)
12
+ * import wasmModule from "@oxidezap/whatsapp-rust-bridge/wasm";
13
+ * import { initSync } from "@oxidezap/whatsapp-rust-bridge/host";
14
+ * initSync({ module: wasmModule });
15
+ *
16
+ * // Deno (bytes; needs --unstable-raw-imports or a readFile)
17
+ * import wasmBytes from "./whatsapp_rust_bridge_bg.wasm" with { type: "bytes" };
18
+ * import { initSync } from "@oxidezap/whatsapp-rust-bridge/host";
19
+ * initSync({ module: wasmBytes });
20
+ *
21
+ * // Node/Bun without the filesystem read
22
+ * import { readFileSync } from "node:fs";
23
+ * import { initSync } from "@oxidezap/whatsapp-rust-bridge/host";
24
+ * initSync({ module: readFileSync("./whatsapp_rust_bridge_bg.wasm") });
25
+ * ```
26
+ *
27
+ * Why one entrypoint covers every host: `initSync` accepts either a compiled
28
+ * `WebAssembly.Module` or raw bytes (`SyncInitInput`), and the host idioms
29
+ * produce exactly those — workerd/wrangler static imports compile to a
30
+ * `WebAssembly.Module`, Deno/raw-import and bundler `?module` styles produce
31
+ * bytes. There is no workerd-only path because workerd needs nothing this
32
+ * module does not take.
33
+ *
34
+ * Two constraints the host must respect, both from the platform, not the bridge:
35
+ * call `initSync` once per isolate (a second call is a no-op returning the
36
+ * existing instance), and create clients inside a request handler, not at
37
+ * global scope — `crypto.getRandomValues` is unavailable during global-scope
38
+ * evaluation on workerd, so client creation (uuid generation) panics there.
39
+ */
40
+ export * from "./surface.js";
41
+ export { initSync } from "./whatsapp_rust_bridge.js";
package/dist/host.js ADDED
@@ -0,0 +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};
package/dist/index.d.ts CHANGED
@@ -1,9 +1 @@
1
- export * from "./whatsapp_rust_bridge.js";
2
- export { encodeProto, decodeProto, decodeProtoBatch, UnpairedSurrogateError, type ProtoDecodeReport, } from "./proto.js";
3
- export { BinaryReader, InvalidUtf8CountingReader, longToBigInt, type Int64, type Long, } from "./proto-reader.js";
4
- export { decodeEventWireEnvelope, decodeMessageWireBatch, decodeReceiptWireBatch, decodeServerAckWireBatch, encodeEventWireEnvelope, encodeMessageWireBatch, encodeReceiptWireBatch, encodeServerAckWireBatch, EVENT_SEGMENT_KIND_MESSAGE, EVENT_SEGMENT_KIND_RECEIPT, EVENT_SEGMENT_KIND_SERVER_ACK, MESSAGE_WIRE_INFO_RECORD_WIDTH, type EventWireSegment, type MessageWireBatchView, type MessageWireEntry, type MessageWireInfo, type PackedWireBatch, type ReceiptWireData, type ServerAckWireData, type WireJid, } from "./wire-info.js";
5
- export { proto } from "./proto-namespace.js";
6
- import type { WhatsAppEventHandler, JsTransportCallbacks, JsHttpClientConfig, JsStoreCallbacks, CacheConfig, ClientPolicies } from "./whatsapp_rust_bridge.js";
7
- import type { WasmWhatsAppClient } from "./whatsapp_rust_bridge.js";
8
- export declare const initWasmEngine: (logger?: any, crypto?: any) => void;
9
- 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>;
1
+ export * from "./surface.js";