@vinikjkkj/wa-proto
v2.3000.1040547457-810620
Published
WhatsApp Web protobuf message bindings — pbjs/pbts compiled from daily-extracted SDL.
Maintainers
Readme
@vinikjkkj/wa-proto
WhatsApp Web protobuf definitions — daily-extracted SDL + compiled JS/TS bindings (via protobufjs).
npm i @vinikjkkj/wa-protoimport { waproto } from '@vinikjkkj/wa-proto'
const msg = waproto.Message.create({ conversation: 'hi' })
const bytes = waproto.Message.encode(msg).finish()
const parsed = waproto.Message.decode(bytes)What's exported
WAProto.proto— single proto3 SDL file with every message + enumdist/index.js— protobufjsstatic-moduleoutput (CommonJS, no parser at runtime)dist/index.d.ts— TypeScript declarations matching the JS module
All messages live under package waproto; nested messages and enums are
declared inside their parent. Field labels are optional (proto3 field
presence) or repeated (with [packed=true] when the runtime flag was set).
Generate locally
npx wa-fetcher --out dump/ # download raw bundles
npx wa-proto apply --bundles dump/raw/<version>/ # extract → WAProto.proto
npm run compile --workspace @vinikjkkj/wa-proto # pbjs/pbts → dist/How extraction works (no deps, no runtime)
- Scan every
__d("WAWebProtobufsX.pb", ...)registration in the bundle texts - Within each factory body, identify aliases for
$InternalEnumandWAProtoConst - Parse local-var bindings:
var X = s({KEY:0, ...})— enum literal (wheresis the InternalEnum alias)var Y = {}; Y.name = "Foo"; Y.internalSpec = {...}— message definition
- Parse each field descriptor
[tag, typeExpression, ref?]and decode the type byte (low 6 bits = primitive, bit 64 = REPEATED, bit 128 = PACKED, bit 256 = REQUIRED) - Resolve refs across modules via the dep array +
<alias>.<ExportKey>syntax - Emit
WAProto.protoproto3 SDL with nested messages/enums under their parent
Caveats
- Some cross-module refs may be unresolved if the referenced
.pbmodule isn't loaded in the bundle dump (lazy-loaded chunks). These surface asint32(enum) /bytes(message) fallbacks — wire-compatible, but the named type is lost until the dump catches up. - Numbers use
long—protobufjsreturnsLonginstances forint64/uint64etc. Make sure to installlong(already a dep here) and either.toNumber()(lossy for >2^53) or.toString(). - Format matches
@wppconnect/wa-protofor drop-in compatibility — samepackage waproto, same proto3 syntax, samepbjs/pbtstoolchain.
Daily-extracted by wa-spec.
