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
4
Versions
251
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.8.0-alpha.0-20240311-6006c732
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.8K
decreased by-1.78%
Maintainers
4
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.

The following features are abstracted away to allow to be implemented environment specific:

  • Network (UDP/MDNS)
  • Crypto (to be split out)
  • Storage
  • Date/Timer
  • Logger (Default uses "console")

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 handes central functions like MDNS and configuration
@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/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.1 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 developed and can overwrite and extend these implementations or just use them.

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.

Cluster nameFeaturesMatter-VersionAdditional Information
Access ControlNone1.1No command implementations needed, but ACL checks still pending in matter.js
Administrator CommissioningNone, Basic1.1Internal Root cluster implemented, no need to customize
Application BasicNone1.1No command implementations needed
Ballast ConfigurationNone1.1No command implementations needed
Basic InformationNone1.1Internal Root cluster implemented, no need to customize, events are automatically emitted by matter.js
Binary Input BasicNone1.1No command implementations needed
BindingNone1.1No command implementations needed, support of defined bindings pending in matter.js
Boolean StateNone1.1No command implementations needed
Bridged Device Basic InformationNone1.1Internal Root cluster implemented, no need to customize, events automatically emitted by matter.js
DescriptorNone1.1Internal Root cluster implemented, no need to customize, data are automatically manabed by matter.js
Ethernet Network DiagnosticsNone1.1No command implementations needed when used without any features
Fan ControlNone1.1No command implementations needed
Fixed LabelNone1.1No command implementations needed
Flow MeasurementNone1.1No command implementations needed
General CommissioningNone1.1Internal Root cluster implemented, no need to customize
General DiagnosticsNone1.1No command implementations needed when used without test event triggers, else implement as needed
IdentifyNone, IdentifyQuery1.1
Illuminance MeasurementNone1.1No command implementations needed
Leaf Wetness MeasurementNone1.1No command implementations needed
Localization ConfigurationNone1.1No command implementations needed
Network CommissioningNone1.1No command implementations needed when using with Ethernet network, needs custom implementation for Wi-Fi or Thread, see examples
Occupancy SensingNone1.1No command implementations needed
OnOffNone, LevelControl-For-Lighting1.1LevelControl-For-Lighting feature is exposed automatically when added to a device
OnOff Switch ConfigurationNone1.1No command implementations needed
Operational CredentialsNone1.1Internal Root cluster implemented, no need to customize
Power SourceNone1.1No command implementations needed
Power Source ConfigurationNone1.1No command implementations needed
Pressure MeasurementNone1.1No command implementations needed
Proxy ConfigurationNone1.1No command implementations needed
Pump Configuration and ControlNone1.1No command implementations needed
Relative Humidity MeasurementNone1.1No command implementations needed
Software DiagnosticsNone1.1No command implementations needed when used without Watermark feature
Soil Moisture MeasurementNone1.1No command implementations needed
SwitchNone1.1No command implementations needed
Temperature MeasurementNone1.1No command implementations needed
Thermostat User InterfaceNone1.1No command implementations needed
Time Format LocalizationNone1.1No command implementations needed
Unit LocalizationNone1.1No command implementations needed
User LabelNone1.1No command implementations needed
WakeOnLanNone1.1No command implementations needed

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
    }
}

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 11 Mar 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