Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@project-chip/matter.js

Package Overview
Dependencies
Maintainers
0
Versions
246
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@project-chip/matter.js

Matter protocol in pure js

  • 0.11.0-alpha.0-20240928-08865c2ce
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.1K
increased by3.47%
Maintainers
0
Weekly downloads
 
Created
Source

matter.js

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:

  • Network (UDP/MDNS)
  • Crypto
  • Storage
  • Date/Timer
  • Logger (Default uses "console")
  • Environment (Process and Configuration handling)

Exported functionality

This library exports the Matter protocol functionality as well as some helper functions as named exports:

ExportDescription
@project-chip/matter.jsExports the API to implement a Device or a Controller.
@project-chip/matter.js/behaviorExports 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/certificateExports Certificate (Root-/PAA/PAI/IAC/DA-Certificates) related functionality
@project-chip/matter.js/clusterExports Matter Cluster definitions and Default Cluster-Handlers
@project-chip/matter.js/codecExports Codecs for e.g. Matter-Messages
@project-chip/matter.js/commonExports certain common functionalities
@project-chip/matter.js/cryptoExports Crypto related abstract functionality that needs to be implemented platform specific!
@project-chip/matter.js/datatypeExports Matter Data types
@project-chip/matter.js/deviceExports Matter Device relevant classes (Legacy API!)
@project-chip/matter.js/devicesExports Matter Device type classes (NEW API!)
@project-chip/matter.js/endpointExports Matter Endpoint structure classes (NEW API!)
@project-chip/matter-.js/environmentExports environment functionalities, which handles central functions like MDNS and configuration
@project-chip/matter.js/elementsExports every standard Matter element defined by the Matter Object Model
@project-chip/matter.js/fabricExports Matter-Fabric functionality
@project-chip/matter.js/interactionExports Matter Interaction protocol functionality
@project-chip/matter.js/logExports Logging functionality (based on "console")
@project-chip/matter.js/mathExports Math functionality used by Matter
@project-chip/matter.js/mdnsExports Basic MDNS functionality (uses Network implementation)
@project-chip/matter.js/modelExports a JavaScript version of the Matter data model
@project-chip/matter.js/netExports Basic Network abstract functionality that needs to be implemented platform specific!
@project-chip/matter.js/nodeExports 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/protocolExports Basic Matter protocol functionality
@project-chip/matter.js/schemaExports Schema definitions and functionality
@project-chip/matter.js/securechannelExports Secure Channel functionality
@project-chip/matter.js/sessionExports Session and Secure-Session functionality
@project-chip/matter.js/specExports Matter Specification References
@project-chip/matter.js/storageExports Basic Storage abstract functionality that needs to be implemented platform specific!
@project-chip/matter.js/tagsExports Semantic Tag Standard namespace definitions of the Matter specification
@project-chip/matter.js/timeExports Basic Time/Timer abstract functionality that needs to be implemented platform specific!
@project-chip/matter.js/tlvExports Matter TLV type definitions
@project-chip/matter.js/utilExports Basic Utility functionality

Both exports and the typings are exported as CommonJS and ES6 modules.

For more details please refer to the API Documentation.

Included Cluster default implementations

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.

PICSCluster nameFeaturesMatter-VersionAdditional Information
ACLAccess ControlNone1.3Fully implemented and compliant
ACFREMONActivated Carbon Filter MonitoringAll1.3No command implementations needed.
CADMINAdministrator CommissioningAll1.3Internal Root cluster implemented, no need to customize
APBSCApplication BasicNone1.3No command implementations needed
BCBallast ConfigurationNone1.3No command implementations needed, Cluster provisional
BINFOBasic InformationNone1.3Internal Root cluster implemented, no need to customize, all events are automatically emitted by matter.js
BOOLBoolean StateNone1.3No command implementations needed. If the StateChanged event is enabled it is emitted automatically on state change.
BRBINFOBridged Device Basic InformationNone1.3reachabilityChanged event is automatically emitted by matter.js
CMOCONCCarbon Dioxide (CO2) Concentration MeasurementAll1.3No command implementations needed.
CMOCONCCarbon Monoxide (CO) Concentration MeasurementAll1.3No command implementations needed.
CCColor ControlAll1.3Default implementation supports all features.
DESCDescriptorNone1.3Internal Root cluster implemented, no need to customize, data are automatically managed by matter.js
DGETHEthernet Network DiagnosticsNone1.3No command implementations needed when used without any features. The cluster data needs to be provided by the platform.
FLABELFixed LabelNone1.3No command implementations needed
FLWFlow MeasurementNone1.3No command implementations needed
FLDCONCFormaldehyde (CH2O) Concentration MeasurementAll1.3No command implementations needed.
CGENGeneral CommissioningNone1.3Internal Root cluster implemented, provides convenience methods to register and clear Faults and to handle triggered Test Events.
DGGENGeneral DiagnosticsNone1.3No 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.
HEPAFREMONHEPA Filter MonitoringAll1.3No command implementations needed.
IIdentifyAll1.3All mandatory commands implemented. Additionally, state isIdentifying and events start/stopIdentifying are available to easiely extend the server.
ILLIlluminance MeasurementNone1.3No command implementations needed
RHLeaf Wetness MeasurementNone1.3No command implementations needed
LVLLevel ControlAll1.3Default 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.
LCFGLocalization ConfigurationNone1.3The active locale is determined via JavaScript Intl package, can be overridden
LOWPOWERLow PowerNone1.3The default implementation emits the internal event enterLowPowerMode that an implementation can listen too. Alternatively, you can override the sleep command by extending the cluster.
CNETNetwork CommissioningNone1.3No command implementations needed when using with Ethernet network, needs custom implementation for Wi-Fi or Thread, see examples
NDOCONCNitrogen Dioxide (NO2) Concentration MeasurementAll1.3No command implementations needed.
MODMode SelectOnOff1.3Default implementation sets the new mode when change command is used and automatically handles StartUpMode and OnMode.
OCCOccupancy SensingNone1.3No command implementations needed
OOOnOffAll1.3LevelControl-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.
OPCREDSOperational CredentialsNone1.3Internal Root cluster implemented, no need to customize
OZCONCOzone (O3) Concentration MeasurementAll1.3No command implementations needed.
PMHCONCPM1 Concentration MeasurementAll1.3No command implementations needed.
PMLCONCPM10 Concentration MeasurementAll1.3No command implementations needed.
PMICONCPM2.5 Concentration MeasurementAll1.3No command implementations needed.
PSPower SourceNone1.3No command implementations needed. Optional events needs to be emitted by the developer if needed
PSCFGPower Source ConfigurationNone1.3No command implementations needed
PWRTLPower TopologyNone1.3No command implementations needed
PRSPressure MeasurementNone1.3No command implementations needed
PXCFGProxy ConfigurationNone1.3No command implementations needed
PCCPump Configuration and ControlNone1.3No 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
RNCONCRadon (Rn) Concentration MeasurementAll1.3No command implementations needed.
RHRelative Humidity MeasurementNone1.1No command implementations needed
SWTCHSwitchAll1.3Matter.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.
TMPTemperature MeasurementNone1.3No command implementations needed
TSUICThermostat User InterfaceNone1.3No command implementations needed
LTIMETime Format LocalizationNone1.3The hour format and calendar type are determined automatically using the JavaScript Intl package.
TVOCCONCTotal Volatile Organic Compounds (TVOC) Concentration MeasurementAll1.3No command implementations needed.
LUNITUnit LocalizationNone1.3No command implementations needed. If not provided we set Celsius as Temperature unit
ULABELUser LabelNone1.3No command implementations needed
WAKEONLANWakeOnLanNone1.3No command implementations needed
WNCVWindow CoveringAll1.3All 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!

Typescript note

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 usage

matter.js is used at the core of those two projects:

  • matternode: a light-weight node.js implementation of a Matter Node
  • matter-node.js: a Matter client / server running on node.js compatible with HA (Android / iOs support in progress)

Building

  • 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 scratch

Tests

  • npm run test-node: Run tests in node.js
  • npm run test-web: Run tests in the browser
  • npm run test: Run all tests

test-web will create a /coverage directory containing the test code coverage

Keywords

FAQs

Package last updated on 28 Sep 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc