This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
A Matrix bridge for LINE Messenger using mautrix-go (bridgev2). It bridges messages between Matrix clients and LINE, supporting both Letter Sealing ON (E2EE) and OFF accounts.
The bridge identifies as a LINE Chrome Extension client, so it cannot coexist with an actual Chrome Extension session.
Requirements: Go 1.25+, libolm (libolm-dev on Ubuntu, olm via Homebrew on macOS)
Build:
./build.shRun:
cd data && ../matrix-lineDocker:
docker compose up --buildFormatting/Linting (via pre-commit):
go fmt ./...
goimports -local "github.com/highesttt/matrix-line-messenger" -w .
staticcheck $(go list ./... | grep -v /ltsm)
go vet $(go list ./... | grep -v /ltsm)Note: staticcheck and go vet exclude the pkg/ltsm package (transpiled WASM code). Imports must use -local flag to group project-local imports correctly.
Matrix Client <-> mautrix bridgev2 framework <-> LineConnector/LineClient <-> LINE API
cmd/matrix-line/— Entry point, usesmautrix.BridgeMainpkg/connector/— Bridge logic implementingbridgev2.NetworkConnectorandbridgev2.NetworkAPIconnector.go—LineConnector: bridge initialization, login flow managementclient.go—LineClient: token management, polling, message routinghandle_message.go/send_message.go— Inbound/outbound message conversione2ee_keys.go— Peer key negotiation and group key fetchingmedia.go— Media upload/download with E2EE supportsync.go— Chat prefetching and long-poll event loop
pkg/line/— HTTP client for LINE's Thrift-based APIclient.go/methods.go— API calls (login, messaging, contacts, groups)sse.go— Server-sent events for long-pollingpassword/— RSA password encryption for loginsecret/— E2EE secret generation for login handshake
pkg/e2ee/— E2EE encryption/decryption manager wrapping the LTSM runtimepkg/ltsm/— Transpiled WASM module for LINE's white-box crypto (do not editwbc_generated.go)
Two login paths exist:
- LSON (type 2): Full E2EE — generates keypair, exchanges encrypted keychain, enables Curve25519-based message encryption
- LSOFF (type 0): Fallback when LINE error 89 indicates E2EE not supported
Message encryption is hybrid:
- Pure Go Curve25519 for known key material
- WASM-transpiled white-box crypto for SKB-wrapped keys
- V1 (AES-256-CBC + MAC) and V2 encryption schemes
- Graceful fallback to plaintext when peer/group doesn't support E2EE
LineClient implements proactive token refresh based on server-provided duration, with automatic recovery on expiry (refresh token -> re-authentication). Token expiry is detected via LINE error codes 119 and 10051.
Uses zerolog. Pre-commit hooks enforce: no Msgf (use Msg with structured fields), use Stringer interface where applicable.