@vinikjkkj/wa-proto 0.1.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/README.md +61 -0
- package/dist/index.d.ts +75580 -0
- package/dist/index.js +246250 -0
- package/package.json +63 -0
package/README.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# @vinikjkkj/wa-proto
|
|
2
|
+
|
|
3
|
+
WhatsApp Web protobuf definitions — daily-extracted SDL + compiled
|
|
4
|
+
JS/TS bindings (via [protobufjs](https://github.com/protobufjs/protobuf.js)).
|
|
5
|
+
|
|
6
|
+
```sh
|
|
7
|
+
npm i @vinikjkkj/wa-proto
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
import { waproto } from '@vinikjkkj/wa-proto'
|
|
12
|
+
|
|
13
|
+
const msg = waproto.Message.create({ conversation: 'hi' })
|
|
14
|
+
const bytes = waproto.Message.encode(msg).finish()
|
|
15
|
+
const parsed = waproto.Message.decode(bytes)
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## What's exported
|
|
19
|
+
|
|
20
|
+
- `WAProto.proto` — single proto3 SDL file with every message + enum
|
|
21
|
+
- `dist/index.js` — protobufjs `static-module` output (CommonJS, no parser at runtime)
|
|
22
|
+
- `dist/index.d.ts` — TypeScript declarations matching the JS module
|
|
23
|
+
|
|
24
|
+
All messages live under `package waproto`; nested messages and enums are
|
|
25
|
+
declared inside their parent. Field labels are `optional` (proto3 field
|
|
26
|
+
presence) or `repeated` (with `[packed=true]` when the runtime flag was set).
|
|
27
|
+
|
|
28
|
+
## Generate locally
|
|
29
|
+
|
|
30
|
+
```sh
|
|
31
|
+
npx wa-fetcher --out dump/ # download raw bundles
|
|
32
|
+
npx wa-proto apply --bundles dump/raw/<version>/ # extract → WAProto.proto
|
|
33
|
+
npm run compile --workspace @vinikjkkj/wa-proto # pbjs/pbts → dist/
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## How extraction works (no deps, no runtime)
|
|
37
|
+
|
|
38
|
+
1. Scan every `__d("WAWebProtobufsX.pb", ...)` registration in the bundle texts
|
|
39
|
+
2. Within each factory body, identify aliases for `$InternalEnum` and `WAProtoConst`
|
|
40
|
+
3. Parse local-var bindings:
|
|
41
|
+
- `var X = s({KEY:0, ...})` — enum literal (where `s` is the InternalEnum alias)
|
|
42
|
+
- `var Y = {}; Y.name = "Foo"; Y.internalSpec = {...}` — message definition
|
|
43
|
+
4. Parse each field descriptor `[tag, typeExpression, ref?]` and decode the
|
|
44
|
+
type byte (low 6 bits = primitive, bit 64 = REPEATED, bit 128 = PACKED, bit 256 = REQUIRED)
|
|
45
|
+
5. Resolve refs across modules via the dep array + `<alias>.<ExportKey>` syntax
|
|
46
|
+
6. Emit `WAProto.proto` proto3 SDL with nested messages/enums under their parent
|
|
47
|
+
|
|
48
|
+
## Caveats
|
|
49
|
+
|
|
50
|
+
- **Some cross-module refs may be unresolved** if the referenced `.pb` module
|
|
51
|
+
isn't loaded in the bundle dump (lazy-loaded chunks). These surface as
|
|
52
|
+
`UNKNOWN` types in the output — refresh the dump with full auth state to
|
|
53
|
+
catch them.
|
|
54
|
+
- **Numbers use `long`** — `protobufjs` returns `Long` instances for `int64` /
|
|
55
|
+
`uint64` etc. Make sure to install `long` (already a dep here) and either
|
|
56
|
+
`.toNumber()` (lossy for >2^53) or `.toString()`.
|
|
57
|
+
- **Format matches [`@wppconnect/wa-proto`](https://github.com/wppconnect-team/wa-proto)**
|
|
58
|
+
for drop-in compatibility — same `package waproto`, same proto3 syntax,
|
|
59
|
+
same `pbjs`/`pbts` toolchain.
|
|
60
|
+
|
|
61
|
+
Daily-extracted by [wa-spec](https://github.com/vinikjkkj/wa-spec).
|