Product
Socket Now Supports uv.lock Files
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
@project-chip/matter.js
Advanced tools
Implementation of Matter protocol in typescript with no native dependencies (and very limited dependencies).
This is the JavaScript-only Core of the Matter protocol. It is used by other projects to implement Matter Nodes and Clients and add the relevant specific implementations for Network and other elements.
This package supports all Node.js LTS versions starting with 18.x
The following features are abstracted away to allow to be implemented environment specific:
This library exports the Matter protocol functionality as well as some helper functions as named exports:
Export | Description |
---|---|
@project-chip/matter.js | Exports the API to implement a Device or a Controller. |
@project-chip/matter.js/behavior | Exports Behavior classes (New API) as framework to implement all relevant Logic for clusters and internal logic. Contains auto-generated class structures and also Cluster default implementations. |
@project-chip/matter.js/certificate | Exports Certificate (Root-/PAA/PAI/IAC/DA-Certificates) related functionality |
@project-chip/matter.js/cluster | Exports Matter Cluster definitions and Default Cluster-Handlers |
@project-chip/matter.js/codec | Exports Codecs for e.g. Matter-Messages |
@project-chip/matter.js/common | Exports certain common functionalities |
@project-chip/matter.js/crypto | Exports Crypto related abstract functionality that needs to be implemented platform specific! |
@project-chip/matter.js/datatype | Exports Matter Data types |
@project-chip/matter.js/device | Exports Matter Device relevant classes (Legacy API!) |
@project-chip/matter.js/devices | Exports Matter Device type classes (NEW API!) |
@project-chip/matter.js/endpoint | Exports Matter Endpoint structure classes (NEW API!) |
@project-chip/matter-.js/environment | Exports environment functionalities, which handles central functions like MDNS and configuration |
@project-chip/matter.js/elements | Exports every standard Matter element defined by the Matter Object Model |
@project-chip/matter.js/fabric | Exports Matter-Fabric functionality |
@project-chip/matter.js/interaction | Exports Matter Interaction protocol functionality |
@project-chip/matter.js/log | Exports Logging functionality (based on "console") |
@project-chip/matter.js/math | Exports Math functionality used by Matter |
@project-chip/matter.js/mdns | Exports Basic MDNS functionality (uses Network implementation) |
@project-chip/matter.js/model | Exports a JavaScript version of the Matter data model |
@project-chip/matter.js/net | Exports Basic Network abstract functionality that needs to be implemented platform specific! |
@project-chip/matter.js/node | Exports Matter Node functionality which is used as basis for a device or controller (NEW API!). It also contains Matter Interaction model abstractions for the new API. |
@project-chip/matter.js/protocol | Exports Basic Matter protocol functionality |
@project-chip/matter.js/schema | Exports Schema definitions and functionality |
@project-chip/matter.js/securechannel | Exports Secure Channel functionality |
@project-chip/matter.js/session | Exports Session and Secure-Session functionality |
@project-chip/matter.js/spec | Exports Matter Specification References |
@project-chip/matter.js/storage | Exports Basic Storage abstract functionality that needs to be implemented platform specific! |
@project-chip/matter.js/tags | Exports Semantic Tag Standard namespace definitions of the Matter specification |
@project-chip/matter.js/time | Exports Basic Time/Timer abstract functionality that needs to be implemented platform specific! |
@project-chip/matter.js/tlv | Exports Matter TLV type definitions |
@project-chip/matter.js/util | Exports Basic Utility functionality |
Both exports and the typings are exported as CommonJS and ES6 modules.
For more details please refer to the API Documentation.
Each cluster that has commands also needs to have them implemented based on the chosen feature set.
Matter.js provides a specification-compliant implementation of all Matter 1.3 clusters. For many clusters our implementations perform high-level business logic. For other clusters you provide the needed business logic by extending the matter.js implementation. In all cases matter.js takes care of details like the Matter protocol, input and output validation and persistence. The developer can then decide if own functionality needs to be implemented and can overwrite and extend these implementations or just use them.
For examples for nearly all clusters check the All Clusters Test App.
Matter.js allows the following clusters to be used directly with a default implementation for all relevant commands - or the clusters do not need any commands and so the standard feature set of Matter.js for attributes is sufficient. All clusters contained in this list are also verified using the CI YAML project-chip certification tests.
PICS | Cluster name | Features | Matter-Version | Additional Information |
---|---|---|---|---|
ACL | Access Control | None | 1.3 | Fully implemented and compliant |
ACFREMON | Activated Carbon Filter Monitoring | All | 1.3 | No command implementations needed. |
CADMIN | Administrator Commissioning | All | 1.3 | Internal Root cluster implemented, no need to customize |
APBSC | Application Basic | None | 1.3 | No command implementations needed |
BC | Ballast Configuration | None | 1.3 | No command implementations needed, Cluster provisional |
BINFO | Basic Information | None | 1.3 | Internal Root cluster implemented, no need to customize, all events are automatically emitted by matter.js |
BOOL | Boolean State | None | 1.3 | No command implementations needed. If the StateChanged event is enabled it is emitted automatically on state change. |
BRBINFO | Bridged Device Basic Information | None | 1.3 | reachabilityChanged event is automatically emitted by matter.js |
CMOCONC | Carbon Dioxide (CO2) Concentration Measurement | All | 1.3 | No command implementations needed. |
CMOCONC | Carbon Monoxide (CO) Concentration Measurement | All | 1.3 | No command implementations needed. |
CC | Color Control | All | 1.3 | Default implementation supports all features. |
DESC | Descriptor | None | 1.3 | Internal Root cluster implemented, no need to customize, data are automatically managed by matter.js |
EEM | Electrical Energy Measurement | None | 1.3 | When the convenience method "setMeasurement" is used then also the required events are sent, else developer needs to trigger them. |
EPM | Electrical Power Measurement | All | 1.3 | No command implementations needed. Required events need to be triggered by the developer. |
DGETH | Ethernet Network Diagnostics | None | 1.3 | No command implementations needed when used without any features. The cluster data needs to be provided by the platform. |
FLABEL | Fixed Label | None | 1.3 | No command implementations needed |
FLW | Flow Measurement | None | 1.3 | No command implementations needed |
FLDCONC | Formaldehyde (CH2O) Concentration Measurement | All | 1.3 | No command implementations needed. |
CGEN | General Commissioning | None | 1.3 | Internal Root cluster implemented, provides convenience methods to register and clear Faults and to handle triggered Test Events. |
DGGEN | General Diagnostics | None | 1.3 | No command implementations needed when used without test event triggers. All mandatory attributes and events supported. Optional attributes, events and Test event triggers needs to be implemented by developer if needed. |
HEPAFREMON | HEPA Filter Monitoring | All | 1.3 | No command implementations needed. |
I | Identify | All | 1.3 | All mandatory commands implemented. Additionally, state isIdentifying and events start/stopIdentifying are available to easiely extend the server. |
ILL | Illuminance Measurement | None | 1.3 | No command implementations needed |
RH | Leaf Wetness Measurement | None | 1.3 | No command implementations needed |
LVL | Level Control | All | 1.3 | Default implementation sets currentLevel and remainingTime attributes by respecting the feature requirements on best-effort basis. Use managedTransitionTimeHandling state to true to use transitions managed by matter.js. |
LCFG | Localization Configuration | None | 1.3 | The active locale is determined via JavaScript Intl package, can be overridden |
LOWPOWER | Low Power | None | 1.3 | The default implementation emits the internal event enterLowPowerMode that an implementation can listen too. Alternatively, you can override the sleep command by extending the cluster. |
CNET | Network Commissioning | None | 1.3 | No command implementations needed when using with Ethernet network, needs custom implementation for Wi-Fi or Thread, see examples |
NDOCONC | Nitrogen Dioxide (NO2) Concentration Measurement | All | 1.3 | No command implementations needed. |
MOD | Mode Select | OnOff | 1.3 | Default implementation sets the new mode when change command is used and automatically handles StartUpMode and OnMode. |
OCC | Occupancy Sensing | None | 1.3 | No command implementations needed |
OO | OnOff | All | 1.3 | LevelControl-For-Lighting feature is enabled automatically in default implementation. offWithEffect currently ignores requested effects and turns off. onWithRecallGlobalScene currently ignores the global scene and turns on. No special logic is implemented for DeadFrontBehavior feature because too use-case specific but can be used and logic adjusted as needed. |
OPCREDS | Operational Credentials | None | 1.3 | Internal Root cluster implemented, no need to customize |
OZCONC | Ozone (O3) Concentration Measurement | All | 1.3 | No command implementations needed. |
PMHCONC | PM1 Concentration Measurement | All | 1.3 | No command implementations needed. |
PMLCONC | PM10 Concentration Measurement | All | 1.3 | No command implementations needed. |
PMICONC | PM2.5 Concentration Measurement | All | 1.3 | No command implementations needed. |
PS | Power Source | None | 1.3 | No command implementations needed. Optional events needs to be emitted by the developer if needed |
PSCFG | Power Source Configuration | None | 1.3 | No command implementations needed |
PWRTL | Power Topology | None | 1.3 | No command implementations needed |
PRS | Pressure Measurement | None | 1.3 | No command implementations needed |
PXCFG | Proxy Configuration | None | 1.3 | No command implementations needed |
PCC | Pump Configuration and Control | None | 1.3 | No command implementations needed, Relevant Events need to be enabled and emitted by the developer when needed, Cluster client dependencies are not yet possible with matter.js |
RNCONC | Radon (Rn) Concentration Measurement | All | 1.3 | No command implementations needed. |
RH | Relative Humidity Measurement | None | 1.1 | No command implementations needed |
SWTCH | Switch | All | 1.3 | Matter.js provides a full implementation with all features in a configurable way including release, long- and multi-press detection. Just set currentPosition state and all events will be triggered automatically. Alternatively, an additional state rawPosition is available which will be debounced based on a defined debounce delay. Check the SwitchCluster documentation for the details and additional state values. |
TMP | Temperature Measurement | None | 1.3 | No command implementations needed |
TSUIC | Thermostat User Interface | None | 1.3 | No command implementations needed |
LTIME | Time Format Localization | None | 1.3 | The hour format and calendar type are determined automatically using the JavaScript Intl package. |
TVOCCONC | Total Volatile Organic Compounds (TVOC) Concentration Measurement | All | 1.3 | No command implementations needed. |
LUNIT | Unit Localization | None | 1.3 | No command implementations needed. If not provided we set Celsius as Temperature unit |
ULABEL | User Label | None | 1.3 | No command implementations needed |
WAKEONLAN | WakeOnLan | None | 1.3 | No command implementations needed |
WNCV | Window Covering | All | 1.3 | All commands for all feature sets are implemented. Movements will by default be executed as fast as possible by just setting the new value, so own movement logic needs to be implemented. |
More will come over time and can also be contributed by the community!
To have Typescript and your IDE know all the relevant exported functionality you need to use the following in your tsconfig.json:
{
compilerOptions: {
moduleResolution: "node16", // Required to support package.json exports
module: "node16", // Required to make sure all imports are js
},
}
Additionally, we recommend using "strictNullChecks": true
or better for code quality "strict": true
to make sure that all types are correctly determined.
matter.js is used at the core of those two projects:
npm run build
: Build all code and create CommonJS and ES6 variants in dist directory. This will built incrementally and only build the changed files.npm run build-clean
: Clean the dist directory and build all code from scratchnpm run test-node
: Run tests in node.jsnpm run test-web
: Run tests in the browsernpm run test
: Run all teststest-web will create a /coverage directory containing the test code coverage
FAQs
Matter protocol in pure js
The npm package @project-chip/matter.js receives a total of 1,818 weekly downloads. As such, @project-chip/matter.js popularity was classified as popular.
We found that @project-chip/matter.js demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.