@riddix/hamh 2.1.0-alpha.493 → 2.1.0-alpha.495

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9825,12 +9825,12 @@ var init_StandardCrypto = __esm({
9825
9825
  implementationName = "JS";
9826
9826
  #crypto;
9827
9827
  #subtle;
9828
- constructor(crypto7 = globalThis.crypto) {
9829
- const { subtle } = crypto7;
9830
- assertInterface("crypto", crypto7, requiredCryptoMethods);
9828
+ constructor(crypto8 = globalThis.crypto) {
9829
+ const { subtle } = crypto8;
9830
+ assertInterface("crypto", crypto8, requiredCryptoMethods);
9831
9831
  assertInterface("crypto.subtle", subtle, requiredSubtleMethods);
9832
9832
  super();
9833
- this.#crypto = crypto7;
9833
+ this.#crypto = crypto8;
9834
9834
  this.#subtle = subtle;
9835
9835
  }
9836
9836
  get subtle() {
@@ -10013,9 +10013,9 @@ var init_StandardCrypto = __esm({
10013
10013
  }
10014
10014
  };
10015
10015
  if ("crypto" in globalThis && globalThis.crypto?.subtle) {
10016
- const crypto7 = new StandardCrypto();
10017
- Environment.default.set(Entropy, crypto7);
10018
- Environment.default.set(Crypto, crypto7);
10016
+ const crypto8 = new StandardCrypto();
10017
+ Environment.default.set(Entropy, crypto8);
10018
+ Environment.default.set(Crypto, crypto8);
10019
10019
  }
10020
10020
  }
10021
10021
  });
@@ -10025,9 +10025,9 @@ function MockCrypto(index = 128, implementation = StandardCrypto) {
10025
10025
  if (index < 0 || index > 255) {
10026
10026
  throw new ImplementationError(`Index for stable crypto must be 0-255`);
10027
10027
  }
10028
- const crypto7 = new implementation();
10029
- const { randomBytes: randomBytes2, createKeyPair } = crypto7;
10030
- Object.defineProperties(crypto7, {
10028
+ const crypto8 = new implementation();
10029
+ const { randomBytes: randomBytes2, createKeyPair } = crypto8;
10030
+ Object.defineProperties(crypto8, {
10031
10031
  index: {
10032
10032
  get() {
10033
10033
  return index;
@@ -10038,12 +10038,12 @@ function MockCrypto(index = 128, implementation = StandardCrypto) {
10038
10038
  },
10039
10039
  entropic: {
10040
10040
  get() {
10041
- return crypto7.randomBytes === randomBytes2;
10041
+ return crypto8.randomBytes === randomBytes2;
10042
10042
  },
10043
10043
  set(entropic) {
10044
10044
  if (entropic) {
10045
- crypto7.randomBytes = randomBytes2;
10046
- crypto7.createKeyPair = createKeyPair;
10045
+ crypto8.randomBytes = randomBytes2;
10046
+ crypto8.createKeyPair = createKeyPair;
10047
10047
  } else {
10048
10048
  disableEntropy();
10049
10049
  }
@@ -10051,15 +10051,15 @@ function MockCrypto(index = 128, implementation = StandardCrypto) {
10051
10051
  }
10052
10052
  });
10053
10053
  disableEntropy();
10054
- return crypto7;
10054
+ return crypto8;
10055
10055
  function disableEntropy() {
10056
- crypto7.randomBytes = function getRandomDataNONENTROPIC(length) {
10056
+ crypto8.randomBytes = function getRandomDataNONENTROPIC(length) {
10057
10057
  const result = new Uint8Array(length);
10058
10058
  result.fill(index);
10059
10059
  return result;
10060
10060
  };
10061
- crypto7.createKeyPair = function getRandomDataNONENTROPIC() {
10062
- const privateBits = ec.mapHashToField(Bytes.of(crypto7.randomBytes(48)), ec.p256.Point.CURVE().n);
10061
+ crypto8.createKeyPair = function getRandomDataNONENTROPIC() {
10062
+ const privateBits = ec.mapHashToField(Bytes.of(crypto8.randomBytes(48)), ec.p256.Point.CURVE().n);
10063
10063
  return Key({
10064
10064
  kty: KeyType.EC,
10065
10065
  crv: CurveType.p256,
@@ -10092,9 +10092,9 @@ var init_NodeJsStyleCrypto = __esm({
10092
10092
  NodeJsStyleCrypto = class extends Crypto {
10093
10093
  implementationName = "Node.js";
10094
10094
  #crypto;
10095
- constructor(crypto7) {
10095
+ constructor(crypto8) {
10096
10096
  super();
10097
- this.#crypto = crypto7;
10097
+ this.#crypto = crypto8;
10098
10098
  }
10099
10099
  encrypt(key, data, nonce, aad) {
10100
10100
  const cipher = this.#crypto.createCipheriv(CRYPTO_ENCRYPT_ALGORITHM, Bytes.of(key), Bytes.of(nonce), {
@@ -10368,29 +10368,29 @@ var init_Spake2p = __esm({
10368
10368
  #context;
10369
10369
  #random;
10370
10370
  #w0;
10371
- static async computeW0W1(crypto7, { iterations, salt }, pin) {
10371
+ static async computeW0W1(crypto8, { iterations, salt }, pin) {
10372
10372
  const pinWriter = new DataWriter(Endian.Little);
10373
10373
  pinWriter.writeUInt32(pin);
10374
10374
  const ws2 = Bytes.of(
10375
- await crypto7.createPbkdf2Key(pinWriter.toByteArray(), salt, iterations, CRYPTO_W_SIZE_BYTES * 2)
10375
+ await crypto8.createPbkdf2Key(pinWriter.toByteArray(), salt, iterations, CRYPTO_W_SIZE_BYTES * 2)
10376
10376
  );
10377
10377
  const curve = Point2.CURVE();
10378
10378
  const w0 = mod2(bytesToNumberBE(ws2.slice(0, 40)), curve.n);
10379
10379
  const w1 = mod2(bytesToNumberBE(ws2.slice(40, 80)), curve.n);
10380
10380
  return { w0, w1 };
10381
10381
  }
10382
- static async computeW0L(crypto7, pbkdfParameters, pin) {
10383
- const { w0, w1 } = await this.computeW0W1(crypto7, pbkdfParameters, pin);
10382
+ static async computeW0L(crypto8, pbkdfParameters, pin) {
10383
+ const { w0, w1 } = await this.computeW0W1(crypto8, pbkdfParameters, pin);
10384
10384
  const L = Point2.BASE.multiply(w1).toBytes(false);
10385
10385
  return { w0, L };
10386
10386
  }
10387
- static create(crypto7, context, w0) {
10387
+ static create(crypto8, context, w0) {
10388
10388
  const curve = Point2.CURVE();
10389
- const random = crypto7.randomBigInt(32, curve.p);
10390
- return new _Spake2p(crypto7, context, random, w0);
10389
+ const random = crypto8.randomBigInt(32, curve.p);
10390
+ return new _Spake2p(crypto8, context, random, w0);
10391
10391
  }
10392
- constructor(crypto7, context, random, w0) {
10393
- this.#crypto = crypto7;
10392
+ constructor(crypto8, context, random, w0) {
10393
+ this.#crypto = crypto8;
10394
10394
  this.#context = context;
10395
10395
  this.#random = random;
10396
10396
  this.#w0 = w0;
@@ -10521,10 +10521,10 @@ var init_X509 = __esm({
10521
10521
  init_Pem();
10522
10522
  init_X962();
10523
10523
  ((X5092) => {
10524
- async function sign(crypto7, key, cert) {
10524
+ async function sign(crypto8, key, cert) {
10525
10525
  return {
10526
10526
  ...cert,
10527
- signature: (await crypto7.signEcdsa(key, certificateToDer(cert))).der
10527
+ signature: (await crypto8.signEcdsa(key, certificateToDer(cert))).der
10528
10528
  };
10529
10529
  }
10530
10530
  X5092.sign = sign;
@@ -46460,9 +46460,9 @@ var init_NodeId = __esm({
46460
46460
  return hex.fixed(nodeId3, 16);
46461
46461
  }
46462
46462
  NodeId2.strOf = strOf;
46463
- NodeId2.randomOperationalNodeId = (crypto7) => {
46463
+ NodeId2.randomOperationalNodeId = (crypto8) => {
46464
46464
  while (true) {
46465
- const randomBigInt = crypto7.randomBigInt(8);
46465
+ const randomBigInt = crypto8.randomBigInt(8);
46466
46466
  if (randomBigInt >= OPERATIONAL_NODE_MIN && randomBigInt <= OPERATIONAL_NODE_MAX) {
46467
46467
  return NodeId2(randomBigInt);
46468
46468
  }
@@ -88338,11 +88338,11 @@ var init_GlobalFabricId = __esm({
88338
88338
  return hex.fixed(id, 16);
88339
88339
  }
88340
88340
  GlobalFabricId2.strOf = strOf;
88341
- async function compute(crypto7, id, caKey) {
88341
+ async function compute(crypto8, id, caKey) {
88342
88342
  const saltWriter = new DataWriter();
88343
88343
  saltWriter.writeUInt64(id);
88344
88344
  return GlobalFabricId2(
88345
- await crypto7.createHkdfKey(
88345
+ await crypto8.createHkdfKey(
88346
88346
  Bytes.of(caKey).slice(1),
88347
88347
  saltWriter.toByteArray(),
88348
88348
  COMPRESSED_FABRIC_ID_INFO,
@@ -90621,8 +90621,8 @@ var init_Certificate = __esm({
90621
90621
  * Sign the certificate using the provided crypto and key.
90622
90622
  * It throws a CertificateError if the certificate is already signed.
90623
90623
  */
90624
- async sign(crypto7, key) {
90625
- this.signature = await crypto7.signEcdsa(key, this.asUnsignedDer());
90624
+ async sign(crypto8, key) {
90625
+ this.signature = await crypto8.signEcdsa(key, this.asUnsignedDer());
90626
90626
  }
90627
90627
  /**
90628
90628
  * Serialize as signed DER.
@@ -90684,7 +90684,7 @@ var init_Certificate = __esm({
90684
90684
  }
90685
90685
  };
90686
90686
  ((Certificate2) => {
90687
- async function createCertificateSigningRequest(crypto7, key) {
90687
+ async function createCertificateSigningRequest(crypto8, key) {
90688
90688
  const request = {
90689
90689
  version: 0,
90690
90690
  subject: { organization: X520.OrganisationName("CSR") },
@@ -90694,7 +90694,7 @@ var init_Certificate = __esm({
90694
90694
  return DerCodec.encode({
90695
90695
  request,
90696
90696
  signAlgorithm: X962.EcdsaWithSHA256,
90697
- signature: DerBitString((await crypto7.signEcdsa(key, DerCodec.encode(request))).der)
90697
+ signature: DerBitString((await crypto8.signEcdsa(key, DerCodec.encode(request))).der)
90698
90698
  });
90699
90699
  }
90700
90700
  Certificate2.createCertificateSigningRequest = createCertificateSigningRequest;
@@ -90973,7 +90973,7 @@ var init_Certificate = __esm({
90973
90973
  };
90974
90974
  }
90975
90975
  Certificate2.parseAsn1Certificate = parseAsn1Certificate;
90976
- async function getPublicKeyFromCsr(crypto7, encodedCsr) {
90976
+ async function getPublicKeyFromCsr(crypto8, encodedCsr) {
90977
90977
  const { _elements: rootElements } = DerCodec.decode(encodedCsr);
90978
90978
  if (rootElements?.length !== 3) {
90979
90979
  throw new CertificateError("Invalid CSR data");
@@ -91011,7 +91011,7 @@ var init_Certificate = __esm({
91011
91011
  if (signatureAlgorithmBytes === void 0 || !Bytes.areEqual(X962.EcdsaWithSHA256._objectId._bytes, signatureAlgorithmBytes)) {
91012
91012
  throw new CertificateError("Unsupported signature algorithm in CSR");
91013
91013
  }
91014
- await crypto7.verifyEcdsa(
91014
+ await crypto8.verifyEcdsa(
91015
91015
  PublicKey(publicKey),
91016
91016
  DerCodec.encode(requestNode),
91017
91017
  new EcdsaSignature(signatureNode._bytes, "der")
@@ -91240,7 +91240,7 @@ var init_Icac = __esm({
91240
91240
  * Verify requirements a Matter Intermediate CA certificate must fulfill.
91241
91241
  * Rules for this are listed in @see {@link MatterSpecification.v12.Core} §6.5.x
91242
91242
  */
91243
- async verify(crypto7, root) {
91243
+ async verify(crypto8, root) {
91244
91244
  this.generalVerify();
91245
91245
  const {
91246
91246
  subject,
@@ -91316,7 +91316,7 @@ var init_Icac = __esm({
91316
91316
  `Ica certificate authorityKeyIdentifier must be equal to root cert subjectKeyIdentifier.`
91317
91317
  );
91318
91318
  }
91319
- await crypto7.verifyEcdsa(PublicKey(root.cert.ellipticCurvePublicKey), this.asUnsignedDer(), this.signature);
91319
+ await crypto8.verifyEcdsa(PublicKey(root.cert.ellipticCurvePublicKey), this.asUnsignedDer(), this.signature);
91320
91320
  }
91321
91321
  };
91322
91322
  }
@@ -91367,7 +91367,7 @@ var init_Noc = __esm({
91367
91367
  * Verify requirements a Matter Node Operational certificate must fulfill.
91368
91368
  * Rules for this are listed in @see {@link MatterSpecification.v12.Core} §6.5.x
91369
91369
  */
91370
- async verify(crypto7, root, ica) {
91370
+ async verify(crypto8, root, ica) {
91371
91371
  this.generalVerify();
91372
91372
  const {
91373
91373
  subject,
@@ -91452,7 +91452,7 @@ var init_Noc = __esm({
91452
91452
  `Noc certificate authorityKeyIdentifier must be equal to Root/Ica subjectKeyIdentifier.`
91453
91453
  );
91454
91454
  }
91455
- await crypto7.verifyEcdsa(PublicKey(issuer.cert.ellipticCurvePublicKey), this.asUnsignedDer(), this.signature);
91455
+ await crypto8.verifyEcdsa(PublicKey(issuer.cert.ellipticCurvePublicKey), this.asUnsignedDer(), this.signature);
91456
91456
  }
91457
91457
  };
91458
91458
  }
@@ -93037,10 +93037,10 @@ var init_MessageCounter = __esm({
93037
93037
  * counter is not allowed to rollover and the callback is called before a rollover would happen. Optionally provide
93038
93038
  * a number of messages before the rollover callback is called (Default 1000).
93039
93039
  */
93040
- constructor(crypto7, onRollover, rolloverInfoDifference = ROLLOVER_INFO_DIFFERENCE) {
93040
+ constructor(crypto8, onRollover, rolloverInfoDifference = ROLLOVER_INFO_DIFFERENCE) {
93041
93041
  this.onRollover = onRollover;
93042
93042
  this.rolloverInfoDifference = rolloverInfoDifference;
93043
- this.messageCounter = (crypto7.randomUint32 >>> 4) + 1;
93043
+ this.messageCounter = (crypto8.randomUint32 >>> 4) + 1;
93044
93044
  }
93045
93045
  messageCounter;
93046
93046
  async getIncrementedCounter() {
@@ -93058,8 +93058,8 @@ var init_MessageCounter = __esm({
93058
93058
  }
93059
93059
  };
93060
93060
  PersistedMessageCounter = class _PersistedMessageCounter extends MessageCounter {
93061
- constructor(crypto7, storageContext, storageKey, aboutToRolloverCallback, rolloverInfoDifference = ROLLOVER_INFO_DIFFERENCE) {
93062
- super(crypto7, aboutToRolloverCallback, rolloverInfoDifference);
93061
+ constructor(crypto8, storageContext, storageKey, aboutToRolloverCallback, rolloverInfoDifference = ROLLOVER_INFO_DIFFERENCE) {
93062
+ super(crypto8, aboutToRolloverCallback, rolloverInfoDifference);
93063
93063
  this.storageContext = storageContext;
93064
93064
  this.storageKey = storageKey;
93065
93065
  this.#construction = Construction(this, async () => {
@@ -93078,10 +93078,10 @@ var init_MessageCounter = __esm({
93078
93078
  get construction() {
93079
93079
  return this.#construction;
93080
93080
  }
93081
- static async create(crypto7, storageContext, storageKey, aboutToRolloverCallback, rolloverInfoDifference = ROLLOVER_INFO_DIFFERENCE) {
93081
+ static async create(crypto8, storageContext, storageKey, aboutToRolloverCallback, rolloverInfoDifference = ROLLOVER_INFO_DIFFERENCE) {
93082
93082
  return asyncNew(
93083
93083
  _PersistedMessageCounter,
93084
- crypto7,
93084
+ crypto8,
93085
93085
  storageContext,
93086
93086
  storageKey,
93087
93087
  aboutToRolloverCallback,
@@ -93994,7 +93994,7 @@ var init_NodeSession = __esm({
93994
93994
  }
93995
93995
  constructor(config10) {
93996
93996
  const {
93997
- crypto: crypto7,
93997
+ crypto: crypto8,
93998
93998
  manager,
93999
93999
  id,
94000
94000
  fabric,
@@ -94012,14 +94012,14 @@ var init_NodeSession = __esm({
94012
94012
  setActiveTimestamp: true,
94013
94013
  // We always set the active timestamp for Secure sessions
94014
94014
  // Can be changed to a PersistedMessageCounter if we implement session storage
94015
- messageCounter: new MessageCounter(crypto7, async () => {
94015
+ messageCounter: new MessageCounter(crypto8, async () => {
94016
94016
  await this.initiateClose(async () => {
94017
94017
  await this.closeSubscriptions(true);
94018
94018
  });
94019
94019
  }),
94020
94020
  messageReceptionState: new MessageReceptionStateEncryptedWithoutRollover(0)
94021
94021
  });
94022
- this.#crypto = crypto7;
94022
+ this.#crypto = crypto8;
94023
94023
  this.#id = id;
94024
94024
  this.#fabric = fabric;
94025
94025
  this.#peerNodeId = peerNodeId;
@@ -94468,22 +94468,22 @@ var init_CaseClient = __esm({
94468
94468
  }
94469
94469
  }
94470
94470
  async #doPair(messenger, exchange, fabric, peerNodeId, caseAuthenticatedTags) {
94471
- const { crypto: crypto7 } = fabric;
94472
- const initiatorRandom = crypto7.randomBytes(32);
94471
+ const { crypto: crypto8 } = fabric;
94472
+ const initiatorRandom = crypto8.randomBytes(32);
94473
94473
  const initiatorSessionId = await this.#sessions.getNextAvailableSessionId();
94474
94474
  const { operationalIdentityProtectionKey, operationalCert: localNoc, intermediateCACert: localIcac } = fabric;
94475
- const localKey = await crypto7.createKeyPair();
94475
+ const localKey = await crypto8.createKeyPair();
94476
94476
  let sigma1Bytes;
94477
94477
  let resumed = false;
94478
94478
  let resumptionRecord = this.#sessions.findResumptionRecordByAddress(fabric.addressOf(peerNodeId));
94479
94479
  if (resumptionRecord !== void 0) {
94480
94480
  const { sharedSecret, resumptionId } = resumptionRecord;
94481
- const resumeKey = await crypto7.createHkdfKey(
94481
+ const resumeKey = await crypto8.createHkdfKey(
94482
94482
  sharedSecret,
94483
94483
  Bytes.concat(initiatorRandom, resumptionId),
94484
94484
  KDFSR1_KEY_INFO
94485
94485
  );
94486
- const initiatorResumeMic = crypto7.encrypt(resumeKey, new Uint8Array(0), RESUME1_MIC_NONCE);
94486
+ const initiatorResumeMic = crypto8.encrypt(resumeKey, new Uint8Array(0), RESUME1_MIC_NONCE);
94487
94487
  sigma1Bytes = await messenger.sendSigma1({
94488
94488
  initiatorSessionId,
94489
94489
  destinationId: await fabric.currentDestinationIdFor(peerNodeId, initiatorRandom),
@@ -94518,8 +94518,8 @@ var init_CaseClient = __esm({
94518
94518
  ...resumptionSessionParams ?? {}
94519
94519
  };
94520
94520
  const resumeSalt = Bytes.concat(initiatorRandom, resumptionId);
94521
- const resumeKey = await crypto7.createHkdfKey(sharedSecret, resumeSalt, KDFSR2_KEY_INFO);
94522
- crypto7.decrypt(resumeKey, resumeMic, RESUME2_MIC_NONCE);
94521
+ const resumeKey = await crypto8.createHkdfKey(sharedSecret, resumeSalt, KDFSR2_KEY_INFO);
94522
+ crypto8.decrypt(resumeKey, resumeMic, RESUME2_MIC_NONCE);
94523
94523
  const secureSessionSalt = Bytes.concat(initiatorRandom, resumptionRecord.resumptionId);
94524
94524
  secureSession = await this.#sessions.createSecureSession({
94525
94525
  channel: exchange.channel.channel,
@@ -94563,15 +94563,15 @@ var init_CaseClient = __esm({
94563
94563
  ...exchange.session.parameters,
94564
94564
  ...responderSessionParams ?? {}
94565
94565
  };
94566
- const sharedSecret = await crypto7.generateDhSecret(localKey, PublicKey(peerKey));
94566
+ const sharedSecret = await crypto8.generateDhSecret(localKey, PublicKey(peerKey));
94567
94567
  const sigma2Salt = Bytes.concat(
94568
94568
  operationalIdentityProtectionKey,
94569
94569
  responderRandom,
94570
94570
  peerKey,
94571
- await crypto7.computeHash(sigma1Bytes)
94571
+ await crypto8.computeHash(sigma1Bytes)
94572
94572
  );
94573
- const sigma2Key = await crypto7.createHkdfKey(sharedSecret, sigma2Salt, KDFSR2_INFO);
94574
- const peerEncryptedData = crypto7.decrypt(sigma2Key, peerEncrypted, TBE_DATA2_NONCE);
94573
+ const sigma2Key = await crypto8.createHkdfKey(sharedSecret, sigma2Salt, KDFSR2_INFO);
94574
+ const peerEncryptedData = crypto8.decrypt(sigma2Key, peerEncrypted, TBE_DATA2_NONCE);
94575
94575
  const {
94576
94576
  responderNoc: peerNoc,
94577
94577
  responderIcac: peerIcac,
@@ -94588,7 +94588,7 @@ var init_CaseClient = __esm({
94588
94588
  ellipticCurvePublicKey: peerPublicKey,
94589
94589
  subject: { fabricId: peerFabricIdNOCert, nodeId: peerNodeIdNOCert }
94590
94590
  } = Noc.fromTlv(peerNoc).cert;
94591
- await crypto7.verifyEcdsa(PublicKey(peerPublicKey), peerSignatureData, new EcdsaSignature(peerSignature));
94591
+ await crypto8.verifyEcdsa(PublicKey(peerPublicKey), peerSignatureData, new EcdsaSignature(peerSignature));
94592
94592
  if (peerNodeIdNOCert !== peerNodeId) {
94593
94593
  throw new UnexpectedDataError(
94594
94594
  `The node ID in the peer certificate ${peerNodeIdNOCert} doesn't match the expected peer node ID ${peerNodeId}`
@@ -94612,9 +94612,9 @@ var init_CaseClient = __esm({
94612
94612
  await fabric.verifyCredentials(peerNoc, peerIcac);
94613
94613
  const sigma3Salt = Bytes.concat(
94614
94614
  operationalIdentityProtectionKey,
94615
- await crypto7.computeHash([sigma1Bytes, sigma2Bytes])
94615
+ await crypto8.computeHash([sigma1Bytes, sigma2Bytes])
94616
94616
  );
94617
- const sigma3Key = await crypto7.createHkdfKey(sharedSecret, sigma3Salt, KDFSR3_INFO);
94617
+ const sigma3Key = await crypto8.createHkdfKey(sharedSecret, sigma3Salt, KDFSR3_INFO);
94618
94618
  const signatureData = TlvSignedData.encode({
94619
94619
  responderNoc: localNoc,
94620
94620
  responderIcac: localIcac,
@@ -94627,13 +94627,13 @@ var init_CaseClient = __esm({
94627
94627
  responderIcac: localIcac,
94628
94628
  signature: signature.bytes
94629
94629
  });
94630
- const encrypted = crypto7.encrypt(sigma3Key, encryptedData, TBE_DATA3_NONCE);
94630
+ const encrypted = crypto8.encrypt(sigma3Key, encryptedData, TBE_DATA3_NONCE);
94631
94631
  const sigma3Bytes = await messenger.sendSigma3({ encrypted });
94632
94632
  await messenger.waitForSuccess("Sigma3-Success");
94633
94633
  const sessionCaseAuthenticatedTags = caseAuthenticatedTags ?? resumptionRecord?.caseAuthenticatedTags;
94634
94634
  const secureSessionSalt = Bytes.concat(
94635
94635
  operationalIdentityProtectionKey,
94636
- await crypto7.computeHash([sigma1Bytes, sigma2Bytes, sigma3Bytes])
94636
+ await crypto8.computeHash([sigma1Bytes, sigma2Bytes, sigma3Bytes])
94637
94637
  );
94638
94638
  secureSession = await this.#sessions.createSecureSession({
94639
94639
  channel: exchange.channel.channel,
@@ -94711,7 +94711,7 @@ var init_Rcac = __esm({
94711
94711
  * Verify requirements a Matter Root certificate must fulfill.
94712
94712
  * Rules for this are listed in @see {@link MatterSpecification.v12.Core} §6.5.x
94713
94713
  */
94714
- async verify(crypto7) {
94714
+ async verify(crypto8) {
94715
94715
  this.generalVerify();
94716
94716
  const { subject, extensions } = this.cert;
94717
94717
  const { fabricId: fabricId3, rcacId } = subject;
@@ -94768,7 +94768,7 @@ var init_Rcac = __esm({
94768
94768
  `Root certificate authorityKeyIdentifier must be equal to subjectKeyIdentifier.`
94769
94769
  );
94770
94770
  }
94771
- await crypto7.verifyEcdsa(PublicKey(this.cert.ellipticCurvePublicKey), this.asUnsignedDer(), this.signature);
94771
+ await crypto8.verifyEcdsa(PublicKey(this.cert.ellipticCurvePublicKey), this.asUnsignedDer(), this.signature);
94772
94772
  }
94773
94773
  };
94774
94774
  }
@@ -94903,8 +94903,8 @@ var init_KeySets = __esm({
94903
94903
  };
94904
94904
  }
94905
94905
  /** Calculates a group session id based on the operational group key. */
94906
- async sessionIdFromKey(crypto7, operationalGroupKey) {
94907
- const groupKeyHash = await crypto7.createHkdfKey(operationalGroupKey, new Uint8Array(), GROUP_KEY_INFO, 2);
94906
+ async sessionIdFromKey(crypto8, operationalGroupKey) {
94907
+ const groupKeyHash = await crypto8.createHkdfKey(operationalGroupKey, new Uint8Array(), GROUP_KEY_INFO, 2);
94908
94908
  return new DataReader(groupKeyHash).readUInt16();
94909
94909
  }
94910
94910
  /**
@@ -94957,8 +94957,8 @@ var init_MessagingState = __esm({
94957
94957
  #messageDataReceptionState = /* @__PURE__ */ new Map();
94958
94958
  #crypto;
94959
94959
  #storage;
94960
- constructor(crypto7, storage2) {
94961
- this.#crypto = crypto7;
94960
+ constructor(crypto8, storage2) {
94961
+ this.#crypto = crypto8;
94962
94962
  if (storage2 !== void 0) {
94963
94963
  this.#storage = storage2;
94964
94964
  }
@@ -95491,8 +95491,8 @@ var init_Fabric = __esm({
95491
95491
  * Certain derived fields that require async crypto operations to compute must be supplied here. Use {@link create}
95492
95492
  * to populate these fields automatically.
95493
95493
  */
95494
- constructor(crypto7, config10) {
95495
- this.#crypto = crypto7;
95494
+ constructor(crypto8, config10) {
95495
+ this.#crypto = crypto8;
95496
95496
  this.fabricIndex = config10.fabricIndex;
95497
95497
  this.fabricId = config10.fabricId;
95498
95498
  this.nodeId = config10.nodeId;
@@ -95521,20 +95521,20 @@ var init_Fabric = __esm({
95521
95521
  *
95522
95522
  * This async creation path populates derived fields that require async crypto operations to compute.
95523
95523
  */
95524
- static async create(crypto7, config10) {
95524
+ static async create(crypto8, config10) {
95525
95525
  let { globalId, operationalIdentityProtectionKey } = config10;
95526
95526
  if (globalId === void 0) {
95527
95527
  const caKey = config10.rootPublicKey ?? Rcac.publicKeyOfTlv(config10.rootCert);
95528
- globalId = await GlobalFabricId.compute(crypto7, config10.fabricId, caKey);
95528
+ globalId = await GlobalFabricId.compute(crypto8, config10.fabricId, caKey);
95529
95529
  }
95530
95530
  if (operationalIdentityProtectionKey === void 0) {
95531
- operationalIdentityProtectionKey = await crypto7.createHkdfKey(
95531
+ operationalIdentityProtectionKey = await crypto8.createHkdfKey(
95532
95532
  config10.identityProtectionKey,
95533
95533
  Bytes.fromBigInt(globalId, 8),
95534
95534
  GROUP_SECURITY_INFO
95535
95535
  );
95536
95536
  }
95537
- return new _Fabric(crypto7, {
95537
+ return new _Fabric(crypto8, {
95538
95538
  ...config10,
95539
95539
  globalId,
95540
95540
  operationalIdentityProtectionKey
@@ -95791,12 +95791,12 @@ var init_Fabric = __esm({
95791
95791
  #vvsc;
95792
95792
  #fabricIndex;
95793
95793
  #label = "";
95794
- constructor(crypto7, key) {
95795
- this.#crypto = crypto7;
95794
+ constructor(crypto8, key) {
95795
+ this.#crypto = crypto8;
95796
95796
  this.#keyPair = key;
95797
95797
  }
95798
- static async create(crypto7) {
95799
- return new _FabricBuilder(crypto7, await crypto7.createKeyPair());
95798
+ static async create(crypto8) {
95799
+ return new _FabricBuilder(crypto8, await crypto8.createKeyPair());
95800
95800
  }
95801
95801
  get publicKey() {
95802
95802
  return this.#keyPair.publicKey;
@@ -95955,8 +95955,8 @@ var init_FabricManager = __esm({
95955
95955
  failsafeClosed: Observable()
95956
95956
  };
95957
95957
  #construction;
95958
- constructor(crypto7, storage2) {
95959
- this.#crypto = crypto7;
95958
+ constructor(crypto8, storage2) {
95959
+ this.#crypto = crypto8;
95960
95960
  this.#storage = storage2;
95961
95961
  let construct;
95962
95962
  if (this.#storage === void 0) {
@@ -95969,7 +95969,7 @@ var init_FabricManager = __esm({
95969
95969
  }
95970
95970
  const fabrics = await this.#storage.get("fabrics", []);
95971
95971
  for (const fabricConfig of fabrics) {
95972
- this.#addNewFabric(await Fabric.create(crypto7, fabricConfig));
95972
+ this.#addNewFabric(await Fabric.create(crypto8, fabricConfig));
95973
95973
  }
95974
95974
  this.#nextFabricIndex = await this.#storage.get("nextFabricIndex", this.#nextFabricIndex);
95975
95975
  this.#initializationDone = true;
@@ -96265,14 +96265,14 @@ var init_CaseServer = __esm({
96265
96265
  return false;
96266
96266
  }
96267
96267
  const { sharedSecret, fabric, peerNodeId, caseAuthenticatedTags } = cx.resumptionRecord;
96268
- const { crypto: crypto7 } = this.#fabrics;
96269
- const peerResumeKey = await crypto7.createHkdfKey(
96268
+ const { crypto: crypto8 } = this.#fabrics;
96269
+ const peerResumeKey = await crypto8.createHkdfKey(
96270
96270
  sharedSecret,
96271
96271
  Bytes.concat(cx.peerRandom, cx.peerResumptionId),
96272
96272
  KDFSR1_KEY_INFO
96273
96273
  );
96274
96274
  try {
96275
- crypto7.decrypt(peerResumeKey, cx.peerResumeMic, RESUME1_MIC_NONCE);
96275
+ crypto8.decrypt(peerResumeKey, cx.peerResumeMic, RESUME1_MIC_NONCE);
96276
96276
  } catch (e) {
96277
96277
  CryptoDecryptError.accept(e);
96278
96278
  cx.peerResumptionId = cx.peerResumeMic = void 0;
@@ -96296,8 +96296,8 @@ var init_CaseServer = __esm({
96296
96296
  // Session establishment could still fail, so add session ourselves to the manager
96297
96297
  });
96298
96298
  const resumeSalt = Bytes.concat(cx.peerRandom, cx.localResumptionId);
96299
- const resumeKey = await crypto7.createHkdfKey(sharedSecret, resumeSalt, KDFSR2_KEY_INFO);
96300
- const resumeMic = crypto7.encrypt(resumeKey, new Uint8Array(0), RESUME2_MIC_NONCE);
96299
+ const resumeKey = await crypto8.createHkdfKey(sharedSecret, resumeSalt, KDFSR2_KEY_INFO);
96300
+ const resumeMic = crypto8.encrypt(resumeKey, new Uint8Array(0), RESUME2_MIC_NONCE);
96301
96301
  try {
96302
96302
  const responderSessionParams = this.#sessions.sessionParameters;
96303
96303
  await cx.messenger.sendSigma2Resume({
@@ -96326,20 +96326,20 @@ var init_CaseServer = __esm({
96326
96326
  ) {
96327
96327
  return false;
96328
96328
  }
96329
- const { crypto: crypto7 } = this.#fabrics;
96330
- const responderRandom = crypto7.randomBytes(32);
96329
+ const { crypto: crypto8 } = this.#fabrics;
96330
+ const responderRandom = crypto8.randomBytes(32);
96331
96331
  const fabric = await this.#fabrics.findFabricFromDestinationId(cx.destinationId, cx.peerRandom);
96332
96332
  const { operationalCert: nodeOpCert, intermediateCACert, operationalIdentityProtectionKey } = fabric;
96333
- const key = await crypto7.createKeyPair();
96333
+ const key = await crypto8.createKeyPair();
96334
96334
  const responderEcdhPublicKey = key.publicBits;
96335
- const sharedSecret = await crypto7.generateDhSecret(key, PublicKey(cx.peerEcdhPublicKey));
96335
+ const sharedSecret = await crypto8.generateDhSecret(key, PublicKey(cx.peerEcdhPublicKey));
96336
96336
  const sigma2Salt = Bytes.concat(
96337
96337
  operationalIdentityProtectionKey,
96338
96338
  responderRandom,
96339
96339
  responderEcdhPublicKey,
96340
- await crypto7.computeHash(cx.bytes)
96340
+ await crypto8.computeHash(cx.bytes)
96341
96341
  );
96342
- const sigma2Key = await crypto7.createHkdfKey(sharedSecret, sigma2Salt, KDFSR2_INFO);
96342
+ const sigma2Key = await crypto8.createHkdfKey(sharedSecret, sigma2Salt, KDFSR2_INFO);
96343
96343
  const signatureData = TlvSignedData.encode({
96344
96344
  responderNoc: nodeOpCert,
96345
96345
  responderIcac: intermediateCACert,
@@ -96353,7 +96353,7 @@ var init_CaseServer = __esm({
96353
96353
  signature: signature.bytes,
96354
96354
  resumptionId: cx.localResumptionId
96355
96355
  });
96356
- const encrypted = crypto7.encrypt(sigma2Key, encryptedData, TBE_DATA2_NONCE);
96356
+ const encrypted = crypto8.encrypt(sigma2Key, encryptedData, TBE_DATA2_NONCE);
96357
96357
  const responderSessionId = await this.#sessions.getNextAvailableSessionId();
96358
96358
  const sigma2Bytes = await cx.messenger.sendSigma2({
96359
96359
  responderRandom,
@@ -96369,10 +96369,10 @@ var init_CaseServer = __esm({
96369
96369
  } = await cx.messenger.readSigma3();
96370
96370
  const sigma3Salt = Bytes.concat(
96371
96371
  operationalIdentityProtectionKey,
96372
- await crypto7.computeHash([cx.bytes, sigma2Bytes])
96372
+ await crypto8.computeHash([cx.bytes, sigma2Bytes])
96373
96373
  );
96374
- const sigma3Key = await crypto7.createHkdfKey(sharedSecret, sigma3Salt, KDFSR3_INFO);
96375
- const peerDecryptedData = crypto7.decrypt(sigma3Key, peerEncrypted, TBE_DATA3_NONCE);
96374
+ const sigma3Key = await crypto8.createHkdfKey(sharedSecret, sigma3Salt, KDFSR3_INFO);
96375
+ const peerDecryptedData = crypto8.decrypt(sigma3Key, peerEncrypted, TBE_DATA3_NONCE);
96376
96376
  const {
96377
96377
  responderNoc: peerNewOpCert,
96378
96378
  responderIcac: peerIntermediateCACert,
@@ -96392,10 +96392,10 @@ var init_CaseServer = __esm({
96392
96392
  if (fabric.fabricId !== peerFabricId) {
96393
96393
  throw new UnexpectedDataError(`Fabric ID mismatch: ${fabric.fabricId} !== ${peerFabricId}`);
96394
96394
  }
96395
- await crypto7.verifyEcdsa(PublicKey(peerPublicKey), peerSignatureData, new EcdsaSignature(peerSignature));
96395
+ await crypto8.verifyEcdsa(PublicKey(peerPublicKey), peerSignatureData, new EcdsaSignature(peerSignature));
96396
96396
  const secureSessionSalt = Bytes.concat(
96397
96397
  operationalIdentityProtectionKey,
96398
- await crypto7.computeHash([cx.bytes, sigma2Bytes, sigma3Bytes])
96398
+ await crypto8.computeHash([cx.bytes, sigma2Bytes, sigma3Bytes])
96399
96399
  );
96400
96400
  const secureSession = await this.#sessions.createSecureSession({
96401
96401
  channel,
@@ -96440,8 +96440,8 @@ var init_CaseServer = __esm({
96440
96440
  peerSessionParams;
96441
96441
  resumptionRecord;
96442
96442
  #localResumptionId;
96443
- constructor(crypto7, messenger, bytes, sigma1, resumptionRecord) {
96444
- this.crypto = crypto7;
96443
+ constructor(crypto8, messenger, bytes, sigma1, resumptionRecord) {
96444
+ this.crypto = crypto8;
96445
96445
  this.messenger = messenger;
96446
96446
  this.bytes = bytes;
96447
96447
  this.peerSessionId = sigma1.initiatorSessionId;
@@ -96937,25 +96937,25 @@ var init_PaseClient = __esm({
96937
96937
  constructor(sessions) {
96938
96938
  this.#sessions = sessions;
96939
96939
  }
96940
- static async generatePakePasscodeVerifier(crypto7, setupPinCode, pbkdfParameters) {
96941
- const { w0, L } = await Spake2p.computeW0L(crypto7, pbkdfParameters, setupPinCode);
96940
+ static async generatePakePasscodeVerifier(crypto8, setupPinCode, pbkdfParameters) {
96941
+ const { w0, L } = await Spake2p.computeW0L(crypto8, pbkdfParameters, setupPinCode);
96942
96942
  return Bytes.concat(numberToBytesBE3(w0, 32), L);
96943
96943
  }
96944
- static generateRandomPasscode(crypto7) {
96944
+ static generateRandomPasscode(crypto8) {
96945
96945
  let passcode;
96946
- passcode = crypto7.randomUint32 % 99999998 + 1;
96946
+ passcode = crypto8.randomUint32 % 99999998 + 1;
96947
96947
  if (CommissioningOptions.FORBIDDEN_PASSCODES.includes(passcode)) {
96948
96948
  passcode += 1;
96949
96949
  }
96950
96950
  return passcode;
96951
96951
  }
96952
- static generateRandomDiscriminator(crypto7) {
96953
- return crypto7.randomUint16 % 4096;
96952
+ static generateRandomDiscriminator(crypto8) {
96953
+ return crypto8.randomUint16 % 4096;
96954
96954
  }
96955
96955
  async pair(initiatorSessionParams, exchange, channel, setupPin) {
96956
96956
  const messenger = new PaseClientMessenger(exchange);
96957
- const { crypto: crypto7 } = this.#sessions;
96958
- const initiatorRandom = crypto7.randomBytes(32);
96957
+ const { crypto: crypto8 } = this.#sessions;
96958
+ const initiatorRandom = crypto8.randomBytes(32);
96959
96959
  const initiatorSessionId = await this.#sessions.getNextAvailableSessionId();
96960
96960
  const requestPayload = await messenger.sendPbkdfParamRequest({
96961
96961
  initiatorRandom,
@@ -96979,10 +96979,10 @@ var init_PaseClient = __esm({
96979
96979
  ...exchange.session.parameters,
96980
96980
  ...responderSessionParams ?? {}
96981
96981
  };
96982
- const { w0, w1 } = await Spake2p.computeW0W1(crypto7, pbkdfParameters, setupPin);
96982
+ const { w0, w1 } = await Spake2p.computeW0W1(crypto8, pbkdfParameters, setupPin);
96983
96983
  const spake2p = Spake2p.create(
96984
- crypto7,
96985
- await crypto7.computeHash([SPAKE_CONTEXT, requestPayload, responsePayload]),
96984
+ crypto8,
96985
+ await crypto8.computeHash([SPAKE_CONTEXT, requestPayload, responsePayload]),
96986
96986
  w0
96987
96987
  );
96988
96988
  const X = spake2p.computeX();
@@ -97093,7 +97093,7 @@ var init_PaseServer = __esm({
97093
97093
  }
97094
97094
  }
97095
97095
  }
97096
- async handlePairingRequest(crypto7, channel) {
97096
+ async handlePairingRequest(crypto8, channel) {
97097
97097
  const messenger = this.#pairingMessenger;
97098
97098
  logger40.info("Received pairing request", Mark.INBOUND, Diagnostic.via(messenger.channelName));
97099
97099
  this.#pairingTimer = Time.getTimer(
@@ -97115,7 +97115,7 @@ var init_PaseServer = __esm({
97115
97115
  throw new UnexpectedDataError(`Unsupported passcode ID ${passcodeId}.`);
97116
97116
  }
97117
97117
  const responderSessionId = await this.sessions.getNextAvailableSessionId();
97118
- const responderRandom = crypto7.randomBytes(32);
97118
+ const responderRandom = crypto8.randomBytes(32);
97119
97119
  const responderSessionParams = this.sessions.sessionParameters;
97120
97120
  if (initiatorSessionParams !== void 0) {
97121
97121
  messenger.channel.session.timingParameters = initiatorSessionParams;
@@ -97128,8 +97128,8 @@ var init_PaseServer = __esm({
97128
97128
  responderSessionParams
97129
97129
  });
97130
97130
  const spake2p = Spake2p.create(
97131
- crypto7,
97132
- await crypto7.computeHash([SPAKE_CONTEXT, requestPayload, responsePayload]),
97131
+ crypto8,
97132
+ await crypto8.computeHash([SPAKE_CONTEXT, requestPayload, responsePayload]),
97133
97133
  this.w0
97134
97134
  );
97135
97135
  const { x: X } = await messenger.readPasePake1();
@@ -97197,14 +97197,14 @@ var init_UnsecuredSession = __esm({
97197
97197
  supportsMRP = true;
97198
97198
  type = SessionType.Unicast;
97199
97199
  constructor(config10) {
97200
- const { crypto: crypto7, initiatorNodeId, isInitiator } = config10;
97200
+ const { crypto: crypto8, initiatorNodeId, isInitiator } = config10;
97201
97201
  super({
97202
97202
  ...config10,
97203
97203
  setActiveTimestamp: !isInitiator,
97204
97204
  // When we are the initiator we assume the node is in idle mode
97205
97205
  messageReceptionState: new MessageReceptionStateUnencryptedWithRollover()
97206
97206
  });
97207
- this.#initiatorNodeId = initiatorNodeId ?? NodeId.randomOperationalNodeId(crypto7);
97207
+ this.#initiatorNodeId = initiatorNodeId ?? NodeId.randomOperationalNodeId(crypto8);
97208
97208
  }
97209
97209
  get isSecure() {
97210
97210
  return false;
@@ -97291,11 +97291,11 @@ var init_SessionManager = __esm({
97291
97291
  constructor(context) {
97292
97292
  this.#context = context;
97293
97293
  const {
97294
- fabrics: { crypto: crypto7 }
97294
+ fabrics: { crypto: crypto8 }
97295
97295
  } = context;
97296
97296
  this.#sessionParameters = SessionParameters({ ...SessionParameters.defaults, ...context.parameters });
97297
- this.#nextSessionId = crypto7.randomUint16;
97298
- this.#globalUnencryptedMessageCounter = new MessageCounter(crypto7);
97297
+ this.#nextSessionId = crypto8.randomUint16;
97298
+ this.#globalUnencryptedMessageCounter = new MessageCounter(crypto8);
97299
97299
  this.#observers.on(context.fabrics.events.deleting, async (fabric) => {
97300
97300
  await this.deleteResumptionRecordsForFabric(fabric);
97301
97301
  });
@@ -100871,18 +100871,18 @@ var init_ProtocolMocks = __esm({
100871
100871
  init_MessageExchange();
100872
100872
  ((ProtocolMocks2) => {
100873
100873
  class Fabric2 extends Fabric {
100874
- constructor(config10, crypto7) {
100875
- if (!crypto7) {
100876
- crypto7 = Environment.default.maybeGet(Crypto);
100877
- if (!(crypto7 instanceof MockCrypto)) {
100878
- crypto7 = MockCrypto();
100874
+ constructor(config10, crypto8) {
100875
+ if (!crypto8) {
100876
+ crypto8 = Environment.default.maybeGet(Crypto);
100877
+ if (!(crypto8 instanceof MockCrypto)) {
100878
+ crypto8 = MockCrypto();
100879
100879
  }
100880
100880
  }
100881
- const keyPair = config10?.keyPair ?? crypto7.createKeyPair();
100881
+ const keyPair = config10?.keyPair ?? crypto8.createKeyPair();
100882
100882
  if (MaybePromise.is(keyPair)) {
100883
100883
  throw new ImplementationError("Must provide key pair with async crypto");
100884
100884
  }
100885
- super(crypto7, {
100885
+ super(crypto8, {
100886
100886
  ...Fabric2.defaults,
100887
100887
  ...config10,
100888
100888
  keyPair
@@ -100912,7 +100912,7 @@ var init_ProtocolMocks = __esm({
100912
100912
  constructor(config10) {
100913
100913
  const index = config10?.index ?? 1;
100914
100914
  const fabricIndex = config10?.fabricIndex ?? 1;
100915
- const crypto7 = config10?.crypto ?? Environment.default.get(Crypto);
100915
+ const crypto8 = config10?.crypto ?? Environment.default.get(Crypto);
100916
100916
  const fabric = config10 && "fabric" in config10 ? config10.fabric : new Fabric2({ fabricIndex });
100917
100917
  const maxPayloadSize = config10?.maxPayloadSize;
100918
100918
  let channel;
@@ -100931,7 +100931,7 @@ var init_ProtocolMocks = __esm({
100931
100931
  encryptKey: Bytes.empty,
100932
100932
  isInitiator: true,
100933
100933
  ...config10,
100934
- crypto: crypto7,
100934
+ crypto: crypto8,
100935
100935
  fabric
100936
100936
  };
100937
100937
  delete fullConfig.channel;
@@ -100940,11 +100940,11 @@ var init_ProtocolMocks = __esm({
100940
100940
  this.lifetime = Lifetime.mock;
100941
100941
  }
100942
100942
  static async create(config10) {
100943
- const crypto7 = config10?.crypto ?? config10?.manager?.crypto ?? Environment.default.get(Crypto);
100943
+ const crypto8 = config10?.crypto ?? config10?.manager?.crypto ?? Environment.default.get(Crypto);
100944
100944
  const index = config10?.index ?? 1;
100945
100945
  return NodeSession.create.call(this, {
100946
100946
  id: index,
100947
- crypto: crypto7,
100947
+ crypto: crypto8,
100948
100948
  peerNodeId: NodeId(0),
100949
100949
  peerSessionId: index,
100950
100950
  sharedSecret: Bytes.empty,
@@ -106671,9 +106671,9 @@ var init_MdnsAdvertiser = __esm({
106671
106671
  init_CommissionerMdnsAdvertisement();
106672
106672
  init_OperationalMdnsAdvertisement();
106673
106673
  MdnsAdvertiser = class _MdnsAdvertiser extends Advertiser {
106674
- constructor(crypto7, server, options) {
106674
+ constructor(crypto8, server, options) {
106675
106675
  super(options?.lifetime);
106676
- this.crypto = crypto7;
106676
+ this.crypto = crypto8;
106677
106677
  this.server = server;
106678
106678
  this.port = options?.port ?? STANDARD_MATTER_PORT;
106679
106679
  this.omitPrivateDetails = options?.omitPrivateDetails ?? false;
@@ -108118,8 +108118,8 @@ var init_AttestationCertificates = __esm({
108118
108118
  * Sign the certificate using the provided crypto and key.
108119
108119
  * If the certificate is already signed, it throws a CertificateError.
108120
108120
  */
108121
- async sign(crypto7, key) {
108122
- this.signature = await crypto7.signEcdsa(key, this.asUnsignedDer());
108121
+ async sign(crypto8, key) {
108122
+ this.signature = await crypto8.signEcdsa(key, this.asUnsignedDer());
108123
108123
  }
108124
108124
  };
108125
108125
  Paa = class _Paa extends AttestationBaseCertificate {
@@ -108168,17 +108168,17 @@ var init_AttestationCertificateManager = __esm({
108168
108168
  #paiCertId = BigInt(1);
108169
108169
  #paiCertBytes;
108170
108170
  #nextCertificateId = 2;
108171
- constructor(crypto7, vendorId3, paiKeyPair, paiKeyIdentifier) {
108172
- this.#crypto = crypto7;
108171
+ constructor(crypto8, vendorId3, paiKeyPair, paiKeyIdentifier) {
108172
+ this.#crypto = crypto8;
108173
108173
  this.#vendorId = vendorId3;
108174
108174
  this.#paiKeyPair = paiKeyPair;
108175
108175
  this.#paiKeyIdentifier = paiKeyIdentifier;
108176
108176
  this.#paiCertBytes = this.generatePAICert(vendorId3);
108177
108177
  }
108178
- static async create(crypto7, vendorId3) {
108179
- const key = await crypto7.createKeyPair();
108180
- const identifier = Bytes.of(await crypto7.computeHash(key.publicKey));
108181
- return new _AttestationCertificateManager(crypto7, vendorId3, key, identifier.slice(0, 20));
108178
+ static async create(crypto8, vendorId3) {
108179
+ const key = await crypto8.createKeyPair();
108180
+ const identifier = Bytes.of(await crypto8.computeHash(key.publicKey));
108181
+ return new _AttestationCertificateManager(crypto8, vendorId3, key, identifier.slice(0, 20));
108182
108182
  }
108183
108183
  getPAICert() {
108184
108184
  return this.#paiCertBytes;
@@ -108324,11 +108324,11 @@ var init_CertificateAuthority = __esm({
108324
108324
  get construction() {
108325
108325
  return this.#construction;
108326
108326
  }
108327
- static async create(crypto7, options, generateIntermediateCert) {
108328
- return asyncNew(_CertificateAuthority, crypto7, options, generateIntermediateCert);
108327
+ static async create(crypto8, options, generateIntermediateCert) {
108328
+ return asyncNew(_CertificateAuthority, crypto8, options, generateIntermediateCert);
108329
108329
  }
108330
- constructor(crypto7, options, generateIntermediateCert) {
108331
- this.#crypto = crypto7;
108330
+ constructor(crypto8, options, generateIntermediateCert) {
108331
+ this.#crypto = crypto8;
108332
108332
  this.#construction = Construction(this, async () => {
108333
108333
  if (typeof options === "boolean") {
108334
108334
  generateIntermediateCert = options;
@@ -108610,7 +108610,7 @@ var init_CertificationDeclaration = __esm({
108610
108610
  * Generator which is the main usage for the class from outside.
108611
108611
  * It constructs the class with the relevant details and returns a signed ASN.1 DER version of the CD.
108612
108612
  */
108613
- static generate(crypto7, vendorId3, productId, provisional = false) {
108613
+ static generate(crypto8, vendorId3, productId, provisional = false) {
108614
108614
  const cd = new _CertificationDeclaration(
108615
108615
  {
108616
108616
  formatVersion: 1,
@@ -108626,7 +108626,7 @@ var init_CertificationDeclaration = __esm({
108626
108626
  },
108627
108627
  TestCMS_SignerSubjectKeyIdentifier
108628
108628
  );
108629
- return cd.asSignedAsn1(crypto7, PrivateKey(TestCMS_SignerPrivateKey));
108629
+ return cd.asSignedAsn1(crypto8, PrivateKey(TestCMS_SignerPrivateKey));
108630
108630
  }
108631
108631
  constructor(content, subjectKeyIdentifier) {
108632
108632
  this.#eContent = CertificationDeclaration.TlvDc.encode(content);
@@ -108635,7 +108635,7 @@ var init_CertificationDeclaration = __esm({
108635
108635
  /**
108636
108636
  * Returns the signed certificate in ASN.1 DER format.
108637
108637
  */
108638
- async asSignedAsn1(crypto7, privateKey) {
108638
+ async asSignedAsn1(crypto8, privateKey) {
108639
108639
  const cert = {
108640
108640
  version: 3,
108641
108641
  digestAlgorithm: [Shs.SHA256_CMS],
@@ -108646,7 +108646,7 @@ var init_CertificationDeclaration = __esm({
108646
108646
  subjectKeyIdentifier: ContextTaggedBytes(0, this.#subjectKeyIdentifier),
108647
108647
  digestAlgorithm: Shs.SHA256_CMS,
108648
108648
  signatureAlgorithm: X962.EcdsaWithSHA256,
108649
- signature: (await crypto7.signEcdsa(privateKey, this.#eContent)).der
108649
+ signature: (await crypto8.signEcdsa(privateKey, this.#eContent)).der
108650
108650
  }
108651
108651
  ]
108652
108652
  };
@@ -108684,8 +108684,8 @@ var init_DeviceCertification = __esm({
108684
108684
  get declaration() {
108685
108685
  return this.#assertInitialized().declaration;
108686
108686
  }
108687
- constructor(crypto7, config10, product) {
108688
- this.#crypto = crypto7;
108687
+ constructor(crypto8, config10, product) {
108688
+ this.#crypto = crypto8;
108689
108689
  let configProvider;
108690
108690
  if (typeof config10 === "function") {
108691
108691
  configProvider = config10;
@@ -108696,13 +108696,13 @@ var init_DeviceCertification = __esm({
108696
108696
  if (product === void 0) {
108697
108697
  throw new ImplementationError(`Cannot generate device certification without product information`);
108698
108698
  }
108699
- const paa = await AttestationCertificateManager.create(crypto7, product.vendorId);
108699
+ const paa = await AttestationCertificateManager.create(crypto8, product.vendorId);
108700
108700
  const { keyPair: dacKeyPair, dac } = await paa.getDACert(product.productId);
108701
108701
  return {
108702
108702
  privateKey: PrivateKey(dacKeyPair.privateKey),
108703
108703
  certificate: dac,
108704
108704
  intermediateCertificate: await paa.getPAICert(),
108705
- declaration: await CertificationDeclaration2.generate(crypto7, product.vendorId, product.productId)
108705
+ declaration: await CertificationDeclaration2.generate(crypto8, product.vendorId, product.productId)
108706
108706
  };
108707
108707
  };
108708
108708
  }
@@ -109493,8 +109493,8 @@ var init_OtaImageReader = __esm({
109493
109493
  return reader.#headerData;
109494
109494
  }
109495
109495
  /** Read and validate the full OTA image file from the stream and returns the header data on success. */
109496
- static async file(streamReader, crypto7, expectedTotalSize, options) {
109497
- const reader = new _OtaImageReader(streamReader, crypto7);
109496
+ static async file(streamReader, crypto8, expectedTotalSize, options) {
109497
+ const reader = new _OtaImageReader(streamReader, crypto8);
109498
109498
  if (options?.checksumType !== void 0) {
109499
109499
  reader.#fullFileChecksumType = options.checksumType;
109500
109500
  }
@@ -109528,8 +109528,8 @@ var init_OtaImageReader = __esm({
109528
109528
  * Read and validate OTA file, extracting payload to a writable stream.
109529
109529
  * Returns the header information after successful validation and extraction.
109530
109530
  */
109531
- static async extractPayload(streamReader, payloadWriter, crypto7, expectedTotalSize) {
109532
- const reader = new _OtaImageReader(streamReader, crypto7);
109531
+ static async extractPayload(streamReader, payloadWriter, crypto8, expectedTotalSize) {
109532
+ const reader = new _OtaImageReader(streamReader, crypto8);
109533
109533
  const { remainingData } = await reader.#processHeader(false);
109534
109534
  if (reader.#headerData === void 0) {
109535
109535
  throw new InternalError("OTA header not read");
@@ -109545,9 +109545,9 @@ var init_OtaImageReader = __esm({
109545
109545
  }
109546
109546
  return reader.#headerData;
109547
109547
  }
109548
- constructor(streamReader, crypto7) {
109548
+ constructor(streamReader, crypto8) {
109549
109549
  this.#streamReader = streamReader;
109550
- this.#crypto = crypto7;
109550
+ this.#crypto = crypto8;
109551
109551
  }
109552
109552
  get totalSize() {
109553
109553
  return this.#totalSize;
@@ -125833,8 +125833,8 @@ var init_VendorIdVerification = __esm({
125833
125833
  }
125834
125834
  VendorIdVerification2.dataToSign = dataToSign;
125835
125835
  async function verify(node, options) {
125836
- const crypto7 = node.env.get(Crypto);
125837
- const clientChallenge = crypto7.randomBytes(32);
125836
+ const crypto8 = node.env.get(Crypto);
125837
+ const clientChallenge = crypto8.randomBytes(32);
125838
125838
  const {
125839
125839
  fabric: { fabricIndex }
125840
125840
  } = options;
@@ -125857,7 +125857,7 @@ var init_VendorIdVerification = __esm({
125857
125857
  return void 0;
125858
125858
  }
125859
125859
  const { noc, rcac, fabric } = options;
125860
- return await verifyData(crypto7, {
125860
+ return await verifyData(crypto8, {
125861
125861
  clientChallenge,
125862
125862
  attChallenge: session.attestationChallengeKey,
125863
125863
  signVerificationResponse,
@@ -125867,7 +125867,7 @@ var init_VendorIdVerification = __esm({
125867
125867
  });
125868
125868
  }
125869
125869
  VendorIdVerification2.verify = verify;
125870
- async function verifyData(crypto7, options) {
125870
+ async function verifyData(crypto8, options) {
125871
125871
  const {
125872
125872
  clientChallenge,
125873
125873
  attChallenge,
@@ -125893,14 +125893,14 @@ var init_VendorIdVerification = __esm({
125893
125893
  }
125894
125894
  }).signatureData;
125895
125895
  try {
125896
- await crypto7.verifyEcdsa(PublicKey(rootPublicKey), tbs, new EcdsaSignature(signature));
125896
+ await crypto8.verifyEcdsa(PublicKey(rootPublicKey), tbs, new EcdsaSignature(signature));
125897
125897
  const rootCert = Rcac.fromTlv(rcac);
125898
125898
  const nocCert = Noc.fromTlv(noc);
125899
125899
  const icaCert = icac ? Icac.fromTlv(icac) : void 0;
125900
125900
  if (icaCert !== void 0) {
125901
- await icaCert.verify(crypto7, rootCert);
125901
+ await icaCert.verify(crypto8, rootCert);
125902
125902
  }
125903
- await nocCert.verify(crypto7, rootCert, icaCert);
125903
+ await nocCert.verify(crypto8, rootCert, icaCert);
125904
125904
  } catch (error) {
125905
125905
  CryptoError.accept(error);
125906
125906
  logger103.error("Could not verify VendorId", error);
@@ -125930,13 +125930,13 @@ var init_VendorIdVerification = __esm({
125930
125930
  `VVSC SubjectKeyIdentifier does not match signerSkid in VID Verification Statement`
125931
125931
  );
125932
125932
  }
125933
- await vvscCert.verify(crypto7);
125933
+ await vvscCert.verify(crypto8);
125934
125934
  const ourStatement = createStatementBytes({
125935
125935
  version: vidStatementVersion,
125936
125936
  fabricBindingMessage: tbs,
125937
125937
  signerSkid
125938
125938
  });
125939
- await crypto7.verifyEcdsa(
125939
+ await crypto8.verifyEcdsa(
125940
125940
  PublicKey(ellipticCurvePublicKey),
125941
125941
  ourStatement,
125942
125942
  new EcdsaSignature(vidStatementSignature)
@@ -130205,8 +130205,8 @@ var init_OtaSoftwareUpdateProviderServer = __esm({
130205
130205
  // the usual bdx session timeout is 5 minutes, so let's use this
130206
130206
  };
130207
130207
  }
130208
- const crypto7 = this.env.get(Crypto);
130209
- const updateToken = crypto7.randomBytes(OTA_UPDATE_TOKEN_LENGTH_BYTES);
130208
+ const crypto8 = this.env.get(Crypto);
130209
+ const updateToken = crypto8.randomBytes(OTA_UPDATE_TOKEN_LENGTH_BYTES);
130210
130210
  if (consentRequired && !request.requestorCanConsent) {
130211
130211
  this.#updateInProgressDetails(peerAddress, updateToken, OtaUpdateStatus.WaitForConsent, newSoftwareVersion);
130212
130212
  const { consentState, delayTime = Seconds(120) } = await this.requestUserConsentForUpdate(
@@ -132681,8 +132681,8 @@ var init_OtaSoftwareUpdateRequestorServer = __esm({
132681
132681
  try {
132682
132682
  const blob = await this.downloadLocation.openBlob();
132683
132683
  totalSize = blob.size;
132684
- const crypto7 = this.env.get(Crypto);
132685
- const header = await OtaImageReader.file(blob.stream().getReader(), crypto7);
132684
+ const crypto8 = this.env.get(Crypto);
132685
+ const header = await OtaImageReader.file(blob.stream().getReader(), crypto8);
132686
132686
  const { softwareVersion: otaFileSoftwareVersion } = header;
132687
132687
  if (newSoftwareVersion === void 0) {
132688
132688
  const { softwareVersion: currentSoftwareVersion } = this.#basicInformationState();
@@ -141853,9 +141853,9 @@ var init_ServerNetworkRuntime = __esm({
141853
141853
  lifetime: this.construction,
141854
141854
  ...this.owner.state.commissioning.mdns
141855
141855
  };
141856
- const crypto7 = this.owner.env.get(Crypto);
141856
+ const crypto8 = this.owner.env.get(Crypto);
141857
141857
  const { server } = this.#services.get(MdnsService);
141858
- this.#mdnsAdvertiser = new MdnsAdvertiser(crypto7, server, { ...options, port });
141858
+ this.#mdnsAdvertiser = new MdnsAdvertiser(crypto8, server, { ...options, port });
141859
141859
  }
141860
141860
  return this.#mdnsAdvertiser;
141861
141861
  }
@@ -145421,14 +145421,14 @@ function rootDirOf(env) {
145421
145421
  function configureCrypto(env) {
145422
145422
  Boot.init(() => {
145423
145423
  if (env.vars.boolean("nodejs.crypto")) {
145424
- let crypto7;
145424
+ let crypto8;
145425
145425
  if (!isBunjs()) {
145426
- crypto7 = new NodeJsCrypto();
145426
+ crypto8 = new NodeJsCrypto();
145427
145427
  } else {
145428
- crypto7 = new StandardCrypto(global.crypto);
145428
+ crypto8 = new StandardCrypto(global.crypto);
145429
145429
  }
145430
- env.set(Entropy, crypto7);
145431
- env.set(Crypto, crypto7);
145430
+ env.set(Entropy, crypto8);
145431
+ env.set(Crypto, crypto8);
145432
145432
  return;
145433
145433
  }
145434
145434
  if (Environment.default.has(Entropy)) {
@@ -159417,6 +159417,7 @@ var DimmablePlugInUnitDeviceDefinition = MutableEndpoint({
159417
159417
  )
159418
159418
  });
159419
159419
  Object.freeze(DimmablePlugInUnitDeviceDefinition);
159420
+ var DimmablePlugInUnitDevice = DimmablePlugInUnitDeviceDefinition;
159420
159421
 
159421
159422
  // ../../node_modules/.pnpm/@matter+node@0.16.10/node_modules/@matter/node/dist/esm/devices/dimmer-switch.js
159422
159423
  init_IdentifyServer();
@@ -164696,10 +164697,6 @@ import * as path12 from "node:path";
164696
164697
  // src/plugins/plugin-device-factory.ts
164697
164698
  init_esm();
164698
164699
 
164699
- // src/matter/behaviors/basic-information-server.ts
164700
- init_esm7();
164701
- import crypto4 from "node:crypto";
164702
-
164703
164700
  // ../../node_modules/.pnpm/@matter+main@0.16.10/node_modules/@matter/main/dist/esm/behaviors.js
164704
164701
  init_nodejs();
164705
164702
 
@@ -165657,6 +165654,65 @@ init_window_covering();
165657
165654
  init_ClientBehavior();
165658
165655
  var WindowCoveringClientConstructor = ClientBehavior(WindowCovering3.Complete);
165659
165656
 
165657
+ // src/matter/behaviors/identify-server.ts
165658
+ var IdentifyServer2 = class extends IdentifyServer {
165659
+ };
165660
+
165661
+ // src/matter/endpoints/validate-endpoint-type.ts
165662
+ init_esm();
165663
+ init_esm7();
165664
+ var logger158 = Logger.get("EndpointValidation");
165665
+ function toCamelCase(name) {
165666
+ return name.charAt(0).toLowerCase() + name.slice(1);
165667
+ }
165668
+ function validateEndpointType(endpointType, entityId) {
165669
+ const deviceTypeModel = Matter.deviceTypes.find(
165670
+ (dt) => dt.id === endpointType.deviceType
165671
+ );
165672
+ if (!deviceTypeModel) {
165673
+ return void 0;
165674
+ }
165675
+ const serverClusterReqs = deviceTypeModel.requirements.filter(
165676
+ (r) => r.element === "serverCluster"
165677
+ );
165678
+ const behaviorKeys = new Set(Object.keys(endpointType.behaviors));
165679
+ const missingMandatory = [];
165680
+ const availableOptional = [];
165681
+ const presentClusters = [];
165682
+ for (const req of serverClusterReqs) {
165683
+ const key = toCamelCase(req.name);
165684
+ if (behaviorKeys.has(key)) {
165685
+ presentClusters.push(req.name);
165686
+ } else if (req.isMandatory) {
165687
+ missingMandatory.push(req.name);
165688
+ } else {
165689
+ availableOptional.push(req.name);
165690
+ }
165691
+ }
165692
+ const prefix = entityId ? `[${entityId}] ` : "";
165693
+ if (missingMandatory.length > 0) {
165694
+ logger158.warn(
165695
+ `${prefix}${deviceTypeModel.name} (0x${endpointType.deviceType.toString(16)}): missing mandatory clusters: ${missingMandatory.join(", ")}`
165696
+ );
165697
+ }
165698
+ if (availableOptional.length > 0) {
165699
+ logger158.debug(
165700
+ `${prefix}${deviceTypeModel.name} (0x${endpointType.deviceType.toString(16)}): optional clusters not used: ${availableOptional.join(", ")}`
165701
+ );
165702
+ }
165703
+ return {
165704
+ deviceTypeName: deviceTypeModel.name,
165705
+ deviceTypeId: endpointType.deviceType,
165706
+ missingMandatory,
165707
+ availableOptional,
165708
+ presentClusters
165709
+ };
165710
+ }
165711
+
165712
+ // src/plugins/plugin-basic-information-server.ts
165713
+ init_esm7();
165714
+ import crypto4 from "node:crypto";
165715
+
165660
165716
  // src/services/bridges/bridge-data-provider.ts
165661
165717
  init_service();
165662
165718
  import { values as values2 } from "lodash-es";
@@ -165745,7 +165801,7 @@ var BridgeDataProvider = class extends Service {
165745
165801
 
165746
165802
  // src/utils/apply-patch-state.ts
165747
165803
  init_esm();
165748
- var logger158 = Logger.get("ApplyPatchState");
165804
+ var logger159 = Logger.get("ApplyPatchState");
165749
165805
  function applyPatchState(state, patch, options) {
165750
165806
  return applyPatch(state, patch, options?.force);
165751
165807
  }
@@ -165772,23 +165828,23 @@ function applyPatch(state, patch, force = false) {
165772
165828
  if (errorMessage.includes(
165773
165829
  "Endpoint storage inaccessible because endpoint is not a node and is not owned by another endpoint"
165774
165830
  )) {
165775
- logger158.debug(
165831
+ logger159.debug(
165776
165832
  `Suppressed endpoint storage error, patch not applied: ${JSON.stringify(actualPatch)}`
165777
165833
  );
165778
165834
  return actualPatch;
165779
165835
  }
165780
165836
  if (errorMessage.includes("synchronous-transaction-conflict")) {
165781
- logger158.warn(
165837
+ logger159.warn(
165782
165838
  `Transaction conflict, state update DROPPED: ${JSON.stringify(actualPatch)}`
165783
165839
  );
165784
165840
  return actualPatch;
165785
165841
  }
165786
165842
  failedKeys.push(key);
165787
- logger158.warn(`Failed to set property '${key}': ${errorMessage}`);
165843
+ logger159.warn(`Failed to set property '${key}': ${errorMessage}`);
165788
165844
  }
165789
165845
  }
165790
165846
  if (failedKeys.length > 0) {
165791
- logger158.warn(
165847
+ logger159.warn(
165792
165848
  `${failedKeys.length} properties failed to update: [${failedKeys.join(", ")}]`
165793
165849
  );
165794
165850
  }
@@ -165811,56 +165867,6 @@ function deepEqual(a, b) {
165811
165867
  return a === b;
165812
165868
  }
165813
165869
 
165814
- // src/matter/behaviors/basic-information-server.ts
165815
- init_home_assistant_entity_behavior();
165816
- var BasicInformationServer2 = class extends BridgedDeviceBasicInformationServer {
165817
- async initialize() {
165818
- await super.initialize();
165819
- const homeAssistant = await this.agent.load(HomeAssistantEntityBehavior);
165820
- this.update(homeAssistant.entity);
165821
- this.reactTo(homeAssistant.onChange, this.update);
165822
- }
165823
- update(entity) {
165824
- if (!entity.state) {
165825
- return;
165826
- }
165827
- const { basicInformation } = this.env.get(BridgeDataProvider);
165828
- const homeAssistant = this.agent.get(HomeAssistantEntityBehavior);
165829
- const device = entity.deviceRegistry;
165830
- applyPatchState(this.state, {
165831
- vendorId: VendorId(basicInformation.vendorId),
165832
- vendorName: ellipse(32, device?.manufacturer) ?? hash(32, basicInformation.vendorName),
165833
- productName: ellipse(32, device?.model_id) ?? ellipse(32, device?.model) ?? hash(32, basicInformation.productName),
165834
- productLabel: ellipse(64, device?.model) ?? hash(64, basicInformation.productLabel),
165835
- hardwareVersion: basicInformation.hardwareVersion,
165836
- softwareVersion: basicInformation.softwareVersion,
165837
- hardwareVersionString: ellipse(64, device?.hw_version),
165838
- softwareVersionString: ellipse(64, device?.sw_version),
165839
- nodeLabel: ellipse(32, homeAssistant.state.customName) ?? ellipse(32, entity.state?.attributes?.friendly_name) ?? ellipse(32, entity.entity_id),
165840
- reachable: entity.state?.state != null && entity.state.state !== "unavailable",
165841
- // The device serial number is available in `device?.serial_number`, but
165842
- // we're keeping it as the entity ID for now to avoid breaking existing
165843
- // deployments.
165844
- serialNumber: hash(32, entity.entity_id),
165845
- // UniqueId helps controllers (especially Alexa) identify devices across
165846
- // multiple fabric connections. Using MD5 hash of entity_id for stability.
165847
- uniqueId: crypto4.createHash("md5").update(entity.entity_id).digest("hex").substring(0, 32)
165848
- });
165849
- }
165850
- };
165851
- function ellipse(maxLength, value) {
165852
- return trimToLength(value, maxLength, "...");
165853
- }
165854
- function hash(maxLength, value) {
165855
- const hashLength = 4;
165856
- const suffix = crypto4.createHash("md5").update(value ?? "").digest("hex").substring(0, hashLength);
165857
- return trimToLength(value, maxLength, suffix);
165858
- }
165859
-
165860
- // src/matter/behaviors/identify-server.ts
165861
- var IdentifyServer2 = class extends IdentifyServer {
165862
- };
165863
-
165864
165870
  // src/plugins/plugin-behavior.ts
165865
165871
  init_esm7();
165866
165872
  var PluginDeviceBehavior = class extends Behavior {
@@ -165884,72 +165890,142 @@ var PluginDeviceBehavior = class extends Behavior {
165884
165890
  PluginDeviceBehavior2.Events = Events2;
165885
165891
  })(PluginDeviceBehavior || (PluginDeviceBehavior = {}));
165886
165892
 
165893
+ // src/plugins/plugin-basic-information-server.ts
165894
+ var PluginBasicInformationServer = class extends BridgedDeviceBasicInformationServer {
165895
+ async initialize() {
165896
+ await super.initialize();
165897
+ const pluginDevice = this.agent.get(PluginDeviceBehavior);
165898
+ const device = pluginDevice.device;
165899
+ const { basicInformation } = this.env.get(BridgeDataProvider);
165900
+ applyPatchState(this.state, {
165901
+ vendorId: VendorId(basicInformation.vendorId),
165902
+ vendorName: truncate(32, pluginDevice.pluginName),
165903
+ productName: truncate(32, device.deviceType),
165904
+ nodeLabel: truncate(32, device.name),
165905
+ serialNumber: crypto4.createHash("md5").update(`plugin_${device.id}`).digest("hex").substring(0, 32),
165906
+ uniqueId: crypto4.createHash("md5").update(`plugin_${device.id}`).digest("hex").substring(0, 32),
165907
+ reachable: true
165908
+ });
165909
+ }
165910
+ };
165911
+ function truncate(maxLength, value) {
165912
+ if (value.length <= maxLength) return value;
165913
+ return `${value.substring(0, maxLength - 3)}...`;
165914
+ }
165915
+
165887
165916
  // src/plugins/plugin-device-factory.ts
165888
- var logger159 = Logger.get("PluginDeviceFactory");
165917
+ var logger160 = Logger.get("PluginDeviceFactory");
165889
165918
  var deviceTypeMap = {
165890
165919
  on_off_light: () => OnOffLightDevice.with(
165891
165920
  IdentifyServer2,
165892
- BasicInformationServer2,
165921
+ PluginBasicInformationServer,
165893
165922
  PluginDeviceBehavior
165894
165923
  ),
165895
165924
  dimmable_light: () => DimmableLightDevice.with(
165896
165925
  IdentifyServer2,
165897
- BasicInformationServer2,
165926
+ PluginBasicInformationServer,
165927
+ PluginDeviceBehavior
165928
+ ),
165929
+ color_temperature_light: () => ColorTemperatureLightDevice.with(
165930
+ IdentifyServer2,
165931
+ PluginBasicInformationServer,
165932
+ PluginDeviceBehavior
165933
+ ),
165934
+ extended_color_light: () => ExtendedColorLightDevice.with(
165935
+ IdentifyServer2,
165936
+ PluginBasicInformationServer,
165898
165937
  PluginDeviceBehavior
165899
165938
  ),
165900
165939
  on_off_plugin_unit: () => OnOffPlugInUnitDevice.with(
165901
165940
  IdentifyServer2,
165902
- BasicInformationServer2,
165941
+ PluginBasicInformationServer,
165942
+ PluginDeviceBehavior
165943
+ ),
165944
+ dimmable_plug_in_unit: () => DimmablePlugInUnitDevice.with(
165945
+ IdentifyServer2,
165946
+ PluginBasicInformationServer,
165903
165947
  PluginDeviceBehavior
165904
165948
  ),
165905
165949
  temperature_sensor: () => TemperatureSensorDevice.with(
165906
165950
  IdentifyServer2,
165907
- BasicInformationServer2,
165951
+ PluginBasicInformationServer,
165908
165952
  PluginDeviceBehavior
165909
165953
  ),
165910
165954
  humidity_sensor: () => HumiditySensorDevice.with(
165911
165955
  IdentifyServer2,
165912
- BasicInformationServer2,
165956
+ PluginBasicInformationServer,
165957
+ PluginDeviceBehavior
165958
+ ),
165959
+ pressure_sensor: () => PressureSensorDevice.with(
165960
+ IdentifyServer2,
165961
+ PluginBasicInformationServer,
165962
+ PluginDeviceBehavior
165963
+ ),
165964
+ flow_sensor: () => FlowSensorDevice.with(
165965
+ IdentifyServer2,
165966
+ PluginBasicInformationServer,
165913
165967
  PluginDeviceBehavior
165914
165968
  ),
165915
165969
  light_sensor: () => LightSensorDevice.with(
165916
165970
  IdentifyServer2,
165917
- BasicInformationServer2,
165971
+ PluginBasicInformationServer,
165918
165972
  PluginDeviceBehavior
165919
165973
  ),
165920
165974
  occupancy_sensor: () => OccupancySensorDevice.with(
165921
165975
  IdentifyServer2,
165922
- BasicInformationServer2,
165976
+ PluginBasicInformationServer,
165923
165977
  PluginDeviceBehavior
165924
165978
  ),
165925
165979
  contact_sensor: () => ContactSensorDevice.with(
165926
165980
  IdentifyServer2,
165927
- BasicInformationServer2,
165981
+ PluginBasicInformationServer,
165982
+ PluginDeviceBehavior
165983
+ ),
165984
+ air_quality_sensor: () => AirQualitySensorDevice.with(
165985
+ IdentifyServer2,
165986
+ PluginBasicInformationServer,
165928
165987
  PluginDeviceBehavior
165929
165988
  ),
165930
165989
  thermostat: () => ThermostatDevice.with(
165931
165990
  IdentifyServer2,
165932
- BasicInformationServer2,
165991
+ PluginBasicInformationServer,
165933
165992
  PluginDeviceBehavior
165934
165993
  ),
165935
165994
  door_lock: () => DoorLockDevice.with(
165936
165995
  IdentifyServer2,
165937
- BasicInformationServer2,
165996
+ PluginBasicInformationServer,
165938
165997
  PluginDeviceBehavior
165939
165998
  ),
165940
165999
  fan: () => FanDevice.with(
165941
166000
  IdentifyServer2,
165942
- BasicInformationServer2,
166001
+ PluginBasicInformationServer,
166002
+ PluginDeviceBehavior
166003
+ ),
166004
+ window_covering: () => WindowCoveringDevice.with(
166005
+ IdentifyServer2,
166006
+ PluginBasicInformationServer,
166007
+ PluginDeviceBehavior
166008
+ ),
166009
+ generic_switch: () => GenericSwitchDevice.with(
166010
+ IdentifyServer2,
166011
+ PluginBasicInformationServer,
166012
+ PluginDeviceBehavior
166013
+ ),
166014
+ water_leak_detector: () => WaterLeakDetectorDevice.with(
166015
+ IdentifyServer2,
166016
+ PluginBasicInformationServer,
165943
166017
  PluginDeviceBehavior
165944
166018
  )
165945
166019
  };
165946
166020
  function createPluginEndpointType(deviceType) {
165947
166021
  const factory = deviceTypeMap[deviceType];
165948
166022
  if (!factory) {
165949
- logger159.warn(`Unsupported plugin device type: "${deviceType}"`);
166023
+ logger160.warn(`Unsupported plugin device type: "${deviceType}"`);
165950
166024
  return void 0;
165951
166025
  }
165952
- return factory();
166026
+ const endpoint = factory();
166027
+ validateEndpointType(endpoint, `plugin:${deviceType}`);
166028
+ return endpoint;
165953
166029
  }
165954
166030
  function getSupportedPluginDeviceTypes() {
165955
166031
  return Object.keys(deviceTypeMap);
@@ -165959,11 +166035,13 @@ function getSupportedPluginDeviceTypes() {
165959
166035
  init_esm();
165960
166036
  import * as fs10 from "node:fs";
165961
166037
  import * as path11 from "node:path";
165962
- var logger160 = Logger.get("PluginStorage");
166038
+ var logger161 = Logger.get("PluginStorage");
166039
+ var SAVE_DEBOUNCE_MS = 500;
165963
166040
  var FilePluginStorage = class {
165964
166041
  data = {};
165965
166042
  dirty = false;
165966
166043
  filePath;
166044
+ saveTimer;
165967
166045
  constructor(storageDir, pluginName) {
165968
166046
  const safePluginName = pluginName.replace(/[^a-zA-Z0-9_-]/g, "_");
165969
166047
  this.filePath = path11.join(storageDir, `plugin-${safePluginName}.json`);
@@ -165976,12 +166054,12 @@ var FilePluginStorage = class {
165976
166054
  async set(key, value) {
165977
166055
  this.data[key] = value;
165978
166056
  this.dirty = true;
165979
- this.save();
166057
+ this.scheduleSave();
165980
166058
  }
165981
166059
  async delete(key) {
165982
166060
  delete this.data[key];
165983
166061
  this.dirty = true;
165984
- this.save();
166062
+ this.scheduleSave();
165985
166063
  }
165986
166064
  async keys() {
165987
166065
  return Object.keys(this.data);
@@ -165993,12 +166071,20 @@ var FilePluginStorage = class {
165993
166071
  this.data = JSON.parse(raw);
165994
166072
  }
165995
166073
  } catch (e) {
165996
- logger160.warn(`Failed to load plugin storage from ${this.filePath}:`, e);
166074
+ logger161.warn(`Failed to load plugin storage from ${this.filePath}:`, e);
165997
166075
  this.data = {};
165998
166076
  }
165999
166077
  }
166078
+ scheduleSave() {
166079
+ if (this.saveTimer) clearTimeout(this.saveTimer);
166080
+ this.saveTimer = setTimeout(() => this.save(), SAVE_DEBOUNCE_MS);
166081
+ }
166000
166082
  save() {
166001
166083
  if (!this.dirty) return;
166084
+ if (this.saveTimer) {
166085
+ clearTimeout(this.saveTimer);
166086
+ this.saveTimer = void 0;
166087
+ }
166002
166088
  try {
166003
166089
  const dir = path11.dirname(this.filePath);
166004
166090
  if (!fs10.existsSync(dir)) {
@@ -166007,14 +166093,17 @@ var FilePluginStorage = class {
166007
166093
  fs10.writeFileSync(this.filePath, JSON.stringify(this.data, null, 2));
166008
166094
  this.dirty = false;
166009
166095
  } catch (e) {
166010
- logger160.warn(`Failed to save plugin storage to ${this.filePath}:`, e);
166096
+ logger161.warn(`Failed to save plugin storage to ${this.filePath}:`, e);
166011
166097
  }
166012
166098
  }
166099
+ flush() {
166100
+ this.save();
166101
+ }
166013
166102
  };
166014
166103
 
166015
166104
  // src/plugins/safe-plugin-runner.ts
166016
166105
  init_esm();
166017
- var logger161 = Logger.get("SafePluginRunner");
166106
+ var logger162 = Logger.get("SafePluginRunner");
166018
166107
  var DEFAULT_TIMEOUT_MS = 1e4;
166019
166108
  var CIRCUIT_BREAKER_THRESHOLD = 3;
166020
166109
  var SafePluginRunner = class {
@@ -166047,7 +166136,7 @@ var SafePluginRunner = class {
166047
166136
  async run(pluginName, operation, fn, timeoutMs = DEFAULT_TIMEOUT_MS) {
166048
166137
  const state = this.getState(pluginName);
166049
166138
  if (state.disabled) {
166050
- logger161.debug(
166139
+ logger162.debug(
166051
166140
  `Plugin "${pluginName}" is disabled (circuit breaker open), skipping ${operation}`
166052
166141
  );
166053
166142
  return void 0;
@@ -166065,13 +166154,13 @@ var SafePluginRunner = class {
166065
166154
  timeout.clear();
166066
166155
  state.failures++;
166067
166156
  state.lastError = error instanceof Error ? error.message : String(error);
166068
- logger161.error(
166157
+ logger162.error(
166069
166158
  `Plugin "${pluginName}" failed during ${operation} (failure ${state.failures}/${CIRCUIT_BREAKER_THRESHOLD}): ${state.lastError}`
166070
166159
  );
166071
166160
  if (state.failures >= CIRCUIT_BREAKER_THRESHOLD) {
166072
166161
  state.disabled = true;
166073
166162
  state.disabledAt = Date.now();
166074
- logger161.error(
166163
+ logger162.error(
166075
166164
  `Plugin "${pluginName}" DISABLED after ${CIRCUIT_BREAKER_THRESHOLD} consecutive failures. Last error: ${state.lastError}`
166076
166165
  );
166077
166166
  }
@@ -166093,13 +166182,13 @@ var SafePluginRunner = class {
166093
166182
  } catch (error) {
166094
166183
  state.failures++;
166095
166184
  state.lastError = error instanceof Error ? error.message : String(error);
166096
- logger161.error(
166185
+ logger162.error(
166097
166186
  `Plugin "${pluginName}" failed during ${operation} (sync, failure ${state.failures}/${CIRCUIT_BREAKER_THRESHOLD}): ${state.lastError}`
166098
166187
  );
166099
166188
  if (state.failures >= CIRCUIT_BREAKER_THRESHOLD) {
166100
166189
  state.disabled = true;
166101
166190
  state.disabledAt = Date.now();
166102
- logger161.error(
166191
+ logger162.error(
166103
166192
  `Plugin "${pluginName}" DISABLED after ${CIRCUIT_BREAKER_THRESHOLD} consecutive failures.`
166104
166193
  );
166105
166194
  }
@@ -166125,12 +166214,16 @@ var SafePluginRunner = class {
166125
166214
  };
166126
166215
 
166127
166216
  // src/plugins/plugin-manager.ts
166128
- var logger162 = Logger.get("PluginManager");
166217
+ var logger163 = Logger.get("PluginManager");
166218
+ var PLUGIN_API_VERSION = 1;
166219
+ var MAX_PLUGIN_DEVICE_ID_LENGTH = 100;
166129
166220
  function validatePluginDevice(device) {
166130
166221
  if (!device || typeof device !== "object") return "device must be an object";
166131
166222
  const d = device;
166132
166223
  if (!d.id || typeof d.id !== "string")
166133
166224
  return "device.id must be a non-empty string";
166225
+ if (d.id.length > MAX_PLUGIN_DEVICE_ID_LENGTH)
166226
+ return `device.id too long (${d.id.length} chars, max ${MAX_PLUGIN_DEVICE_ID_LENGTH})`;
166134
166227
  if (!d.name || typeof d.name !== "string")
166135
166228
  return "device.name must be a non-empty string";
166136
166229
  if (!d.deviceType || typeof d.deviceType !== "string")
@@ -166197,6 +166290,11 @@ var PluginManager = class {
166197
166290
  if (!manifest.main || typeof manifest.main !== "string") {
166198
166291
  throw new Error(`Plugin at ${packagePath} package.json missing "main"`);
166199
166292
  }
166293
+ if (manifest.hamhPluginApiVersion != null && manifest.hamhPluginApiVersion !== PLUGIN_API_VERSION) {
166294
+ logger163.warn(
166295
+ `Plugin "${manifest.name}" declares API version ${manifest.hamhPluginApiVersion}, current is ${PLUGIN_API_VERSION}. It may not work correctly.`
166296
+ );
166297
+ }
166200
166298
  const module = await this.runner.run(
166201
166299
  manifest.name,
166202
166300
  "import",
@@ -166224,7 +166322,7 @@ var PluginManager = class {
166224
166322
  };
166225
166323
  await this.register(plugin, metadata);
166226
166324
  } catch (e) {
166227
- logger162.error(`Failed to load external plugin from ${packagePath}:`, e);
166325
+ logger163.error(`Failed to load external plugin from ${packagePath}:`, e);
166228
166326
  throw e;
166229
166327
  }
166230
166328
  }
@@ -166285,7 +166383,7 @@ var PluginManager = class {
166285
166383
  devices,
166286
166384
  started: false
166287
166385
  });
166288
- logger162.info(
166386
+ logger163.info(
166289
166387
  `Registered plugin: ${plugin.name} v${plugin.version} (${metadata.source})`
166290
166388
  );
166291
166389
  }
@@ -166296,13 +166394,13 @@ var PluginManager = class {
166296
166394
  for (const [name, instance] of this.instances) {
166297
166395
  if (!instance.metadata.enabled) continue;
166298
166396
  if (this.runner.isDisabled(name)) {
166299
- logger162.warn(
166397
+ logger163.warn(
166300
166398
  `Plugin "${name}" is disabled (circuit breaker), skipping start`
166301
166399
  );
166302
166400
  instance.metadata.enabled = false;
166303
166401
  continue;
166304
166402
  }
166305
- logger162.info(`Starting plugin: ${name}`);
166403
+ logger163.info(`Starting plugin: ${name}`);
166306
166404
  await this.runner.run(
166307
166405
  name,
166308
166406
  "onStart",
@@ -166345,8 +166443,12 @@ var PluginManager = class {
166345
166443
  () => instance.plugin.onShutdown(reason)
166346
166444
  );
166347
166445
  }
166446
+ const storage2 = instance.context.storage;
166447
+ if (storage2 instanceof FilePluginStorage) {
166448
+ storage2.flush();
166449
+ }
166348
166450
  instance.started = false;
166349
- logger162.info(`Plugin "${name}" shut down`);
166451
+ logger163.info(`Plugin "${name}" shut down`);
166350
166452
  }
166351
166453
  this.instances.clear();
166352
166454
  }
@@ -167308,13 +167410,61 @@ function testBit(value, bitValue) {
167308
167410
  return !!(value & bitValue);
167309
167411
  }
167310
167412
 
167413
+ // src/matter/behaviors/basic-information-server.ts
167414
+ init_esm7();
167415
+ import crypto6 from "node:crypto";
167416
+ init_home_assistant_entity_behavior();
167417
+ var BasicInformationServer2 = class extends BridgedDeviceBasicInformationServer {
167418
+ async initialize() {
167419
+ await super.initialize();
167420
+ const homeAssistant = await this.agent.load(HomeAssistantEntityBehavior);
167421
+ this.update(homeAssistant.entity);
167422
+ this.reactTo(homeAssistant.onChange, this.update);
167423
+ }
167424
+ update(entity) {
167425
+ if (!entity.state) {
167426
+ return;
167427
+ }
167428
+ const { basicInformation } = this.env.get(BridgeDataProvider);
167429
+ const homeAssistant = this.agent.get(HomeAssistantEntityBehavior);
167430
+ const device = entity.deviceRegistry;
167431
+ applyPatchState(this.state, {
167432
+ vendorId: VendorId(basicInformation.vendorId),
167433
+ vendorName: ellipse(32, device?.manufacturer) ?? hash(32, basicInformation.vendorName),
167434
+ productName: ellipse(32, device?.model_id) ?? ellipse(32, device?.model) ?? hash(32, basicInformation.productName),
167435
+ productLabel: ellipse(64, device?.model) ?? hash(64, basicInformation.productLabel),
167436
+ hardwareVersion: basicInformation.hardwareVersion,
167437
+ softwareVersion: basicInformation.softwareVersion,
167438
+ hardwareVersionString: ellipse(64, device?.hw_version),
167439
+ softwareVersionString: ellipse(64, device?.sw_version),
167440
+ nodeLabel: ellipse(32, homeAssistant.state.customName) ?? ellipse(32, entity.state?.attributes?.friendly_name) ?? ellipse(32, entity.entity_id),
167441
+ reachable: entity.state?.state != null && entity.state.state !== "unavailable",
167442
+ // The device serial number is available in `device?.serial_number`, but
167443
+ // we're keeping it as the entity ID for now to avoid breaking existing
167444
+ // deployments.
167445
+ serialNumber: hash(32, entity.entity_id),
167446
+ // UniqueId helps controllers (especially Alexa) identify devices across
167447
+ // multiple fabric connections. Using MD5 hash of entity_id for stability.
167448
+ uniqueId: crypto6.createHash("md5").update(entity.entity_id).digest("hex").substring(0, 32)
167449
+ });
167450
+ }
167451
+ };
167452
+ function ellipse(maxLength, value) {
167453
+ return trimToLength(value, maxLength, "...");
167454
+ }
167455
+ function hash(maxLength, value) {
167456
+ const hashLength = 4;
167457
+ const suffix = crypto6.createHash("md5").update(value ?? "").digest("hex").substring(0, hashLength);
167458
+ return trimToLength(value, maxLength, suffix);
167459
+ }
167460
+
167311
167461
  // src/matter/endpoints/composed/composed-air-purifier-endpoint.ts
167312
167462
  init_home_assistant_entity_behavior();
167313
167463
 
167314
167464
  // src/matter/behaviors/humidity-measurement-server.ts
167315
167465
  init_esm();
167316
167466
  init_home_assistant_entity_behavior();
167317
- var logger163 = Logger.get("HumidityMeasurementServer");
167467
+ var logger164 = Logger.get("HumidityMeasurementServer");
167318
167468
  var HumidityMeasurementServerBase = class extends RelativeHumidityMeasurementServer {
167319
167469
  async initialize() {
167320
167470
  await super.initialize();
@@ -167327,7 +167477,7 @@ var HumidityMeasurementServerBase = class extends RelativeHumidityMeasurementSer
167327
167477
  return;
167328
167478
  }
167329
167479
  const humidity = this.getHumidity(this.state.config, entity.state);
167330
- logger163.debug(
167480
+ logger164.debug(
167331
167481
  `Humidity ${entity.state.entity_id} raw=${entity.state.state} measuredValue=${humidity}`
167332
167482
  );
167333
167483
  applyPatchState(this.state, {
@@ -167363,7 +167513,7 @@ init_clusters();
167363
167513
 
167364
167514
  // src/matter/behaviors/power-source-server.ts
167365
167515
  init_home_assistant_entity_behavior();
167366
- var logger164 = Logger.get("PowerSourceServer");
167516
+ var logger165 = Logger.get("PowerSourceServer");
167367
167517
  var FeaturedBase = PowerSourceServer.with("Battery", "Rechargeable");
167368
167518
  var PowerSourceServerBase = class extends FeaturedBase {
167369
167519
  async initialize() {
@@ -167375,17 +167525,17 @@ var PowerSourceServerBase = class extends FeaturedBase {
167375
167525
  applyPatchState(this.state, {
167376
167526
  endpointList: [endpointNumber]
167377
167527
  });
167378
- logger164.debug(
167528
+ logger165.debug(
167379
167529
  `[${entityId}] PowerSource initialized with endpointList=[${endpointNumber}]`
167380
167530
  );
167381
167531
  } else {
167382
- logger164.warn(
167532
+ logger165.warn(
167383
167533
  `[${entityId}] PowerSource endpoint number is null during initialize - endpointList will be empty!`
167384
167534
  );
167385
167535
  }
167386
167536
  const batteryEntity = homeAssistant.state.mapping?.batteryEntity;
167387
167537
  if (batteryEntity) {
167388
- logger164.debug(
167538
+ logger165.debug(
167389
167539
  `[${entityId}] PowerSource using mapped battery entity: ${batteryEntity}`
167390
167540
  );
167391
167541
  }
@@ -167692,7 +167842,7 @@ var OPTIMISTIC_TOLERANCE = 5;
167692
167842
  function notifyLightTurnedOn(entityId) {
167693
167843
  lastTurnOnTimestamps.set(entityId, Date.now());
167694
167844
  }
167695
- var logger165 = Logger.get("LevelControlServer");
167845
+ var logger166 = Logger.get("LevelControlServer");
167696
167846
  var FeaturedBase3 = LevelControlServer.with("OnOff", "Lighting");
167697
167847
  var LevelControlServerBase = class extends FeaturedBase3 {
167698
167848
  pendingTransitionTime;
@@ -167707,12 +167857,12 @@ var LevelControlServerBase = class extends FeaturedBase3 {
167707
167857
  this.state.maxLevel = 254;
167708
167858
  }
167709
167859
  this.state.onLevel = null;
167710
- logger165.debug(`initialize: calling super.initialize()`);
167860
+ logger166.debug(`initialize: calling super.initialize()`);
167711
167861
  try {
167712
167862
  await super.initialize();
167713
- logger165.debug(`initialize: super.initialize() completed successfully`);
167863
+ logger166.debug(`initialize: super.initialize() completed successfully`);
167714
167864
  } catch (error) {
167715
- logger165.error(`initialize: super.initialize() FAILED:`, error);
167865
+ logger166.error(`initialize: super.initialize() FAILED:`, error);
167716
167866
  throw error;
167717
167867
  }
167718
167868
  const homeAssistant = await this.agent.load(HomeAssistantEntityBehavior);
@@ -167788,7 +167938,7 @@ var LevelControlServerBase = class extends FeaturedBase3 {
167788
167938
  const timeSinceTurnOn = lastTurnOn ? Date.now() - lastTurnOn : Infinity;
167789
167939
  const isMaxBrightness = level >= this.maxLevel;
167790
167940
  if (isMaxBrightness && timeSinceTurnOn < 200) {
167791
- logger165.debug(
167941
+ logger166.debug(
167792
167942
  `[${entityId}] Ignoring moveToLevel(${level}) - Alexa brightness reset detected (${timeSinceTurnOn}ms after turn-on)`
167793
167943
  );
167794
167944
  return;
@@ -167831,7 +167981,7 @@ function LevelControlServer2(config10) {
167831
167981
  }
167832
167982
 
167833
167983
  // src/matter/behaviors/on-off-server.ts
167834
- var logger166 = Logger.get("OnOffServer");
167984
+ var logger167 = Logger.get("OnOffServer");
167835
167985
  var optimisticOnOffState = /* @__PURE__ */ new Map();
167836
167986
  var OPTIMISTIC_TIMEOUT_MS2 = 3e3;
167837
167987
  var OnOffServerBase = class extends OnOffServer {
@@ -167869,7 +168019,7 @@ var OnOffServerBase = class extends OnOffServer {
167869
168019
  const action = turnOn?.(void 0, this.agent) ?? {
167870
168020
  action: "homeassistant.turn_on"
167871
168021
  };
167872
- logger166.info(`[${homeAssistant.entityId}] Turning ON -> ${action.action}`);
168022
+ logger167.info(`[${homeAssistant.entityId}] Turning ON -> ${action.action}`);
167873
168023
  notifyLightTurnedOn(homeAssistant.entityId);
167874
168024
  applyPatchState(this.state, { onOff: true });
167875
168025
  optimisticOnOffState.set(homeAssistant.entityId, {
@@ -167891,7 +168041,7 @@ var OnOffServerBase = class extends OnOffServer {
167891
168041
  const action = turnOff?.(void 0, this.agent) ?? {
167892
168042
  action: "homeassistant.turn_off"
167893
168043
  };
167894
- logger166.info(`[${homeAssistant.entityId}] Turning OFF -> ${action.action}`);
168044
+ logger167.info(`[${homeAssistant.entityId}] Turning OFF -> ${action.action}`);
167895
168045
  applyPatchState(this.state, { onOff: false });
167896
168046
  optimisticOnOffState.set(homeAssistant.entityId, {
167897
168047
  expectedOnOff: false,
@@ -167922,7 +168072,7 @@ function setOptimisticOnOff(entityId, expectedOnOff) {
167922
168072
  }
167923
168073
 
167924
168074
  // src/matter/behaviors/fan-control-server.ts
167925
- var logger167 = Logger.get("FanControlServer");
168075
+ var logger168 = Logger.get("FanControlServer");
167926
168076
  var defaultStepSize = 33.33;
167927
168077
  var minSpeedMax = 3;
167928
168078
  var maxSpeedMax = 100;
@@ -168281,7 +168431,7 @@ var FanControlServerBase = class extends FeaturedBase4 {
168281
168431
  const entityId = this.agent.get(HomeAssistantEntityBehavior).entity.entity_id;
168282
168432
  setOptimisticOnOff(entityId, on);
168283
168433
  } catch (e) {
168284
- logger167.debug(
168434
+ logger168.debug(
168285
168435
  `syncOnOff(${on}) failed: ${e instanceof Error ? e.message : String(e)}`
168286
168436
  );
168287
168437
  }
@@ -168369,7 +168519,7 @@ var FanOnOffServer = OnOffServer2({
168369
168519
  });
168370
168520
 
168371
168521
  // src/matter/endpoints/composed/composed-air-purifier-endpoint.ts
168372
- var logger168 = Logger.get("ComposedAirPurifierEndpoint");
168522
+ var logger169 = Logger.get("ComposedAirPurifierEndpoint");
168373
168523
  function createTemperatureConfig(temperatureEntityId) {
168374
168524
  return {
168375
168525
  getValue(_entity, agent) {
@@ -168527,7 +168677,7 @@ var ComposedAirPurifierEndpoint = class _ComposedAirPurifierEndpoint extends End
168527
168677
  config10.humidityEntityId ? "+Hum" : "",
168528
168678
  config10.batteryEntityId ? "+Bat" : ""
168529
168679
  ].filter(Boolean).join("");
168530
- logger168.info(`Created air purifier ${primaryEntityId}: ${clusterLabels}`);
168680
+ logger169.info(`Created air purifier ${primaryEntityId}: ${clusterLabels}`);
168531
168681
  return endpoint;
168532
168682
  }
168533
168683
  constructor(type, entityId, id, trackedEntityIds, mappedEntityIds) {
@@ -168623,7 +168773,7 @@ init_home_assistant_entity_behavior();
168623
168773
  // src/matter/behaviors/pressure-measurement-server.ts
168624
168774
  init_esm();
168625
168775
  init_home_assistant_entity_behavior();
168626
- var logger169 = Logger.get("PressureMeasurementServer");
168776
+ var logger170 = Logger.get("PressureMeasurementServer");
168627
168777
  var MIN_PRESSURE = 300;
168628
168778
  var MAX_PRESSURE = 1100;
168629
168779
  var PressureMeasurementServerBase = class extends PressureMeasurementServer {
@@ -168651,7 +168801,7 @@ var PressureMeasurementServerBase = class extends PressureMeasurementServer {
168651
168801
  }
168652
168802
  const rounded = Math.round(value);
168653
168803
  if (rounded < MIN_PRESSURE || rounded > MAX_PRESSURE) {
168654
- logger169.warn(
168804
+ logger170.warn(
168655
168805
  `Pressure value ${rounded} (raw: ${value}) for ${entity.entity_id} is outside valid range [${MIN_PRESSURE}-${MAX_PRESSURE}], ignoring`
168656
168806
  );
168657
168807
  return null;
@@ -168670,7 +168820,7 @@ function PressureMeasurementServer2(config10) {
168670
168820
  }
168671
168821
 
168672
168822
  // src/matter/endpoints/composed/composed-sensor-endpoint.ts
168673
- var logger170 = Logger.get("ComposedSensorEndpoint");
168823
+ var logger171 = Logger.get("ComposedSensorEndpoint");
168674
168824
  var temperatureConfig = {
168675
168825
  getValue(entity, agent) {
168676
168826
  const fallbackUnit = agent.env.get(HomeAssistantConfig).unitSystem.temperature;
@@ -168834,7 +168984,7 @@ var ComposedSensorEndpoint = class _ComposedSensorEndpoint extends Endpoint {
168834
168984
  if (config10.pressureEntityId && pressSub) {
168835
168985
  endpoint.subEndpoints.set(config10.pressureEntityId, pressSub);
168836
168986
  }
168837
- logger170.info(
168987
+ logger171.info(
168838
168988
  `Created composed sensor ${primaryEntityId} with ${parts.length} sub-endpoint(s): T${humSub ? "+H" : ""}${pressSub ? "+P" : ""}${config10.batteryEntityId ? "+Bat" : ""}`
168839
168989
  );
168840
168990
  return endpoint;
@@ -168902,57 +169052,6 @@ var ComposedSensorEndpoint = class _ComposedSensorEndpoint extends Endpoint {
168902
169052
  }
168903
169053
  };
168904
169054
 
168905
- // src/matter/endpoints/validate-endpoint-type.ts
168906
- init_esm();
168907
- init_esm7();
168908
- var logger171 = Logger.get("EndpointValidation");
168909
- function toCamelCase(name) {
168910
- return name.charAt(0).toLowerCase() + name.slice(1);
168911
- }
168912
- function validateEndpointType(endpointType, entityId) {
168913
- const deviceTypeModel = Matter.deviceTypes.find(
168914
- (dt) => dt.id === endpointType.deviceType
168915
- );
168916
- if (!deviceTypeModel) {
168917
- return void 0;
168918
- }
168919
- const serverClusterReqs = deviceTypeModel.requirements.filter(
168920
- (r) => r.element === "serverCluster"
168921
- );
168922
- const behaviorKeys = new Set(Object.keys(endpointType.behaviors));
168923
- const missingMandatory = [];
168924
- const availableOptional = [];
168925
- const presentClusters = [];
168926
- for (const req of serverClusterReqs) {
168927
- const key = toCamelCase(req.name);
168928
- if (behaviorKeys.has(key)) {
168929
- presentClusters.push(req.name);
168930
- } else if (req.isMandatory) {
168931
- missingMandatory.push(req.name);
168932
- } else {
168933
- availableOptional.push(req.name);
168934
- }
168935
- }
168936
- const prefix = entityId ? `[${entityId}] ` : "";
168937
- if (missingMandatory.length > 0) {
168938
- logger171.warn(
168939
- `${prefix}${deviceTypeModel.name} (0x${endpointType.deviceType.toString(16)}): missing mandatory clusters: ${missingMandatory.join(", ")}`
168940
- );
168941
- }
168942
- if (availableOptional.length > 0) {
168943
- logger171.debug(
168944
- `${prefix}${deviceTypeModel.name} (0x${endpointType.deviceType.toString(16)}): optional clusters not used: ${availableOptional.join(", ")}`
168945
- );
168946
- }
168947
- return {
168948
- deviceTypeName: deviceTypeModel.name,
168949
- deviceTypeId: endpointType.deviceType,
168950
- missingMandatory,
168951
- availableOptional,
168952
- presentClusters
168953
- };
168954
- }
168955
-
168956
169055
  // src/matter/endpoints/legacy/air-purifier/index.ts
168957
169056
  init_dist();
168958
169057
  init_home_assistant_entity_behavior();
@@ -177954,7 +178053,7 @@ var LegacyEndpoint = class _LegacyEndpoint extends EntityEndpoint {
177954
178053
 
177955
178054
  // src/services/home-assistant/api/subscribe-entities.ts
177956
178055
  init_esm();
177957
- import crypto6 from "node:crypto";
178056
+ import crypto7 from "node:crypto";
177958
178057
  import {
177959
178058
  getCollection
177960
178059
  } from "home-assistant-js-websocket";
@@ -178038,7 +178137,7 @@ var subscribeUpdates = (conn, store, entityIds) => {
178038
178137
  });
178039
178138
  };
178040
178139
  function createEntitiesHash(entityIds) {
178041
- return crypto6.createHash("sha256").update(entityIds.join(",")).digest("hex").substring(0, 16);
178140
+ return crypto7.createHash("sha256").update(entityIds.join(",")).digest("hex").substring(0, 16);
178042
178141
  }
178043
178142
  var entitiesColl = (conn, entityIds) => {
178044
178143
  if (atLeastHaVersion(conn.haVersion, 2022, 4, 0)) {