constants.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // Copyright (c) 2021 Tulir Asokan
  2. //
  3. // This Source Code Form is subject to the terms of the Mozilla Public
  4. // License, v. 2.0. If a copy of the MPL was not distributed with this
  5. // file, You can obtain one at http://mozilla.org/MPL/2.0/.
  6. // Package socket implements a subset of the Noise protocol framework on top of websockets as used by WhatsApp.
  7. //
  8. // There shouldn't be any need to manually interact with this package.
  9. // The Client struct in the top-level whatsmeow package handles everything.
  10. package socket
  11. import (
  12. "errors"
  13. "go.mau.fi/whatsmeow/binary/token"
  14. )
  15. const (
  16. // Origin is the Origin header for all WhatsApp websocket connections
  17. Origin = "https://web.whatsapp.com"
  18. // URL is the websocket URL for the new multidevice protocol
  19. URL = "wss://web.whatsapp.com/ws/chat"
  20. )
  21. const (
  22. NoiseStartPattern = "Noise_XX_25519_AESGCM_SHA256\x00\x00\x00\x00"
  23. WAMagicValue = 6
  24. )
  25. var WAConnHeader = []byte{'W', 'A', WAMagicValue, token.DictVersion}
  26. const (
  27. FrameMaxSize = 1 << 24
  28. FrameLengthSize = 3
  29. )
  30. var (
  31. ErrFrameTooLarge = errors.New("frame too large")
  32. ErrSocketClosed = errors.New("frame socket is closed")
  33. ErrSocketAlreadyOpen = errors.New("frame socket is already open")
  34. )
  35. type ErrWithStatusCode struct {
  36. error
  37. StatusCode int
  38. }