@matter/protocol 0.15.0-alpha.0-20250616-4b3754906 → 0.15.0-alpha.0-20250619-df2264f15

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 (207) hide show
  1. package/dist/cjs/certificate/AttestationCertificateManager.d.ts.map +1 -1
  2. package/dist/cjs/certificate/AttestationCertificateManager.js +26 -22
  3. package/dist/cjs/certificate/AttestationCertificateManager.js.map +1 -1
  4. package/dist/cjs/certificate/CertificateAuthority.d.ts +1 -2
  5. package/dist/cjs/certificate/CertificateAuthority.d.ts.map +1 -1
  6. package/dist/cjs/certificate/CertificateAuthority.js +22 -29
  7. package/dist/cjs/certificate/CertificateAuthority.js.map +1 -1
  8. package/dist/cjs/certificate/DeviceCertification.d.ts.map +1 -1
  9. package/dist/cjs/certificate/DeviceCertification.js +2 -6
  10. package/dist/cjs/certificate/DeviceCertification.js.map +1 -1
  11. package/dist/cjs/certificate/index.d.ts +7 -2
  12. package/dist/cjs/certificate/index.d.ts.map +1 -1
  13. package/dist/cjs/certificate/index.js +14 -2
  14. package/dist/cjs/certificate/index.js.map +1 -1
  15. package/dist/cjs/certificate/kinds/AttestationCertificates.d.ts +34 -0
  16. package/dist/cjs/certificate/kinds/AttestationCertificates.d.ts.map +1 -0
  17. package/dist/cjs/certificate/kinds/AttestationCertificates.js +64 -0
  18. package/dist/cjs/certificate/kinds/AttestationCertificates.js.map +6 -0
  19. package/dist/cjs/certificate/kinds/CertificationDeclaration.d.ts +23 -0
  20. package/dist/cjs/certificate/kinds/CertificationDeclaration.d.ts.map +1 -0
  21. package/dist/cjs/certificate/kinds/CertificationDeclaration.js +86 -0
  22. package/dist/cjs/certificate/kinds/CertificationDeclaration.js.map +6 -0
  23. package/dist/cjs/certificate/kinds/Icac.d.ts +29 -0
  24. package/dist/cjs/certificate/kinds/Icac.d.ts.map +1 -0
  25. package/dist/cjs/certificate/kinds/Icac.js +138 -0
  26. package/dist/cjs/certificate/kinds/Icac.js.map +6 -0
  27. package/dist/cjs/certificate/kinds/Noc.d.ts +27 -0
  28. package/dist/cjs/certificate/kinds/Noc.d.ts.map +1 -0
  29. package/dist/cjs/certificate/kinds/Noc.js +148 -0
  30. package/dist/cjs/certificate/kinds/Noc.js.map +6 -0
  31. package/dist/cjs/certificate/kinds/OperationalBase.d.ts +24 -0
  32. package/dist/cjs/certificate/kinds/OperationalBase.d.ts.map +1 -0
  33. package/dist/cjs/certificate/kinds/OperationalBase.js +68 -0
  34. package/dist/cjs/certificate/kinds/OperationalBase.js.map +6 -0
  35. package/dist/cjs/certificate/kinds/Rcac.d.ts +25 -0
  36. package/dist/cjs/certificate/kinds/Rcac.d.ts.map +1 -0
  37. package/dist/cjs/certificate/kinds/Rcac.js +119 -0
  38. package/dist/cjs/certificate/kinds/Rcac.js.map +6 -0
  39. package/dist/cjs/certificate/kinds/X509Base.d.ts +92 -0
  40. package/dist/cjs/certificate/kinds/X509Base.d.ts.map +1 -0
  41. package/dist/cjs/certificate/kinds/X509Base.js +344 -0
  42. package/dist/cjs/certificate/kinds/X509Base.js.map +6 -0
  43. package/dist/cjs/certificate/kinds/common.d.ts +18 -0
  44. package/dist/cjs/certificate/kinds/common.d.ts.map +1 -0
  45. package/dist/cjs/certificate/kinds/common.js +42 -0
  46. package/dist/cjs/certificate/kinds/common.js.map +6 -0
  47. package/dist/cjs/certificate/kinds/definitions/asn.d.ts +25 -0
  48. package/dist/cjs/certificate/kinds/definitions/asn.d.ts.map +1 -0
  49. package/dist/cjs/certificate/kinds/definitions/asn.js +83 -0
  50. package/dist/cjs/certificate/kinds/definitions/asn.js.map +6 -0
  51. package/dist/cjs/certificate/kinds/definitions/attestation.d.ts +44 -0
  52. package/dist/cjs/certificate/kinds/definitions/attestation.d.ts.map +1 -0
  53. package/dist/cjs/certificate/kinds/definitions/attestation.js +22 -0
  54. package/dist/cjs/certificate/kinds/definitions/attestation.js.map +6 -0
  55. package/dist/cjs/certificate/kinds/definitions/base.d.ts +52 -0
  56. package/dist/cjs/certificate/kinds/definitions/base.d.ts.map +1 -0
  57. package/dist/cjs/certificate/kinds/definitions/base.js +43 -0
  58. package/dist/cjs/certificate/kinds/definitions/base.js.map +6 -0
  59. package/dist/cjs/certificate/kinds/definitions/certification-declaration.d.ts +18 -0
  60. package/dist/cjs/certificate/kinds/definitions/certification-declaration.d.ts.map +1 -0
  61. package/dist/cjs/certificate/kinds/definitions/certification-declaration.js +50 -0
  62. package/dist/cjs/certificate/kinds/definitions/certification-declaration.js.map +6 -0
  63. package/dist/cjs/certificate/kinds/definitions/operational.d.ts +368 -0
  64. package/dist/cjs/certificate/kinds/definitions/operational.d.ts.map +1 -0
  65. package/dist/cjs/certificate/kinds/definitions/operational.js +149 -0
  66. package/dist/cjs/certificate/kinds/definitions/operational.js.map +6 -0
  67. package/dist/cjs/certificate/kinds/index.d.ts +12 -0
  68. package/dist/cjs/certificate/kinds/index.d.ts.map +1 -0
  69. package/dist/cjs/certificate/kinds/index.js +29 -0
  70. package/dist/cjs/certificate/kinds/index.js.map +6 -0
  71. package/dist/cjs/fabric/Fabric.d.ts +1 -2
  72. package/dist/cjs/fabric/Fabric.d.ts.map +1 -1
  73. package/dist/cjs/fabric/Fabric.js +28 -31
  74. package/dist/cjs/fabric/Fabric.js.map +1 -1
  75. package/dist/cjs/peer/ControllerCommissioningFlow.d.ts.map +1 -1
  76. package/dist/cjs/peer/ControllerCommissioningFlow.js +2 -1
  77. package/dist/cjs/peer/ControllerCommissioningFlow.js.map +1 -1
  78. package/dist/cjs/session/case/CaseClient.d.ts.map +1 -1
  79. package/dist/cjs/session/case/CaseClient.js +3 -3
  80. package/dist/cjs/session/case/CaseClient.js.map +1 -1
  81. package/dist/cjs/session/case/CaseServer.d.ts.map +1 -1
  82. package/dist/cjs/session/case/CaseServer.js +2 -2
  83. package/dist/cjs/session/case/CaseServer.js.map +1 -1
  84. package/dist/esm/certificate/AttestationCertificateManager.d.ts.map +1 -1
  85. package/dist/esm/certificate/AttestationCertificateManager.js +20 -16
  86. package/dist/esm/certificate/AttestationCertificateManager.js.map +1 -1
  87. package/dist/esm/certificate/CertificateAuthority.d.ts +1 -2
  88. package/dist/esm/certificate/CertificateAuthority.d.ts.map +1 -1
  89. package/dist/esm/certificate/CertificateAuthority.js +18 -30
  90. package/dist/esm/certificate/CertificateAuthority.js.map +1 -1
  91. package/dist/esm/certificate/DeviceCertification.d.ts.map +1 -1
  92. package/dist/esm/certificate/DeviceCertification.js +2 -6
  93. package/dist/esm/certificate/DeviceCertification.js.map +1 -1
  94. package/dist/esm/certificate/index.d.ts +7 -2
  95. package/dist/esm/certificate/index.d.ts.map +1 -1
  96. package/dist/esm/certificate/index.js +10 -2
  97. package/dist/esm/certificate/index.js.map +1 -1
  98. package/dist/esm/certificate/kinds/AttestationCertificates.d.ts +34 -0
  99. package/dist/esm/certificate/kinds/AttestationCertificates.d.ts.map +1 -0
  100. package/dist/esm/certificate/kinds/AttestationCertificates.js +44 -0
  101. package/dist/esm/certificate/kinds/AttestationCertificates.js.map +6 -0
  102. package/dist/esm/certificate/kinds/CertificationDeclaration.d.ts +23 -0
  103. package/dist/esm/certificate/kinds/CertificationDeclaration.d.ts.map +1 -0
  104. package/dist/esm/certificate/kinds/CertificationDeclaration.js +66 -0
  105. package/dist/esm/certificate/kinds/CertificationDeclaration.js.map +6 -0
  106. package/dist/esm/certificate/kinds/Icac.d.ts +29 -0
  107. package/dist/esm/certificate/kinds/Icac.d.ts.map +1 -0
  108. package/dist/esm/certificate/kinds/Icac.js +118 -0
  109. package/dist/esm/certificate/kinds/Icac.js.map +6 -0
  110. package/dist/esm/certificate/kinds/Noc.d.ts +27 -0
  111. package/dist/esm/certificate/kinds/Noc.d.ts.map +1 -0
  112. package/dist/esm/certificate/kinds/Noc.js +128 -0
  113. package/dist/esm/certificate/kinds/Noc.js.map +6 -0
  114. package/dist/esm/certificate/kinds/OperationalBase.d.ts +24 -0
  115. package/dist/esm/certificate/kinds/OperationalBase.d.ts.map +1 -0
  116. package/dist/esm/certificate/kinds/OperationalBase.js +48 -0
  117. package/dist/esm/certificate/kinds/OperationalBase.js.map +6 -0
  118. package/dist/esm/certificate/kinds/Rcac.d.ts +25 -0
  119. package/dist/esm/certificate/kinds/Rcac.d.ts.map +1 -0
  120. package/dist/esm/certificate/kinds/Rcac.js +99 -0
  121. package/dist/esm/certificate/kinds/Rcac.js.map +6 -0
  122. package/dist/esm/certificate/kinds/X509Base.d.ts +92 -0
  123. package/dist/esm/certificate/kinds/X509Base.d.ts.map +1 -0
  124. package/dist/esm/certificate/kinds/X509Base.js +347 -0
  125. package/dist/esm/certificate/kinds/X509Base.js.map +6 -0
  126. package/dist/esm/certificate/kinds/common.d.ts +18 -0
  127. package/dist/esm/certificate/kinds/common.d.ts.map +1 -0
  128. package/dist/esm/certificate/kinds/common.js +22 -0
  129. package/dist/esm/certificate/kinds/common.js.map +6 -0
  130. package/dist/esm/certificate/kinds/definitions/asn.d.ts +25 -0
  131. package/dist/esm/certificate/kinds/definitions/asn.d.ts.map +1 -0
  132. package/dist/esm/certificate/kinds/definitions/asn.js +63 -0
  133. package/dist/esm/certificate/kinds/definitions/asn.js.map +6 -0
  134. package/dist/esm/certificate/kinds/definitions/attestation.d.ts +44 -0
  135. package/dist/esm/certificate/kinds/definitions/attestation.d.ts.map +1 -0
  136. package/dist/esm/certificate/kinds/definitions/attestation.js +6 -0
  137. package/dist/esm/certificate/kinds/definitions/attestation.js.map +6 -0
  138. package/dist/esm/certificate/kinds/definitions/base.d.ts +52 -0
  139. package/dist/esm/certificate/kinds/definitions/base.d.ts.map +1 -0
  140. package/dist/esm/certificate/kinds/definitions/base.js +23 -0
  141. package/dist/esm/certificate/kinds/definitions/base.js.map +6 -0
  142. package/dist/esm/certificate/kinds/definitions/certification-declaration.d.ts +18 -0
  143. package/dist/esm/certificate/kinds/definitions/certification-declaration.d.ts.map +1 -0
  144. package/dist/esm/certificate/kinds/definitions/certification-declaration.js +41 -0
  145. package/dist/esm/certificate/kinds/definitions/certification-declaration.js.map +6 -0
  146. package/dist/esm/certificate/kinds/definitions/operational.d.ts +368 -0
  147. package/dist/esm/certificate/kinds/definitions/operational.d.ts.map +1 -0
  148. package/dist/esm/certificate/kinds/definitions/operational.js +148 -0
  149. package/dist/esm/certificate/kinds/definitions/operational.js.map +6 -0
  150. package/dist/esm/certificate/kinds/index.d.ts +12 -0
  151. package/dist/esm/certificate/kinds/index.d.ts.map +1 -0
  152. package/dist/esm/certificate/kinds/index.js +12 -0
  153. package/dist/esm/certificate/kinds/index.js.map +6 -0
  154. package/dist/esm/fabric/Fabric.d.ts +1 -2
  155. package/dist/esm/fabric/Fabric.d.ts.map +1 -1
  156. package/dist/esm/fabric/Fabric.js +28 -36
  157. package/dist/esm/fabric/Fabric.js.map +1 -1
  158. package/dist/esm/peer/ControllerCommissioningFlow.d.ts.map +1 -1
  159. package/dist/esm/peer/ControllerCommissioningFlow.js +2 -1
  160. package/dist/esm/peer/ControllerCommissioningFlow.js.map +1 -1
  161. package/dist/esm/session/case/CaseClient.d.ts.map +1 -1
  162. package/dist/esm/session/case/CaseClient.js +3 -3
  163. package/dist/esm/session/case/CaseClient.js.map +1 -1
  164. package/dist/esm/session/case/CaseServer.d.ts.map +1 -1
  165. package/dist/esm/session/case/CaseServer.js +2 -2
  166. package/dist/esm/session/case/CaseServer.js.map +1 -1
  167. package/package.json +6 -6
  168. package/src/certificate/AttestationCertificateManager.ts +20 -16
  169. package/src/certificate/CertificateAuthority.ts +18 -35
  170. package/src/certificate/DeviceCertification.ts +2 -6
  171. package/src/certificate/index.ts +7 -2
  172. package/src/certificate/kinds/AttestationCertificates.ts +48 -0
  173. package/src/certificate/kinds/CertificationDeclaration.ts +91 -0
  174. package/src/certificate/kinds/Icac.ts +156 -0
  175. package/src/certificate/kinds/Noc.ts +164 -0
  176. package/src/certificate/kinds/OperationalBase.ts +72 -0
  177. package/src/certificate/kinds/Rcac.ts +126 -0
  178. package/src/certificate/kinds/X509Base.ts +380 -0
  179. package/src/certificate/kinds/common.ts +24 -0
  180. package/src/certificate/kinds/definitions/asn.ts +97 -0
  181. package/src/certificate/kinds/definitions/attestation.ts +46 -0
  182. package/src/certificate/kinds/definitions/base.ts +43 -0
  183. package/src/certificate/kinds/definitions/certification-declaration.ts +38 -0
  184. package/src/certificate/kinds/definitions/operational.ts +179 -0
  185. package/src/certificate/kinds/index.ts +12 -0
  186. package/src/fabric/Fabric.ts +28 -40
  187. package/src/peer/ControllerCommissioningFlow.ts +2 -1
  188. package/src/session/case/CaseClient.ts +3 -3
  189. package/src/session/case/CaseServer.ts +2 -2
  190. package/dist/cjs/certificate/CertificateManager.d.ts +0 -578
  191. package/dist/cjs/certificate/CertificateManager.d.ts.map +0 -1
  192. package/dist/cjs/certificate/CertificateManager.js +0 -843
  193. package/dist/cjs/certificate/CertificateManager.js.map +0 -6
  194. package/dist/cjs/certificate/CertificationDeclarationManager.d.ts +0 -11
  195. package/dist/cjs/certificate/CertificationDeclarationManager.d.ts.map +0 -1
  196. package/dist/cjs/certificate/CertificationDeclarationManager.js +0 -54
  197. package/dist/cjs/certificate/CertificationDeclarationManager.js.map +0 -6
  198. package/dist/esm/certificate/CertificateManager.d.ts +0 -578
  199. package/dist/esm/certificate/CertificateManager.d.ts.map +0 -1
  200. package/dist/esm/certificate/CertificateManager.js +0 -870
  201. package/dist/esm/certificate/CertificateManager.js.map +0 -6
  202. package/dist/esm/certificate/CertificationDeclarationManager.d.ts +0 -11
  203. package/dist/esm/certificate/CertificationDeclarationManager.d.ts.map +0 -1
  204. package/dist/esm/certificate/CertificationDeclarationManager.js +0 -34
  205. package/dist/esm/certificate/CertificationDeclarationManager.js.map +0 -6
  206. package/src/certificate/CertificateManager.ts +0 -1176
  207. package/src/certificate/CertificationDeclarationManager.ts +0 -52
@@ -0,0 +1,128 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2022-2025 Matter.js Authors
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { Bytes, Diagnostic, PublicKey } from "#general";
7
+ import { CaseAuthenticatedTag, FabricId, NodeId } from "#types";
8
+ import { CertificateError } from "./common.js";
9
+ import { OperationalCertificate } from "./definitions/operational.js";
10
+ import { OperationalBase } from "./OperationalBase.js";
11
+ class Noc extends OperationalBase {
12
+ /** Construct the class from a Tlv version of the certificate */
13
+ static fromTlv(tlv) {
14
+ return new Noc(OperationalCertificate.TlvNoc.decode(tlv));
15
+ }
16
+ /** Validates all basic certificate fields on construction. */
17
+ validateFields() {
18
+ const {
19
+ issuer: { icacId, rcacId },
20
+ extensions: {
21
+ basicConstraints: { isCa }
22
+ }
23
+ } = this.cert;
24
+ if (icacId === void 0 && rcacId === void 0) {
25
+ throw new CertificateError("Issuer RCAC or ICAC ID must be defined for an operational certificate.");
26
+ }
27
+ if (isCa) {
28
+ throw new CertificateError("Node operational certificate must not be a CA.");
29
+ }
30
+ }
31
+ /**
32
+ * Encodes the certificate with the signature as Matter Tlv.
33
+ * If the certificate is not signed, it throws a CertificateError.
34
+ */
35
+ asSignedTlv() {
36
+ return OperationalCertificate.TlvNoc.encode({ ...this.cert, signature: this.signature });
37
+ }
38
+ /**
39
+ * Verify requirements a Matter Node Operational certificate must fulfill.
40
+ * Rules for this are listed in @see {@link MatterSpecification.v12.Core} §6.5.x
41
+ */
42
+ async verify(crypto, root, ica) {
43
+ this.generalVerify();
44
+ const {
45
+ subject,
46
+ extensions: { extendedKeyUsage, subjectKeyIdentifier, authorityKeyIdentifier }
47
+ } = this.cert;
48
+ const { nodeId, fabricId, caseAuthenticatedTags } = subject;
49
+ const {
50
+ subject: { fabricId: rootFabricId }
51
+ } = root.cert;
52
+ const {
53
+ subject: { fabricId: icaFabricId }
54
+ } = ica?.cert ?? { subject: {} };
55
+ if (nodeId === void 0 || Array.isArray(nodeId)) {
56
+ throw new CertificateError(`Invalid nodeId in NoC certificate: ${Diagnostic.json(nodeId)}`);
57
+ }
58
+ if (!NodeId.isOperationalNodeId(nodeId)) {
59
+ throw new CertificateError(`Invalid nodeId in NoC certificate: ${Diagnostic.json(nodeId)}`);
60
+ }
61
+ if (fabricId === void 0 || Array.isArray(fabricId)) {
62
+ throw new CertificateError(`Invalid fabricId in NoC certificate: ${Diagnostic.json(fabricId)}`);
63
+ }
64
+ if (fabricId === FabricId(0)) {
65
+ throw new CertificateError(`Invalid fabricId in NoC certificate: ${Diagnostic.json(fabricId)}`);
66
+ }
67
+ if ("icacId" in subject) {
68
+ throw new CertificateError(`Noc certificate must not contain an icacId.`);
69
+ }
70
+ if ("rcacId" in subject) {
71
+ throw new CertificateError(`Noc certificate must not contain an rcacId.`);
72
+ }
73
+ if (caseAuthenticatedTags !== void 0) {
74
+ CaseAuthenticatedTag.validateNocTagList(caseAuthenticatedTags);
75
+ }
76
+ if (rootFabricId !== void 0 && rootFabricId !== fabricId) {
77
+ throw new CertificateError(
78
+ `FabricId in NoC certificate does not match the fabricId in the parent certificate. ${Diagnostic.json(
79
+ rootFabricId
80
+ )} !== ${Diagnostic.json(fabricId)}`
81
+ );
82
+ }
83
+ if (icaFabricId !== void 0 && icaFabricId !== fabricId) {
84
+ throw new CertificateError(
85
+ `FabricId in NoC certificate does not match the fabricId in the parent certificate. ${Diagnostic.json(
86
+ icaFabricId
87
+ )} !== ${Diagnostic.json(fabricId)}`
88
+ );
89
+ }
90
+ if (this.cert.extensions.basicConstraints.isCa) {
91
+ throw new CertificateError(`Noc certificate must not have isCa set to true.`);
92
+ }
93
+ if (!this.cert.extensions.keyUsage.digitalSignature) {
94
+ throw new CertificateError(`Noc certificate must have keyUsage set to digitalSignature.`);
95
+ }
96
+ if (extendedKeyUsage === void 0 || !extendedKeyUsage.includes(1) && !extendedKeyUsage.includes(2)) {
97
+ throw new CertificateError(
98
+ `Noc certificate must have extendedKeyUsage with serverAuth and clientAuth: ${Diagnostic.json(extendedKeyUsage)}`
99
+ );
100
+ }
101
+ if (subjectKeyIdentifier === void 0) {
102
+ throw new CertificateError(`Noc certificate must have subjectKeyIdentifier set.`);
103
+ }
104
+ if (subjectKeyIdentifier.length !== 20) {
105
+ throw new CertificateError(`Noc certificate subjectKeyIdentifier must be 160 bit.`);
106
+ }
107
+ if (authorityKeyIdentifier === void 0) {
108
+ throw new CertificateError(`Noc certificate must have authorityKeyIdentifier set.`);
109
+ }
110
+ if (authorityKeyIdentifier.length !== 20) {
111
+ throw new CertificateError(`Noc certificate authorityKeyIdentifier must be 160 bit.`);
112
+ }
113
+ if (!Bytes.areEqual(authorityKeyIdentifier, (ica?.cert ?? root.cert).extensions.subjectKeyIdentifier)) {
114
+ throw new CertificateError(
115
+ `Noc certificate authorityKeyIdentifier must be equal to Root/Ica subjectKeyIdentifier.`
116
+ );
117
+ }
118
+ await crypto.verifyEcdsa(
119
+ PublicKey((ica?.cert ?? root.cert).ellipticCurvePublicKey),
120
+ this.asUnsignedAsn1(),
121
+ this.signature
122
+ );
123
+ }
124
+ }
125
+ export {
126
+ Noc
127
+ };
128
+ //# sourceMappingURL=Noc.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/certificate/kinds/Noc.ts"],
4
+ "mappings": "AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,SAAS,OAAe,YAAY,iBAAiB;AACrD,SAAS,sBAAsB,UAAU,cAAc;AACvD,SAAS,wBAAwB;AACjC,SAAS,8BAA8B;AAEvC,SAAS,uBAAuB;AAGzB,MAAM,YAAY,gBAA4C;AAAA;AAAA,EAEjE,OAAO,QAAQ,KAAiB;AAC5B,WAAO,IAAI,IAAI,uBAAuB,OAAO,OAAO,GAAG,CAAC;AAAA,EAC5D;AAAA;AAAA,EAGU,iBAAiB;AACvB,UAAM;AAAA,MACF,QAAQ,EAAE,QAAQ,OAAO;AAAA,MACzB,YAAY;AAAA,QACR,kBAAkB,EAAE,KAAK;AAAA,MAC7B;AAAA,IACJ,IAAI,KAAK;AACT,QAAI,WAAW,UAAa,WAAW,QAAW;AAC9C,YAAM,IAAI,iBAAiB,wEAAwE;AAAA,IACvG;AACA,QAAI,MAA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,UAAM,OAAO;AAAA,MACT,WAAW,KAAK,QAAQ,KAAK,MAAM,sBAAsB;AAAA,MACzD,KAAK,eAAe;AAAA,MACpB,KAAK;AAAA,IACT;AAAA,EACJ;AACJ;",
5
+ "names": []
6
+ }
@@ -0,0 +1,24 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2022-2025 Matter.js Authors
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { X509Base } from "./X509Base.js";
7
+ import { Unsigned } from "./common.js";
8
+ import { X509Certificate } from "./definitions/base.js";
9
+ /**
10
+ * Base class for all operational certificates (RCAC, ICAC, NOC)
11
+ */
12
+ export declare abstract class OperationalBase<CT extends X509Certificate> extends X509Base<CT> {
13
+ constructor(cert: CT | Unsigned<CT>);
14
+ /** Validates all basic certificate fields on construction. */
15
+ protected abstract validateFields(): void;
16
+ /** Encodes the signed certificate into the Matter TLV format. */
17
+ abstract asSignedTlv(signature: Uint8Array<ArrayBufferLike>): Uint8Array;
18
+ /**
19
+ * Verifies general requirements a Matter certificate fields must fulfill.
20
+ * Rules for this are listed in @see {@link MatterSpecification.v12.Core} §6.5.x
21
+ */
22
+ generalVerify(): void;
23
+ }
24
+ //# sourceMappingURL=OperationalBase.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OperationalBase.d.ts","sourceRoot":"","sources":["../../../../src/certificate/kinds/OperationalBase.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAoB,QAAQ,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAIxD;;GAEG;AACH,8BAAsB,eAAe,CAAC,EAAE,SAAS,eAAe,CAAE,SAAQ,QAAQ,CAAC,EAAE,CAAC;gBACtE,IAAI,EAAE,EAAE,GAAG,QAAQ,CAAC,EAAE,CAAC;IAKnC,8DAA8D;IAC9D,SAAS,CAAC,QAAQ,CAAC,cAAc,IAAI,IAAI;IAEzC,iEAAiE;IACjE,QAAQ,CAAC,WAAW,CAAC,SAAS,EAAE,UAAU,CAAC,eAAe,CAAC,GAAG,UAAU;IAExE;;;OAGG;IACH,aAAa;CAuChB"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2022-2025 Matter.js Authors
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { Logger, Time } from "#general";
7
+ import { X509Base } from "./X509Base.js";
8
+ import { CertificateError } from "./common.js";
9
+ const logger = Logger.get("OperationalBaseCertificate");
10
+ class OperationalBase extends X509Base {
11
+ constructor(cert) {
12
+ super(cert);
13
+ this.validateFields();
14
+ }
15
+ /**
16
+ * Verifies general requirements a Matter certificate fields must fulfill.
17
+ * Rules for this are listed in @see {@link MatterSpecification.v12.Core} §6.5.x
18
+ */
19
+ generalVerify() {
20
+ const cert = this.cert;
21
+ if (cert.serialNumber.length > 20)
22
+ throw new CertificateError(
23
+ `Serial number must not be longer then 20 octets. Current serial number has ${cert.serialNumber.length} octets.`
24
+ );
25
+ if (cert.signatureAlgorithm !== 1) {
26
+ throw new CertificateError(`Unsupported signature algorithm: ${cert.signatureAlgorithm}`);
27
+ }
28
+ if (cert.publicKeyAlgorithm !== 1) {
29
+ throw new CertificateError(`Unsupported public key algorithm: ${cert.publicKeyAlgorithm}`);
30
+ }
31
+ if (cert.ellipticCurveIdentifier !== 1) {
32
+ throw new CertificateError(`Unsupported elliptic curve identifier: ${cert.ellipticCurveIdentifier}`);
33
+ }
34
+ if (Object.keys(cert.subject).length > 5) {
35
+ throw new CertificateError(`Certificate subject must not contain more than 5 RDNs.`);
36
+ }
37
+ if (Object.keys(cert.issuer).length > 5) {
38
+ throw new CertificateError(`Certificate issuer must not contain more than 5 RDNs.`);
39
+ }
40
+ if (cert.notBefore * 1e3 > Time.nowMs()) {
41
+ logger.warn(`Certificate notBefore date is in the future: ${cert.notBefore * 1e3} vs ${Time.nowMs()}`);
42
+ }
43
+ }
44
+ }
45
+ export {
46
+ OperationalBase
47
+ };
48
+ //# sourceMappingURL=OperationalBase.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/certificate/kinds/OperationalBase.ts"],
4
+ "mappings": "AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,SAAS,QAAQ,YAAY;AAC7B,SAAS,gBAAgB;AACzB,SAAS,wBAAkC;AAG3C,MAAM,SAAS,OAAO,IAAI,4BAA4B;AAK/C,MAAe,wBAAoD,SAAa;AAAA,EACnF,YAAY,MAAyB;AACjC,UAAM,IAAI;AACV,SAAK,eAAe;AAAA,EACxB;AAAA;AAAA;AAAA;AAAA;AAAA,EAYA,gBAAgB;AACZ,UAAM,OAAO,KAAK;AAClB,QAAI,KAAK,aAAa,SAAS;AAC3B,YAAM,IAAI;AAAA,QACN,8EAA8E,KAAK,aAAa,MAAM;AAAA,MAC1G;AAEJ,QAAI,KAAK,uBAAuB,GAAG;AAE/B,YAAM,IAAI,iBAAiB,oCAAoC,KAAK,kBAAkB,EAAE;AAAA,IAC5F;AAEA,QAAI,KAAK,uBAAuB,GAAG;AAE/B,YAAM,IAAI,iBAAiB,qCAAqC,KAAK,kBAAkB,EAAE;AAAA,IAC7F;AAEA,QAAI,KAAK,4BAA4B,GAAG;AAEpC,YAAM,IAAI,iBAAiB,0CAA0C,KAAK,uBAAuB,EAAE;AAAA,IACvG;AAGA,QAAI,OAAO,KAAK,KAAK,OAAO,EAAE,SAAS,GAAG;AACtC,YAAM,IAAI,iBAAiB,wDAAwD;AAAA,IACvF;AACA,QAAI,OAAO,KAAK,KAAK,MAAM,EAAE,SAAS,GAAG;AACrC,YAAM,IAAI,iBAAiB,uDAAuD;AAAA,IACtF;AAIA,QAAI,KAAK,YAAY,MAAO,KAAK,MAAM,GAAG;AACtC,aAAO,KAAK,gDAAgD,KAAK,YAAY,GAAI,OAAO,KAAK,MAAM,CAAC,EAAE;AAAA,IAI1G;AAAA,EACJ;AACJ;",
5
+ "names": []
6
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2022-2025 Matter.js Authors
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { Crypto } from "#general";
7
+ import { OperationalCertificate } from "./definitions/operational.js";
8
+ import { OperationalBase } from "./OperationalBase.js";
9
+ export declare class Rcac extends OperationalBase<OperationalCertificate.Rcac> {
10
+ /** Construct the class from a Tlv version of the certificate */
11
+ static fromTlv(tlv: Uint8Array): Rcac;
12
+ /** Validates all basic certificate fields on construction. */
13
+ protected validateFields(): void;
14
+ /**
15
+ * Encodes the certificate with the signature as Matter Tlv.
16
+ * If the certificate is not signed, it throws a CertificateError.
17
+ */
18
+ asSignedTlv(): Uint8Array<ArrayBufferLike>;
19
+ /**
20
+ * Verify requirements a Matter Root certificate must fulfill.
21
+ * Rules for this are listed in @see {@link MatterSpecification.v12.Core} §6.5.x
22
+ */
23
+ verify(crypto: Crypto): Promise<void>;
24
+ }
25
+ //# sourceMappingURL=Rcac.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Rcac.d.ts","sourceRoot":"","sources":["../../../../src/certificate/kinds/Rcac.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAS,MAAM,EAAyB,MAAM,UAAU,CAAC;AAIhE,OAAO,EAAE,sBAAsB,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,qBAAa,IAAK,SAAQ,eAAe,CAAC,sBAAsB,CAAC,IAAI,CAAC;IAClE,gEAAgE;IAChE,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,UAAU,GAAG,IAAI;IAIrC,8DAA8D;IAC9D,SAAS,CAAC,cAAc;IAWxB;;;OAGG;IACH,WAAW;IAIX;;;OAGG;IACG,MAAM,CAAC,MAAM,EAAE,MAAM;CAkF9B"}
@@ -0,0 +1,99 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2022-2025 Matter.js Authors
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { Bytes, Diagnostic, PublicKey } from "#general";
7
+ import { FabricId } from "#types";
8
+ import { CertificateError } from "./common.js";
9
+ import { ExtensionKeyUsageSchema } from "./definitions/base.js";
10
+ import { OperationalCertificate } from "./definitions/operational.js";
11
+ import { OperationalBase } from "./OperationalBase.js";
12
+ class Rcac extends OperationalBase {
13
+ /** Construct the class from a Tlv version of the certificate */
14
+ static fromTlv(tlv) {
15
+ return new Rcac(OperationalCertificate.TlvRcac.decode(tlv));
16
+ }
17
+ /** Validates all basic certificate fields on construction. */
18
+ validateFields() {
19
+ const {
20
+ extensions: {
21
+ basicConstraints: { isCa }
22
+ }
23
+ } = this.cert;
24
+ if (!isCa) {
25
+ throw new CertificateError("Root certificate must be a CA.");
26
+ }
27
+ }
28
+ /**
29
+ * Encodes the certificate with the signature as Matter Tlv.
30
+ * If the certificate is not signed, it throws a CertificateError.
31
+ */
32
+ asSignedTlv() {
33
+ return OperationalCertificate.TlvRcac.encode({ ...this.cert, signature: this.signature });
34
+ }
35
+ /**
36
+ * Verify requirements a Matter Root certificate must fulfill.
37
+ * Rules for this are listed in @see {@link MatterSpecification.v12.Core} §6.5.x
38
+ */
39
+ async verify(crypto) {
40
+ this.generalVerify();
41
+ const { subject, extensions } = this.cert;
42
+ const { fabricId, rcacId } = subject;
43
+ const { basicConstraints, subjectKeyIdentifier, authorityKeyIdentifier } = extensions;
44
+ if ("nodeId" in subject) {
45
+ throw new CertificateError(`Root certificate must not contain a nodeId.`);
46
+ }
47
+ if (fabricId !== void 0) {
48
+ if (Array.isArray(fabricId)) {
49
+ throw new CertificateError(`Invalid fabricId in NoC certificate: ${Diagnostic.json(fabricId)}`);
50
+ }
51
+ if (fabricId === FabricId(0)) {
52
+ throw new CertificateError(`Invalid fabricId in NoC certificate: ${Diagnostic.json(fabricId)}`);
53
+ }
54
+ }
55
+ if ("icacId" in subject) {
56
+ throw new CertificateError(`Root certificate must not contain an icacId.`);
57
+ }
58
+ if (rcacId === void 0 || Array.isArray(rcacId)) {
59
+ throw new CertificateError(`Invalid rcacId in Root certificate: ${Diagnostic.json(rcacId)}`);
60
+ }
61
+ if ("caseAuthenticatedTags" in subject) {
62
+ throw new CertificateError(`Root certificate must not contain a caseAuthenticatedTags.`);
63
+ }
64
+ if (basicConstraints.isCa !== true) {
65
+ throw new CertificateError(`Root certificate must have isCa set to true.`);
66
+ }
67
+ const keyUsage = ExtensionKeyUsageSchema.encode(extensions.keyUsage);
68
+ if (keyUsage !== 96 && keyUsage !== 97) {
69
+ throw new CertificateError(
70
+ `Root certificate keyUsage must have keyCertSign and CRLSign and optionally digitalSignature set.`
71
+ );
72
+ }
73
+ if (extensions.extendedKeyUsage !== void 0) {
74
+ throw new CertificateError(`Root certificate must not have extendedKeyUsage set.`);
75
+ }
76
+ if (subjectKeyIdentifier === void 0) {
77
+ throw new CertificateError(`Root certificate must have subjectKeyIdentifier set.`);
78
+ }
79
+ if (subjectKeyIdentifier.length !== 20) {
80
+ throw new CertificateError(`Root certificate subjectKeyIdentifier must be 160 bit.`);
81
+ }
82
+ if (authorityKeyIdentifier === void 0) {
83
+ throw new CertificateError(`Root certificate must have authorityKeyIdentifier set.`);
84
+ }
85
+ if (authorityKeyIdentifier.length !== 20) {
86
+ throw new CertificateError(`Root certificate authorityKeyIdentifier must be 160 bit.`);
87
+ }
88
+ if (!Bytes.areEqual(authorityKeyIdentifier, subjectKeyIdentifier)) {
89
+ throw new CertificateError(
90
+ `Root certificate authorityKeyIdentifier must be equal to subjectKeyIdentifier.`
91
+ );
92
+ }
93
+ await crypto.verifyEcdsa(PublicKey(this.cert.ellipticCurvePublicKey), this.asUnsignedAsn1(), this.signature);
94
+ }
95
+ }
96
+ export {
97
+ Rcac
98
+ };
99
+ //# sourceMappingURL=Rcac.js.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/certificate/kinds/R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unsigned } from "./common.js";
8
+ import { X509Certificate } from "./definitions/base.js";
9
+ /**
10
+ * Abstract definition of a X.509 certificate that can be signed and converted to ASN.1 DER format.
11
+ * It also provides two static methods to create a certificate signing request (CSR) and to extract the public key
12
+ * from a CSR.
13
+ */
14
+ export declare abstract class X509Base<CT extends X509Certificate> {
15
+ #private;
16
+ constructor(cert: CT | Unsigned<CT>);
17
+ get cert(): Unsigned<CT>;
18
+ get isSigned(): boolean;
19
+ /**
20
+ * Get the signature of the certificate.
21
+ * If the certificate is not signed, it throws a CertificateError.
22
+ */
23
+ get signature(): Uint8Array;
24
+ /**
25
+ * Set the signature of the certificate.
26
+ * If the certificate is already signed, it throws a CertificateError.
27
+ */
28
+ set signature(signature: Uint8Array);
29
+ /**
30
+ * Sign the certificate using the provided crypto and key.
31
+ * It throws a CertificateError if the certificate is already signed.
32
+ */
33
+ sign(crypto: Crypto, key: JsonWebKey): Promise<void>;
34
+ /**
35
+ * Convert the certificate to ASN.1 DER format without signature.
36
+ */
37
+ asUnsignedAsn1(): Uint8Array<ArrayBufferLike>;
38
+ /**
39
+ * Build the ASN.1 DER structure for the certificate.
40
+ */
41
+ protected genericBuildAsn1Structure({ serialNumber, notBefore, notAfter, issuer, subject, ellipticCurvePublicKey, extensions, }: Unsigned<CT>): {
42
+ version: {
43
+ _tag: number;
44
+ _bytes: Uint8Array<ArrayBuffer>;
45
+ };
46
+ serialNumber: {
47
+ _type: DerType;
48
+ _raw: any;
49
+ };
50
+ signatureAlgorithm: any;
51
+ issuer: {
52
+ [field: string]: any[];
53
+ };
54
+ validity: {
55
+ notBefore: Date;
56
+ notAfter: Date;
57
+ };
58
+ subject: {
59
+ [field: string]: any[];
60
+ };
61
+ publicKey: {
62
+ type: {
63
+ algorithm: {
64
+ _tag: number;
65
+ _bytes: Uint8Array<ArrayBuffer>;
66
+ };
67
+ curve: {
68
+ _tag: number;
69
+ _bytes: Uint8Array<ArrayBuffer>;
70
+ };
71
+ };
72
+ bytes: {
73
+ _tag: number;
74
+ _bytes: Uint8Array<ArrayBufferLike>;
75
+ _padding: number;
76
+ };
77
+ };
78
+ extensions: {
79
+ _tag: number;
80
+ _bytes: Uint8Array<ArrayBuffer>;
81
+ };
82
+ };
83
+ /**
84
+ * Create a Certificate Signing Request (CSR) in ASN.1 DER format.
85
+ */
86
+ static createCertificateSigningRequest(crypto: Crypto, key: Key): Promise<Uint8Array<ArrayBufferLike>>;
87
+ /**
88
+ * Extract the public key from a Certificate Signing Request (CSR) in ASN.1 DER format.
89
+ */
90
+ static getPublicKeyFromCsr(crypto: Crypto, csr: Uint8Array): Promise<Uint8Array<ArrayBufferLike>>;
91
+ }
92
+ //# sourceMappingURL=X509Base.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"X509Base.d.ts","sourceRoot":"","sources":["../../../../src/certificate/kinds/X509Base.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAGH,MAAM,EAKN,OAAO,EACP,GAAG,EAMN,MAAM,UAAU,CAAC;AAElB,OAAO,EAA8C,QAAQ,EAAE,MAAM,aAAa,CAAC;AAYnF,OAAO,EAAoD,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAG1G;;;;GAIG;AACH,8BAAsB,QAAQ,CAAC,EAAE,SAAS,eAAe;;gBAIzC,IAAI,EAAE,EAAE,GAAG,QAAQ,CAAC,EAAE,CAAC;IAOnC,IAAI,IAAI,IAAI,QAAQ,CAAC,EAAE,CAAC,CAEvB;IAED,IAAI,QAAQ,YAEX;IAED;;;OAGG;IACH,IAAI,SAAS,IAWY,UAAU,CANlC;IAED;;;OAGG;IACH,IAAI,SAAS,CAAC,SAAS,EAAE,UAAU,EAKlC;IAED;;;OAGG;IACG,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU;IAI1C;;OAEG;IACH,cAAc,IAAI,UAAU,CAAC,eAAe,CAAC;IAiM7C;;OAEG;IACH,SAAS,CAAC,yBAAyB,CAAC,EAChC,YAAY,EACZ,SAAS,EACT,QAAQ,EACR,MAAM,EACN,OAAO,EACP,sBAAsB,EACtB,UAAU,GACb,EAAE,QAAQ,CAAC,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAsBf;;OAEG;WACU,+BAA+B,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG;IAerE;;OAEG;WACU,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,UAAU;CAqCnE"}