@matter/protocol 0.16.0-alpha.0-20251016-b56cf5683 → 0.16.0-alpha.0-20251018-dd1ea6a8a

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.
Files changed (155) hide show
  1. package/dist/cjs/action/client/ClientInteraction.d.ts +10 -5
  2. package/dist/cjs/action/client/ClientInteraction.d.ts.map +1 -1
  3. package/dist/cjs/action/client/ClientInteraction.js +129 -18
  4. package/dist/cjs/action/client/ClientInteraction.js.map +1 -1
  5. package/dist/cjs/action/request/Invoke.d.ts +36 -8
  6. package/dist/cjs/action/request/Invoke.d.ts.map +1 -1
  7. package/dist/cjs/action/request/Invoke.js +80 -15
  8. package/dist/cjs/action/request/Invoke.js.map +1 -1
  9. package/dist/cjs/action/request/Read.d.ts +1 -1
  10. package/dist/cjs/action/request/Read.d.ts.map +1 -1
  11. package/dist/cjs/action/request/Read.js +10 -2
  12. package/dist/cjs/action/request/Read.js.map +1 -1
  13. package/dist/cjs/action/request/Specifier.d.ts +16 -1
  14. package/dist/cjs/action/request/Specifier.d.ts.map +1 -1
  15. package/dist/cjs/action/request/Specifier.js +56 -1
  16. package/dist/cjs/action/request/Specifier.js.map +1 -1
  17. package/dist/cjs/action/request/Write.d.ts +5 -3
  18. package/dist/cjs/action/request/Write.d.ts.map +1 -1
  19. package/dist/cjs/action/request/Write.js +52 -12
  20. package/dist/cjs/action/request/Write.js.map +1 -1
  21. package/dist/cjs/action/response/InvokeResult.d.ts +6 -0
  22. package/dist/cjs/action/response/InvokeResult.d.ts.map +1 -1
  23. package/dist/cjs/interaction/InteractionClient.d.ts.map +1 -1
  24. package/dist/cjs/interaction/InteractionClient.js +91 -74
  25. package/dist/cjs/interaction/InteractionClient.js.map +1 -1
  26. package/dist/cjs/interaction/InteractionMessenger.d.ts +3 -2
  27. package/dist/cjs/interaction/InteractionMessenger.d.ts.map +1 -1
  28. package/dist/cjs/interaction/InteractionMessenger.js +10 -3
  29. package/dist/cjs/interaction/InteractionMessenger.js.map +1 -1
  30. package/dist/cjs/protocol/ExchangeManager.d.ts.map +1 -1
  31. package/dist/cjs/protocol/ExchangeManager.js +20 -17
  32. package/dist/cjs/protocol/ExchangeManager.js.map +1 -1
  33. package/dist/cjs/protocol/MessageChannel.d.ts.map +1 -1
  34. package/dist/cjs/protocol/MessageChannel.js +1 -1
  35. package/dist/cjs/protocol/MessageChannel.js.map +1 -1
  36. package/dist/cjs/protocol/MessageExchange.d.ts +1 -0
  37. package/dist/cjs/protocol/MessageExchange.d.ts.map +1 -1
  38. package/dist/cjs/protocol/MessageExchange.js +14 -4
  39. package/dist/cjs/protocol/MessageExchange.js.map +1 -1
  40. package/dist/cjs/protocol/ProtocolHandler.d.ts +7 -2
  41. package/dist/cjs/protocol/ProtocolHandler.d.ts.map +1 -1
  42. package/dist/cjs/securechannel/SecureChannelProtocol.d.ts +1 -1
  43. package/dist/cjs/securechannel/SecureChannelProtocol.d.ts.map +1 -1
  44. package/dist/cjs/securechannel/SecureChannelProtocol.js +2 -1
  45. package/dist/cjs/securechannel/SecureChannelProtocol.js.map +1 -1
  46. package/dist/cjs/session/GroupSession.d.ts +8 -1
  47. package/dist/cjs/session/GroupSession.d.ts.map +1 -1
  48. package/dist/cjs/session/GroupSession.js +10 -0
  49. package/dist/cjs/session/GroupSession.js.map +1 -1
  50. package/dist/cjs/session/NodeSession.d.ts +3 -1
  51. package/dist/cjs/session/NodeSession.d.ts.map +1 -1
  52. package/dist/cjs/session/NodeSession.js +13 -0
  53. package/dist/cjs/session/NodeSession.js.map +2 -2
  54. package/dist/cjs/session/SecureSession.d.ts +2 -0
  55. package/dist/cjs/session/SecureSession.d.ts.map +1 -1
  56. package/dist/cjs/session/SecureSession.js.map +1 -1
  57. package/dist/cjs/session/case/CaseClient.d.ts.map +1 -1
  58. package/dist/cjs/session/case/CaseClient.js +3 -15
  59. package/dist/cjs/session/case/CaseClient.js.map +1 -1
  60. package/dist/cjs/session/case/CaseServer.d.ts.map +1 -1
  61. package/dist/cjs/session/case/CaseServer.js +10 -18
  62. package/dist/cjs/session/case/CaseServer.js.map +1 -1
  63. package/dist/cjs/session/pase/PaseClient.js +1 -1
  64. package/dist/cjs/session/pase/PaseClient.js.map +1 -1
  65. package/dist/cjs/session/pase/PaseServer.d.ts.map +1 -1
  66. package/dist/cjs/session/pase/PaseServer.js +2 -2
  67. package/dist/cjs/session/pase/PaseServer.js.map +1 -1
  68. package/dist/esm/action/client/ClientInteraction.d.ts +10 -5
  69. package/dist/esm/action/client/ClientInteraction.d.ts.map +1 -1
  70. package/dist/esm/action/client/ClientInteraction.js +140 -20
  71. package/dist/esm/action/client/ClientInteraction.js.map +1 -1
  72. package/dist/esm/action/request/Invoke.d.ts +36 -8
  73. package/dist/esm/action/request/Invoke.d.ts.map +1 -1
  74. package/dist/esm/action/request/Invoke.js +81 -16
  75. package/dist/esm/action/request/Invoke.js.map +1 -1
  76. package/dist/esm/action/request/Read.d.ts +1 -1
  77. package/dist/esm/action/request/Read.d.ts.map +1 -1
  78. package/dist/esm/action/request/Read.js +12 -4
  79. package/dist/esm/action/request/Read.js.map +1 -1
  80. package/dist/esm/action/request/Specifier.d.ts +16 -1
  81. package/dist/esm/action/request/Specifier.d.ts.map +1 -1
  82. package/dist/esm/action/request/Specifier.js +56 -1
  83. package/dist/esm/action/request/Specifier.js.map +1 -1
  84. package/dist/esm/action/request/Write.d.ts +5 -3
  85. package/dist/esm/action/request/Write.d.ts.map +1 -1
  86. package/dist/esm/action/request/Write.js +53 -13
  87. package/dist/esm/action/request/Write.js.map +1 -1
  88. package/dist/esm/action/response/InvokeResult.d.ts +6 -0
  89. package/dist/esm/action/response/InvokeResult.d.ts.map +1 -1
  90. package/dist/esm/interaction/InteractionClient.d.ts.map +1 -1
  91. package/dist/esm/interaction/InteractionClient.js +92 -74
  92. package/dist/esm/interaction/InteractionClient.js.map +1 -1
  93. package/dist/esm/interaction/InteractionMessenger.d.ts +3 -2
  94. package/dist/esm/interaction/InteractionMessenger.d.ts.map +1 -1
  95. package/dist/esm/interaction/InteractionMessenger.js +10 -3
  96. package/dist/esm/interaction/InteractionMessenger.js.map +1 -1
  97. package/dist/esm/protocol/ExchangeManager.d.ts.map +1 -1
  98. package/dist/esm/protocol/ExchangeManager.js +20 -17
  99. package/dist/esm/protocol/ExchangeManager.js.map +1 -1
  100. package/dist/esm/protocol/MessageChannel.d.ts.map +1 -1
  101. package/dist/esm/protocol/MessageChannel.js +2 -2
  102. package/dist/esm/protocol/MessageChannel.js.map +1 -1
  103. package/dist/esm/protocol/MessageExchange.d.ts +1 -0
  104. package/dist/esm/protocol/MessageExchange.d.ts.map +1 -1
  105. package/dist/esm/protocol/MessageExchange.js +14 -4
  106. package/dist/esm/protocol/MessageExchange.js.map +1 -1
  107. package/dist/esm/protocol/ProtocolHandler.d.ts +7 -2
  108. package/dist/esm/protocol/ProtocolHandler.d.ts.map +1 -1
  109. package/dist/esm/securechannel/SecureChannelProtocol.d.ts +1 -1
  110. package/dist/esm/securechannel/SecureChannelProtocol.d.ts.map +1 -1
  111. package/dist/esm/securechannel/SecureChannelProtocol.js +2 -1
  112. package/dist/esm/securechannel/SecureChannelProtocol.js.map +1 -1
  113. package/dist/esm/session/GroupSession.d.ts +8 -1
  114. package/dist/esm/session/GroupSession.d.ts.map +1 -1
  115. package/dist/esm/session/GroupSession.js +11 -1
  116. package/dist/esm/session/GroupSession.js.map +1 -1
  117. package/dist/esm/session/NodeSession.d.ts +3 -1
  118. package/dist/esm/session/NodeSession.d.ts.map +1 -1
  119. package/dist/esm/session/NodeSession.js +13 -0
  120. package/dist/esm/session/NodeSession.js.map +2 -2
  121. package/dist/esm/session/SecureSession.d.ts +2 -0
  122. package/dist/esm/session/SecureSession.d.ts.map +1 -1
  123. package/dist/esm/session/SecureSession.js.map +1 -1
  124. package/dist/esm/session/case/CaseClient.d.ts.map +1 -1
  125. package/dist/esm/session/case/CaseClient.js +5 -17
  126. package/dist/esm/session/case/CaseClient.js.map +1 -1
  127. package/dist/esm/session/case/CaseServer.d.ts.map +1 -1
  128. package/dist/esm/session/case/CaseServer.js +12 -20
  129. package/dist/esm/session/case/CaseServer.js.map +1 -1
  130. package/dist/esm/session/pase/PaseClient.js +1 -1
  131. package/dist/esm/session/pase/PaseClient.js.map +1 -1
  132. package/dist/esm/session/pase/PaseServer.d.ts.map +1 -1
  133. package/dist/esm/session/pase/PaseServer.js +3 -2
  134. package/dist/esm/session/pase/PaseServer.js.map +1 -1
  135. package/package.json +6 -6
  136. package/src/action/client/ClientInteraction.ts +181 -27
  137. package/src/action/request/Invoke.ts +149 -27
  138. package/src/action/request/Read.ts +27 -7
  139. package/src/action/request/Specifier.ts +80 -1
  140. package/src/action/request/Write.ts +71 -19
  141. package/src/action/response/InvokeResult.ts +8 -0
  142. package/src/interaction/InteractionClient.ts +135 -96
  143. package/src/interaction/InteractionMessenger.ts +15 -3
  144. package/src/protocol/ExchangeManager.ts +27 -29
  145. package/src/protocol/MessageChannel.ts +2 -2
  146. package/src/protocol/MessageExchange.ts +18 -4
  147. package/src/protocol/ProtocolHandler.ts +7 -2
  148. package/src/securechannel/SecureChannelProtocol.ts +5 -1
  149. package/src/session/GroupSession.ts +12 -1
  150. package/src/session/NodeSession.ts +21 -0
  151. package/src/session/SecureSession.ts +2 -0
  152. package/src/session/case/CaseClient.ts +3 -23
  153. package/src/session/case/CaseServer.ts +15 -20
  154. package/src/session/pase/PaseClient.ts +1 -1
  155. package/src/session/pase/PaseServer.ts +3 -2
@@ -225,6 +225,12 @@ export class ExchangeManager {
225
225
  message.payloadHeader.protocolId,
226
226
  message.payloadHeader.messageType,
227
227
  );
228
+ const messageDiagnostics = Diagnostic.dict({
229
+ message: messageId,
230
+ protocol: message.payloadHeader.protocolId,
231
+ exId: message.payloadHeader.exchangeId,
232
+ via: channel.name,
233
+ });
228
234
  if (exchange !== undefined) {
229
235
  if (
230
236
  exchange.requiresSecureSession !== session.isSecure ||
@@ -232,14 +238,15 @@ export class ExchangeManager {
232
238
  (exchange.isClosing && !isStandaloneAck)
233
239
  ) {
234
240
  logger.debug(
235
- `Ignoring message ${messageId} for protocol ${message.payloadHeader.protocolId} and exchange id ${message.payloadHeader.exchangeId} on channel ${channel.name} because ${
236
- exchange.isClosing
237
- ? "exchange is closing"
238
- : exchange.session.id !== packet.header.sessionId
239
- ? `session ID mismatch ${exchange.session.id} vs ${packet.header.sessionId}`
240
- : `session security requirements (${exchange.requiresSecureSession}) not fulfilled`
241
- }`,
241
+ "Ignore « message because",
242
+ exchange.isClosing
243
+ ? "exchange is closing"
244
+ : exchange.session.id !== packet.header.sessionId
245
+ ? `session ID mismatch ${exchange.session.id} vs ${packet.header.sessionId}`
246
+ : `session security requirements (${exchange.requiresSecureSession}) not fulfilled`,
247
+ messageDiagnostics,
242
248
  );
249
+
243
250
  await exchange.send(SecureMessageType.StandaloneAck, new Uint8Array(0), {
244
251
  includeAcknowledgeMessageId: message.packetHeader.messageId,
245
252
  protocolId: SECURE_CHANNEL_PROTOCOL_ID,
@@ -259,15 +266,15 @@ export class ExchangeManager {
259
266
 
260
267
  const protocolHandler = this.#protocols.get(message.payloadHeader.protocolId);
261
268
 
269
+ const handlerSecurityMismatch =
270
+ protocolHandler?.requiresSecureSession !== undefined &&
271
+ protocolHandler.requiresSecureSession !== session.isSecure;
262
272
  // Having a "Secure Session" means it is encrypted in our internal working
263
273
  // TODO When adding Group sessions, we need to check how to adjust that handling
264
- if (
265
- protocolHandler !== undefined &&
266
- protocolHandler.requiresSecureSession !== session.isSecure &&
267
- !isStandaloneAck
268
- ) {
274
+ if (handlerSecurityMismatch) {
269
275
  logger.debug(
270
- `Ignoring message ${messageId} for protocol ${message.payloadHeader.protocolId} and exchange id ${message.payloadHeader.exchangeId} on channel ${channel.name} because not matching the security requirements.`,
276
+ `Ignore « message because not matching the security requirements (${protocolHandler.requiresSecureSession} vs. ${session.isSecure})`,
277
+ messageDiagnostics,
271
278
  );
272
279
  }
273
280
 
@@ -275,12 +282,10 @@ export class ExchangeManager {
275
282
  protocolHandler !== undefined &&
276
283
  message.payloadHeader.isInitiatorMessage &&
277
284
  !isDuplicate &&
278
- protocolHandler.requiresSecureSession === session.isSecure
285
+ !handlerSecurityMismatch
279
286
  ) {
280
287
  if (isStandaloneAck && !message.payloadHeader.requiresAck) {
281
- logger.debug(
282
- `Ignoring unsolicited standalone ack message ${messageId} for protocol ${message.payloadHeader.protocolId} and exchange id ${message.payloadHeader.exchangeId} on channel ${channel.name}`,
283
- );
288
+ logger.debug("Ignore « unsolicited standalone ack message", messageDiagnostics);
284
289
  return;
285
290
  }
286
291
 
@@ -302,9 +307,7 @@ export class ExchangeManager {
302
307
  protocolId: SECURE_CHANNEL_PROTOCOL_ID,
303
308
  });
304
309
  await exchange.close();
305
- logger.debug(
306
- `Ignoring unsolicited message ${messageId} for protocol ${message.payloadHeader.protocolId} on channel ${channel.name}`,
307
- );
310
+ logger.debug("Ignore « unsolicited message", messageDiagnostics);
308
311
  } else {
309
312
  if (protocolHandler === undefined) {
310
313
  throw new MatterFlowError(`Unsupported protocol ${message.payloadHeader.protocolId}`);
@@ -312,17 +315,12 @@ export class ExchangeManager {
312
315
  if (isDuplicate) {
313
316
  if (message.packetHeader.destGroupId === undefined) {
314
317
  // Duplicate Non-Group messages are still interesting to log to know them
315
- logger.info(
316
- `Ignoring duplicate message ${messageId} (requires no ack) for protocol ${message.payloadHeader.protocolId} on channel ${channel.name}`,
317
- );
318
+ logger.debug("Ignore « duplicate message", messageDiagnostics);
318
319
  }
319
320
  return;
320
- } else if (!isStandaloneAck) {
321
- logger.info(
322
- `Discarding unexpected message ${messageId} for protocol ${
323
- message.payloadHeader.protocolId
324
- }, exchangeIndex ${exchangeIndex} and sessionId ${session.id} on channel ${channel.name}: ${Diagnostic.json(message)}`,
325
- );
321
+ }
322
+ if (!isStandaloneAck) {
323
+ logger.info("Discard « unexpected message", messageDiagnostics, Diagnostic.json(message));
326
324
  }
327
325
  }
328
326
  }
@@ -5,7 +5,7 @@
5
5
  */
6
6
 
7
7
  import { Message, MessageCodec } from "#codec/MessageCodec.js";
8
- import { Bytes, Channel, Duration, Logger, MatterError, MatterFlowError, Millis, Seconds } from "#general";
8
+ import { Bytes, Channel, Diagnostic, Duration, Logger, MatterError, MatterFlowError, Millis, Seconds } from "#general";
9
9
  import type { ExchangeLogContext } from "#protocol/MessageExchange.js";
10
10
  import { Session, SessionParameters } from "#session/Session.js";
11
11
 
@@ -101,7 +101,7 @@ export class MessageChannel implements Channel<Message> {
101
101
  }
102
102
 
103
103
  get name() {
104
- return `${this.channel.name} on session ${this.session.name}`;
104
+ return Diagnostic.via(`${this.session.name}@${this.channel.name}`);
105
105
  }
106
106
 
107
107
  async close() {
@@ -30,6 +30,7 @@ import {
30
30
  MRP,
31
31
  } from "#protocol/MessageChannel.js";
32
32
  import { GroupSession } from "#session/GroupSession.js";
33
+ import { SecureSession } from "#session/SecureSession.js";
33
34
  import { SessionParameters } from "#session/Session.js";
34
35
  import {
35
36
  GroupId,
@@ -199,8 +200,8 @@ export class MessageExchange {
199
200
  logger.debug(
200
201
  "New exchange",
201
202
  isInitiator ? "»" : "«",
203
+ channel.name,
202
204
  Diagnostic.dict({
203
- channel: channel.name,
204
205
  protocol: this.#protocolId,
205
206
  exId: this.#exchangeId,
206
207
  sess: session.name,
@@ -582,12 +583,16 @@ export class MessageExchange {
582
583
  StatusCode.InvalidAction,
583
584
  );
584
585
  }
586
+
585
587
  logger.debug(
586
- `Starting timed interaction with Transaction ID ${this.#exchangeId} for ${Duration.format(timeout)} from ${this.channel.name}`,
588
+ "Starting timed interaction «",
589
+ this.channel.name,
590
+ Diagnostic.dict({ exId: this.#exchangeId, timeout: Duration.format(timeout) }),
587
591
  );
588
592
  this.#timedInteractionTimer = Time.getTimer("Timed interaction", timeout, () => {
589
593
  logger.debug(
590
- `Timed interaction with Transaction ID ${this.#exchangeId} from ${this.channel.name} timed out`,
594
+ "Timed interaction timeout!",
595
+ Diagnostic.dict({ exId: this.#exchangeId, via: this.channel.name }),
591
596
  );
592
597
  }).start();
593
598
  }
@@ -595,7 +600,8 @@ export class MessageExchange {
595
600
  clearTimedInteraction() {
596
601
  if (this.#timedInteractionTimer !== undefined) {
597
602
  logger.debug(
598
- `Clearing timed interaction with Transaction ID ${this.#exchangeId} from ${this.channel.name}`,
603
+ "Clearing timed interaction",
604
+ Diagnostic.dict({ exId: this.#exchangeId, via: this.channel.name }),
599
605
  );
600
606
  this.#timedInteractionTimer.stop();
601
607
  this.#timedInteractionTimer = undefined;
@@ -679,4 +685,12 @@ export class MessageExchange {
679
685
  this.#messagesQueue.close();
680
686
  await this.#closed.emit();
681
687
  }
688
+
689
+ get via() {
690
+ if (this.session == undefined || !this.session.isSecure) {
691
+ return this.channel.name; // already formatted as "via"
692
+ }
693
+
694
+ return Diagnostic.via(`${(this.session as SecureSession).peerAddress.toString()}#${this.session.id}`);
695
+ }
682
696
  }
@@ -11,8 +11,13 @@ export interface ProtocolHandler {
11
11
  /** Protocol ID that this handler implements */
12
12
  readonly id: number;
13
13
 
14
- /** Indicates whether this protocol requires a secure session to be established before it can be used */
15
- readonly requiresSecureSession: boolean;
14
+ /**
15
+ * Indicates whether this protocol requires a secure session to be established before it can be used.
16
+ * When `true`, the protocol can only be used over secure sessions.
17
+ * When `false`, the protocol can only be used without a secure session.
18
+ * When `undefined`, the protocol can be used with or without a secure session and it is up to the handler to check
19
+ */
20
+ readonly requiresSecureSession: boolean | undefined;
16
21
 
17
22
  /** Called on a new exchange that uses this protocol. The message is the first message of the exchange. */
18
23
  onNewExchange(exchange: MessageExchange, message: Message): Promise<void>;
@@ -29,7 +29,9 @@ const logger = Logger.get("SecureChannelProtocol");
29
29
 
30
30
  export class StatusReportOnlySecureChannelProtocol implements ProtocolHandler {
31
31
  readonly id = SECURE_CHANNEL_PROTOCOL_ID;
32
- readonly requiresSecureSession = false;
32
+
33
+ // We need to check the message details to decide if ok or not, so we take them all
34
+ readonly requiresSecureSession = undefined;
33
35
 
34
36
  async onNewExchange(exchange: MessageExchange, message: Message) {
35
37
  const messageType = message.payloadHeader.messageType;
@@ -70,6 +72,8 @@ export class StatusReportOnlySecureChannelProtocol implements ProtocolHandler {
70
72
  protocolStatus,
71
73
  );
72
74
  }
75
+
76
+ // CloseSession is the only case where a StatusReport comes as initial message
73
77
  if (protocolStatus !== SecureChannelStatusCode.CloseSession) {
74
78
  throw new ChannelStatusResponseError(
75
79
  `Received general success status, but protocol status is not CloseSession`,
@@ -16,8 +16,9 @@ import {
16
16
  MatterFlowError,
17
17
  UnexpectedDataError,
18
18
  } from "#general";
19
+ import { PeerAddress } from "#peer/PeerAddress.js";
19
20
  import type { SessionManager } from "#session/SessionManager.js";
20
- import { GroupId, NodeId } from "#types";
21
+ import { FabricIndex, GroupId, NodeId } from "#types";
21
22
  import { SecureSession } from "./SecureSession.js";
22
23
  import { Session } from "./Session.js";
23
24
 
@@ -92,6 +93,16 @@ export class GroupSession extends SecureSession {
92
93
  return this.#fabric;
93
94
  }
94
95
 
96
+ /**
97
+ * The peer group's address.
98
+ */
99
+ get peerAddress() {
100
+ return PeerAddress({
101
+ fabricIndex: this.#fabric?.fabricIndex ?? FabricIndex.NO_FABRIC,
102
+ nodeId: this.#peerNodeId,
103
+ });
104
+ }
105
+
95
106
  subjectFor(message?: Message): Subject {
96
107
  if (message === undefined || message.packetHeader.destGroupId === undefined) {
97
108
  throw new ImplementationError("GroupSession requires a message with destGroupId");
@@ -22,6 +22,7 @@ import type { Subscription } from "#interaction/Subscription.js";
22
22
  import { PeerAddress } from "#peer/PeerAddress.js";
23
23
  import { MessageCounter } from "#protocol/MessageCounter.js";
24
24
  import { MessageReceptionStateEncryptedWithoutRollover } from "#protocol/MessageReceptionState.js";
25
+ import { SecureChannelMessenger } from "#securechannel/SecureChannelMessenger.js";
25
26
  import { CaseAuthenticatedTag, FabricIndex, NodeId, StatusCode, StatusResponseError } from "#types";
26
27
  import { SecureSession } from "./SecureSession.js";
27
28
  import { Session, SessionParameterOptions } from "./Session.js";
@@ -392,4 +393,24 @@ export namespace NodeSession {
392
393
  export function is(session?: Session): session is NodeSession {
393
394
  return session?.type === SessionType.Unicast;
394
395
  }
396
+
397
+ export function logNew(
398
+ logger: Logger,
399
+ operation: "New" | "Resumed",
400
+ session: NodeSession,
401
+ messenger: SecureChannelMessenger,
402
+ fabric: Fabric,
403
+ peerNodeId: NodeId,
404
+ ) {
405
+ logger.info(
406
+ `${operation} session with`,
407
+ Diagnostic.strong(PeerAddress({ fabricIndex: fabric.fabricIndex, nodeId: peerNodeId }).toString()),
408
+ Diagnostic.dict({
409
+ id: session.id,
410
+ address: messenger.channelName,
411
+ fabric: `${NodeId.toHexString(fabric.nodeId)} (#${fabric.fabricIndex})`,
412
+ ...session.parameterDiagnostics,
413
+ }),
414
+ );
415
+ }
395
416
  }
@@ -7,11 +7,13 @@ import { Subject } from "#action/server/Subject.js";
7
7
  import { Message } from "#codec/MessageCodec.js";
8
8
  import { Fabric } from "#fabric/Fabric.js";
9
9
  import { MatterFlowError } from "#general";
10
+ import { PeerAddress } from "#peer/PeerAddress.js";
10
11
  import { Session } from "./Session.js";
11
12
 
12
13
  export abstract class SecureSession extends Session {
13
14
  readonly isSecure = true;
14
15
  abstract fabric: Fabric | undefined;
16
+ abstract peerAddress: PeerAddress;
15
17
  abstract subjectFor(message?: Message): Subject;
16
18
  }
17
19
 
@@ -7,8 +7,7 @@
7
7
  import { Icac } from "#certificate/kinds/Icac.js";
8
8
  import { Noc } from "#certificate/kinds/Noc.js";
9
9
  import { Fabric } from "#fabric/Fabric.js";
10
- import { Bytes, Diagnostic, Duration, Logger, PublicKey, UnexpectedDataError } from "#general";
11
- import { PeerAddress } from "#peer/PeerAddress.js";
10
+ import { Bytes, Duration, Logger, PublicKey, UnexpectedDataError } from "#general";
12
11
  import { MessageExchange, RetransmissionLimitReachedError } from "#protocol/MessageExchange.js";
13
12
  import { ChannelStatusResponseError } from "#securechannel/SecureChannelMessenger.js";
14
13
  import { NodeSession } from "#session/NodeSession.js";
@@ -135,7 +134,7 @@ export class CaseClient {
135
134
  caseAuthenticatedTags,
136
135
  });
137
136
  await messenger.sendSuccess();
138
- this.#logNewSession("Resumed", secureSession, messenger, fabric, peerNodeId);
137
+ NodeSession.logNew(logger, "Resumed", secureSession, messenger, fabric, peerNodeId);
139
138
 
140
139
  resumptionRecord.resumptionId = resumptionId; /* update resumptionId */
141
140
  resumptionRecord.sessionParameters = secureSession.parameters; /* update mrpParams */
@@ -246,7 +245,7 @@ export class CaseClient {
246
245
  peerSessionParameters,
247
246
  caseAuthenticatedTags: sessionCaseAuthenticatedTags,
248
247
  });
249
- this.#logNewSession("New", secureSession, messenger, fabric, peerNodeId);
248
+ NodeSession.logNew(logger, "New", secureSession, messenger, fabric, peerNodeId);
250
249
  resumptionRecord = {
251
250
  fabric,
252
251
  peerNodeId,
@@ -262,25 +261,6 @@ export class CaseClient {
262
261
 
263
262
  return { session: secureSession, resumed };
264
263
  }
265
-
266
- #logNewSession(
267
- operation: "New" | "Resumed",
268
- session: NodeSession,
269
- messenger: CaseClientMessenger,
270
- fabric: Fabric,
271
- peerNodeId: NodeId,
272
- ) {
273
- logger.info(
274
- `${operation} session with`,
275
- Diagnostic.strong(PeerAddress({ fabricIndex: fabric.fabricIndex, nodeId: peerNodeId }).toString()),
276
- Diagnostic.dict({
277
- id: session.id,
278
- address: messenger.channelName,
279
- fabric: `${NodeId.toHexString(fabric.nodeId)} (#${fabric.fabricIndex})`,
280
- ...session.parameterDiagnostics,
281
- }),
282
- );
283
- }
284
264
  }
285
265
 
286
266
  export namespace CaseClient {
@@ -5,10 +5,11 @@
5
5
  */
6
6
 
7
7
  import { Noc } from "#certificate/kinds/Noc.js";
8
- import { Bytes, Crypto, CryptoDecryptError, Logger, PublicKey, UnexpectedDataError } from "#general";
8
+ import { Bytes, Crypto, CryptoDecryptError, Diagnostic, Logger, PublicKey, UnexpectedDataError } from "#general";
9
+ import { NodeSession } from "#session/NodeSession.js";
9
10
  import { SessionParametersWithDurations } from "#session/pase/PaseMessages.js";
10
11
  import { ResumptionRecord, SessionManager } from "#session/SessionManager.js";
11
- import { NodeId, SECURE_CHANNEL_PROTOCOL_ID, SecureChannelStatusCode } from "#types";
12
+ import { SECURE_CHANNEL_PROTOCOL_ID, SecureChannelStatusCode } from "#types";
12
13
  import { FabricManager, FabricNotFoundError } from "../../fabric/FabricManager.js";
13
14
  import { MessageExchange } from "../../protocol/MessageExchange.js";
14
15
  import { ProtocolHandler } from "../../protocol/ProtocolHandler.js";
@@ -64,7 +65,7 @@ export class CaseServer implements ProtocolHandler {
64
65
  }
65
66
 
66
67
  async #handleSigma1(messenger: CaseServerMessenger) {
67
- logger.info(`Received pairing request from ${messenger.channelName}`);
68
+ logger.info("Received pairing request «", Diagnostic.via(messenger.channelName));
68
69
 
69
70
  // Initialize context with information from peer
70
71
  const { sigma1Bytes, sigma1 } = await messenger.readSigma1();
@@ -86,9 +87,12 @@ export class CaseServer implements ProtocolHandler {
86
87
  }
87
88
 
88
89
  logger.info(
89
- `Invalid resumption ID or resume MIC received from ${messenger.channelName}`,
90
- context.peerResumptionId,
91
- context.peerResumeMic,
90
+ "Invalid resumption ID or resume MIC received from",
91
+ messenger.channelName,
92
+ Diagnostic.dict({
93
+ resumptionId: context.peerResumptionId,
94
+ resumeMic: context.peerResumeMic,
95
+ }),
92
96
  );
93
97
 
94
98
  throw new UnexpectedDataError("Invalid resumption ID or resume MIC.");
@@ -152,13 +156,8 @@ export class CaseServer implements ProtocolHandler {
152
156
  throw error;
153
157
  }
154
158
 
155
- logger.info(
156
- `Session ${secureSession.id} resumed with ${cx.messenger.channelName} for Fabric ${NodeId.toHexString(
157
- fabric.nodeId,
158
- )} (index ${fabric.fabricIndex}) and PeerNode ${NodeId.toHexString(peerNodeId)}`,
159
- "with CATs",
160
- caseAuthenticatedTags,
161
- );
159
+ NodeSession.logNew(logger, "Resumed", secureSession, cx.messenger, fabric, peerNodeId);
160
+
162
161
  cx.resumptionRecord.resumptionId = cx.localResumptionId; /* Update the ID */
163
162
 
164
163
  // Wait for success on the peer side
@@ -274,13 +273,9 @@ export class CaseServer implements ProtocolHandler {
274
273
  peerSessionParameters: cx.peerSessionParams,
275
274
  caseAuthenticatedTags,
276
275
  });
277
- logger.info(
278
- `Session ${secureSession.id} created with ${cx.messenger.channelName} for Fabric ${NodeId.toHexString(
279
- fabric.nodeId,
280
- )} (index ${fabric.fabricIndex}) and PeerNode ${NodeId.toHexString(peerNodeId)}`,
281
- "with CATs",
282
- caseAuthenticatedTags,
283
- );
276
+
277
+ NodeSession.logNew(logger, "New", secureSession, cx.messenger, fabric, peerNodeId);
278
+
284
279
  await cx.messenger.sendSuccess();
285
280
 
286
281
  const resumptionRecord = {
@@ -106,7 +106,7 @@ export class PaseClient {
106
106
  peerSessionParameters,
107
107
  });
108
108
  await messenger.close();
109
- logger.info(`Pase client: Paired successfully with ${messenger.channelName}.`);
109
+ logger.info("Paired successfully »", messenger.channelName);
110
110
 
111
111
  return secureSession;
112
112
  }
@@ -7,6 +7,7 @@
7
7
  import {
8
8
  Bytes,
9
9
  Crypto,
10
+ Diagnostic,
10
11
  ec,
11
12
  Logger,
12
13
  MatterFlowError,
@@ -104,7 +105,7 @@ export class PaseServer implements ProtocolHandler {
104
105
  }
105
106
 
106
107
  private async handlePairingRequest(crypto: Crypto, messenger: PaseServerMessenger) {
107
- logger.info(`Received pairing request from ${messenger.channelName}.`);
108
+ logger.info("Received pairing request «", Diagnostic.via(messenger.channelName));
108
109
 
109
110
  this.#pairingTimer = Time.getTimer("PASE pairing timeout", PASE_PAIRING_TIMEOUT_MS, () =>
110
111
  this.cancelPairing(messenger),
@@ -167,7 +168,7 @@ export class PaseServer implements ProtocolHandler {
167
168
  isResumption: false,
168
169
  peerSessionParameters: initiatorSessionParams,
169
170
  });
170
- logger.info(`Session ${responderSessionId} created with ${messenger.channelName}.`);
171
+ logger.info(Diagnostic.strong(`Session ${responderSessionId} created`), "with", messenger.channelName);
171
172
 
172
173
  await messenger.sendSuccess();
173
174
  await messenger.close();