@matter/protocol 0.15.0-alpha.0-20250617-f4d4cad23 → 0.15.0-alpha.0-20250620-16e218ed3
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.
- package/dist/cjs/action/client/index.d.ts +1 -1
- package/dist/cjs/action/client/index.js +1 -1
- package/dist/cjs/action/errors.d.ts +12 -0
- package/dist/cjs/action/errors.d.ts.map +1 -1
- package/dist/cjs/action/errors.js +13 -1
- package/dist/cjs/action/errors.js.map +1 -1
- package/dist/cjs/action/protocols.d.ts +1 -1
- package/dist/cjs/action/protocols.js +1 -1
- package/dist/cjs/action/server/AttributeReadResponse.d.ts +1 -1
- package/dist/cjs/action/server/AttributeReadResponse.js +1 -1
- package/dist/cjs/action/server/AttributeSubscriptionResponse.d.ts +1 -1
- package/dist/cjs/action/server/AttributeSubscriptionResponse.js +1 -1
- package/dist/cjs/action/server/AttributeWriteResponse.d.ts +1 -1
- package/dist/cjs/action/server/AttributeWriteResponse.js +1 -1
- package/dist/cjs/action/server/CommandInvokeResponse.d.ts +1 -1
- package/dist/cjs/action/server/CommandInvokeResponse.js +1 -1
- package/dist/cjs/action/server/DataResponse.d.ts +1 -1
- package/dist/cjs/action/server/DataResponse.js +1 -1
- package/dist/cjs/action/server/EventReadResponse.d.ts +1 -1
- package/dist/cjs/action/server/EventReadResponse.js +1 -1
- package/dist/cjs/action/server/ServerInteraction.d.ts +1 -1
- package/dist/cjs/action/server/ServerInteraction.js +1 -1
- package/dist/cjs/action/server/index.d.ts +1 -1
- package/dist/cjs/action/server/index.js +1 -1
- package/dist/cjs/certificate/AttestationCertificateManager.d.ts.map +1 -1
- package/dist/cjs/certificate/AttestationCertificateManager.js +26 -22
- package/dist/cjs/certificate/AttestationCertificateManager.js.map +1 -1
- package/dist/cjs/certificate/CertificateAuthority.d.ts +1 -2
- package/dist/cjs/certificate/CertificateAuthority.d.ts.map +1 -1
- package/dist/cjs/certificate/CertificateAuthority.js +22 -29
- package/dist/cjs/certificate/CertificateAuthority.js.map +1 -1
- package/dist/cjs/certificate/DeviceCertification.d.ts.map +1 -1
- package/dist/cjs/certificate/DeviceCertification.js +2 -6
- package/dist/cjs/certificate/DeviceCertification.js.map +1 -1
- package/dist/cjs/certificate/index.d.ts +7 -2
- package/dist/cjs/certificate/index.d.ts.map +1 -1
- package/dist/cjs/certificate/index.js +14 -2
- package/dist/cjs/certificate/index.js.map +1 -1
- package/dist/cjs/certificate/kinds/AttestationCertificates.d.ts +34 -0
- package/dist/cjs/certificate/kinds/AttestationCertificates.d.ts.map +1 -0
- package/dist/cjs/certificate/kinds/AttestationCertificates.js +64 -0
- package/dist/cjs/certificate/kinds/AttestationCertificates.js.map +6 -0
- package/dist/cjs/certificate/kinds/CertificationDeclaration.d.ts +23 -0
- package/dist/cjs/certificate/kinds/CertificationDeclaration.d.ts.map +1 -0
- package/dist/cjs/certificate/kinds/CertificationDeclaration.js +86 -0
- package/dist/cjs/certificate/kinds/CertificationDeclaration.js.map +6 -0
- package/dist/cjs/certificate/kinds/Icac.d.ts +29 -0
- package/dist/cjs/certificate/kinds/Icac.d.ts.map +1 -0
- package/dist/cjs/certificate/kinds/Icac.js +138 -0
- package/dist/cjs/certificate/kinds/Icac.js.map +6 -0
- package/dist/cjs/certificate/kinds/Noc.d.ts +27 -0
- package/dist/cjs/certificate/kinds/Noc.d.ts.map +1 -0
- package/dist/cjs/certificate/kinds/Noc.js +148 -0
- package/dist/cjs/certificate/kinds/Noc.js.map +6 -0
- package/dist/cjs/certificate/kinds/OperationalBase.d.ts +24 -0
- package/dist/cjs/certificate/kinds/OperationalBase.d.ts.map +1 -0
- package/dist/cjs/certificate/kinds/OperationalBase.js +68 -0
- package/dist/cjs/certificate/kinds/OperationalBase.js.map +6 -0
- package/dist/cjs/certificate/kinds/Rcac.d.ts +25 -0
- package/dist/cjs/certificate/kinds/Rcac.d.ts.map +1 -0
- package/dist/cjs/certificate/kinds/Rcac.js +119 -0
- package/dist/cjs/certificate/kinds/Rcac.js.map +6 -0
- package/dist/cjs/certificate/kinds/X509Base.d.ts +92 -0
- package/dist/cjs/certificate/kinds/X509Base.d.ts.map +1 -0
- package/dist/cjs/certificate/kinds/X509Base.js +344 -0
- package/dist/cjs/certificate/kinds/X509Base.js.map +6 -0
- package/dist/cjs/certificate/kinds/common.d.ts +18 -0
- package/dist/cjs/certificate/kinds/common.d.ts.map +1 -0
- package/dist/cjs/certificate/kinds/common.js +42 -0
- package/dist/cjs/certificate/kinds/common.js.map +6 -0
- package/dist/cjs/certificate/kinds/definitions/asn.d.ts +25 -0
- package/dist/cjs/certificate/kinds/definitions/asn.d.ts.map +1 -0
- package/dist/cjs/certificate/kinds/definitions/asn.js +83 -0
- package/dist/cjs/certificate/kinds/definitions/asn.js.map +6 -0
- package/dist/cjs/certificate/kinds/definitions/attestation.d.ts +44 -0
- package/dist/cjs/certificate/kinds/definitions/attestation.d.ts.map +1 -0
- package/dist/cjs/certificate/kinds/definitions/attestation.js +22 -0
- package/dist/cjs/certificate/kinds/definitions/attestation.js.map +6 -0
- package/dist/cjs/certificate/kinds/definitions/base.d.ts +52 -0
- package/dist/cjs/certificate/kinds/definitions/base.d.ts.map +1 -0
- package/dist/cjs/certificate/kinds/definitions/base.js +43 -0
- package/dist/cjs/certificate/kinds/definitions/base.js.map +6 -0
- package/dist/cjs/certificate/kinds/definitions/certification-declaration.d.ts +18 -0
- package/dist/cjs/certificate/kinds/definitions/certification-declaration.d.ts.map +1 -0
- package/dist/cjs/certificate/kinds/definitions/certification-declaration.js +50 -0
- package/dist/cjs/certificate/kinds/definitions/certification-declaration.js.map +6 -0
- package/dist/cjs/certificate/kinds/definitions/operational.d.ts +368 -0
- package/dist/cjs/certificate/kinds/definitions/operational.d.ts.map +1 -0
- package/dist/cjs/certificate/kinds/definitions/operational.js +149 -0
- package/dist/cjs/certificate/kinds/definitions/operational.js.map +6 -0
- package/dist/cjs/certificate/kinds/index.d.ts +12 -0
- package/dist/cjs/certificate/kinds/index.d.ts.map +1 -0
- package/dist/cjs/certificate/kinds/index.js +29 -0
- package/dist/cjs/certificate/kinds/index.js.map +6 -0
- package/dist/cjs/fabric/Fabric.d.ts +1 -2
- package/dist/cjs/fabric/Fabric.d.ts.map +1 -1
- package/dist/cjs/fabric/Fabric.js +28 -31
- package/dist/cjs/fabric/Fabric.js.map +1 -1
- package/dist/cjs/fabric/TestFabric.d.ts +1 -1
- package/dist/cjs/fabric/TestFabric.js +1 -1
- package/dist/cjs/peer/ControllerCommissioningFlow.d.ts.map +1 -1
- package/dist/cjs/peer/ControllerCommissioningFlow.js +2 -1
- package/dist/cjs/peer/ControllerCommissioningFlow.js.map +1 -1
- package/dist/cjs/session/case/CaseClient.d.ts.map +1 -1
- package/dist/cjs/session/case/CaseClient.js +3 -3
- package/dist/cjs/session/case/CaseClient.js.map +1 -1
- package/dist/cjs/session/case/CaseServer.d.ts.map +1 -1
- package/dist/cjs/session/case/CaseServer.js +2 -2
- package/dist/cjs/session/case/CaseServer.js.map +1 -1
- package/dist/esm/action/client/index.d.ts +1 -1
- package/dist/esm/action/client/index.js +1 -1
- package/dist/esm/action/errors.d.ts +12 -0
- package/dist/esm/action/errors.d.ts.map +1 -1
- package/dist/esm/action/errors.js +13 -1
- package/dist/esm/action/errors.js.map +1 -1
- package/dist/esm/action/protocols.d.ts +1 -1
- package/dist/esm/action/protocols.js +1 -1
- package/dist/esm/action/server/AttributeReadResponse.d.ts +1 -1
- package/dist/esm/action/server/AttributeReadResponse.js +1 -1
- package/dist/esm/action/server/AttributeSubscriptionResponse.d.ts +1 -1
- package/dist/esm/action/server/AttributeSubscriptionResponse.js +1 -1
- package/dist/esm/action/server/AttributeWriteResponse.d.ts +1 -1
- package/dist/esm/action/server/AttributeWriteResponse.js +1 -1
- package/dist/esm/action/server/CommandInvokeResponse.d.ts +1 -1
- package/dist/esm/action/server/CommandInvokeResponse.js +1 -1
- package/dist/esm/action/server/DataResponse.d.ts +1 -1
- package/dist/esm/action/server/DataResponse.js +1 -1
- package/dist/esm/action/server/EventReadResponse.d.ts +1 -1
- package/dist/esm/action/server/EventReadResponse.js +1 -1
- package/dist/esm/action/server/ServerInteraction.d.ts +1 -1
- package/dist/esm/action/server/ServerInteraction.js +1 -1
- package/dist/esm/action/server/index.d.ts +1 -1
- package/dist/esm/action/server/index.js +1 -1
- package/dist/esm/certificate/AttestationCertificateManager.d.ts.map +1 -1
- package/dist/esm/certificate/AttestationCertificateManager.js +20 -16
- package/dist/esm/certificate/AttestationCertificateManager.js.map +1 -1
- package/dist/esm/certificate/CertificateAuthority.d.ts +1 -2
- package/dist/esm/certificate/CertificateAuthority.d.ts.map +1 -1
- package/dist/esm/certificate/CertificateAuthority.js +18 -30
- package/dist/esm/certificate/CertificateAuthority.js.map +1 -1
- package/dist/esm/certificate/DeviceCertification.d.ts.map +1 -1
- package/dist/esm/certificate/DeviceCertification.js +2 -6
- package/dist/esm/certificate/DeviceCertification.js.map +1 -1
- package/dist/esm/certificate/index.d.ts +7 -2
- package/dist/esm/certificate/index.d.ts.map +1 -1
- package/dist/esm/certificate/index.js +10 -2
- package/dist/esm/certificate/index.js.map +1 -1
- package/dist/esm/certificate/kinds/AttestationCertificates.d.ts +34 -0
- package/dist/esm/certificate/kinds/AttestationCertificates.d.ts.map +1 -0
- package/dist/esm/certificate/kinds/AttestationCertificates.js +44 -0
- package/dist/esm/certificate/kinds/AttestationCertificates.js.map +6 -0
- package/dist/esm/certificate/kinds/CertificationDeclaration.d.ts +23 -0
- package/dist/esm/certificate/kinds/CertificationDeclaration.d.ts.map +1 -0
- package/dist/esm/certificate/kinds/CertificationDeclaration.js +66 -0
- package/dist/esm/certificate/kinds/CertificationDeclaration.js.map +6 -0
- package/dist/esm/certificate/kinds/Icac.d.ts +29 -0
- package/dist/esm/certificate/kinds/Icac.d.ts.map +1 -0
- package/dist/esm/certificate/kinds/Icac.js +118 -0
- package/dist/esm/certificate/kinds/Icac.js.map +6 -0
- package/dist/esm/certificate/kinds/Noc.d.ts +27 -0
- package/dist/esm/certificate/kinds/Noc.d.ts.map +1 -0
- package/dist/esm/certificate/kinds/Noc.js +128 -0
- package/dist/esm/certificate/kinds/Noc.js.map +6 -0
- package/dist/esm/certificate/kinds/OperationalBase.d.ts +24 -0
- package/dist/esm/certificate/kinds/OperationalBase.d.ts.map +1 -0
- package/dist/esm/certificate/kinds/OperationalBase.js +48 -0
- package/dist/esm/certificate/kinds/OperationalBase.js.map +6 -0
- package/dist/esm/certificate/kinds/Rcac.d.ts +25 -0
- package/dist/esm/certificate/kinds/Rcac.d.ts.map +1 -0
- package/dist/esm/certificate/kinds/Rcac.js +99 -0
- package/dist/esm/certificate/kinds/Rcac.js.map +6 -0
- package/dist/esm/certificate/kinds/X509Base.d.ts +92 -0
- package/dist/esm/certificate/kinds/X509Base.d.ts.map +1 -0
- package/dist/esm/certificate/kinds/X509Base.js +347 -0
- package/dist/esm/certificate/kinds/X509Base.js.map +6 -0
- package/dist/esm/certificate/kinds/common.d.ts +18 -0
- package/dist/esm/certificate/kinds/common.d.ts.map +1 -0
- package/dist/esm/certificate/kinds/common.js +22 -0
- package/dist/esm/certificate/kinds/common.js.map +6 -0
- package/dist/esm/certificate/kinds/definitions/asn.d.ts +25 -0
- package/dist/esm/certificate/kinds/definitions/asn.d.ts.map +1 -0
- package/dist/esm/certificate/kinds/definitions/asn.js +63 -0
- package/dist/esm/certificate/kinds/definitions/asn.js.map +6 -0
- package/dist/esm/certificate/kinds/definitions/attestation.d.ts +44 -0
- package/dist/esm/certificate/kinds/definitions/attestation.d.ts.map +1 -0
- package/dist/esm/certificate/kinds/definitions/attestation.js +6 -0
- package/dist/esm/certificate/kinds/definitions/attestation.js.map +6 -0
- package/dist/esm/certificate/kinds/definitions/base.d.ts +52 -0
- package/dist/esm/certificate/kinds/definitions/base.d.ts.map +1 -0
- package/dist/esm/certificate/kinds/definitions/base.js +23 -0
- package/dist/esm/certificate/kinds/definitions/base.js.map +6 -0
- package/dist/esm/certificate/kinds/definitions/certification-declaration.d.ts +18 -0
- package/dist/esm/certificate/kinds/definitions/certification-declaration.d.ts.map +1 -0
- package/dist/esm/certificate/kinds/definitions/certification-declaration.js +41 -0
- package/dist/esm/certificate/kinds/definitions/certification-declaration.js.map +6 -0
- package/dist/esm/certificate/kinds/definitions/operational.d.ts +368 -0
- package/dist/esm/certificate/kinds/definitions/operational.d.ts.map +1 -0
- package/dist/esm/certificate/kinds/definitions/operational.js +148 -0
- package/dist/esm/certificate/kinds/definitions/operational.js.map +6 -0
- package/dist/esm/certificate/kinds/index.d.ts +12 -0
- package/dist/esm/certificate/kinds/index.d.ts.map +1 -0
- package/dist/esm/certificate/kinds/index.js +12 -0
- package/dist/esm/certificate/kinds/index.js.map +6 -0
- package/dist/esm/fabric/Fabric.d.ts +1 -2
- package/dist/esm/fabric/Fabric.d.ts.map +1 -1
- package/dist/esm/fabric/Fabric.js +28 -36
- package/dist/esm/fabric/Fabric.js.map +1 -1
- package/dist/esm/fabric/TestFabric.d.ts +1 -1
- package/dist/esm/fabric/TestFabric.js +1 -1
- package/dist/esm/peer/ControllerCommissioningFlow.d.ts.map +1 -1
- package/dist/esm/peer/ControllerCommissioningFlow.js +2 -1
- package/dist/esm/peer/ControllerCommissioningFlow.js.map +1 -1
- package/dist/esm/session/case/CaseClient.d.ts.map +1 -1
- package/dist/esm/session/case/CaseClient.js +3 -3
- package/dist/esm/session/case/CaseClient.js.map +1 -1
- package/dist/esm/session/case/CaseServer.d.ts.map +1 -1
- package/dist/esm/session/case/CaseServer.js +2 -2
- package/dist/esm/session/case/CaseServer.js.map +1 -1
- package/package.json +6 -6
- package/src/action/client/index.ts +1 -1
- package/src/action/errors.ts +19 -1
- package/src/action/protocols.ts +1 -1
- package/src/action/server/AttributeReadResponse.ts +1 -1
- package/src/action/server/AttributeSubscriptionResponse.ts +1 -1
- package/src/action/server/AttributeWriteResponse.ts +1 -1
- package/src/action/server/CommandInvokeResponse.ts +1 -1
- package/src/action/server/DataResponse.ts +1 -1
- package/src/action/server/EventReadResponse.ts +1 -1
- package/src/action/server/ServerInteraction.ts +1 -1
- package/src/action/server/index.ts +1 -1
- package/src/certificate/AttestationCertificateManager.ts +20 -16
- package/src/certificate/CertificateAuthority.ts +18 -35
- package/src/certificate/DeviceCertification.ts +2 -6
- package/src/certificate/index.ts +7 -2
- package/src/certificate/kinds/AttestationCertificates.ts +48 -0
- package/src/certificate/kinds/CertificationDeclaration.ts +91 -0
- package/src/certificate/kinds/Icac.ts +156 -0
- package/src/certificate/kinds/Noc.ts +164 -0
- package/src/certificate/kinds/OperationalBase.ts +72 -0
- package/src/certificate/kinds/Rcac.ts +126 -0
- package/src/certificate/kinds/X509Base.ts +380 -0
- package/src/certificate/kinds/common.ts +24 -0
- package/src/certificate/kinds/definitions/asn.ts +97 -0
- package/src/certificate/kinds/definitions/attestation.ts +46 -0
- package/src/certificate/kinds/definitions/base.ts +43 -0
- package/src/certificate/kinds/definitions/certification-declaration.ts +38 -0
- package/src/certificate/kinds/definitions/operational.ts +179 -0
- package/src/certificate/kinds/index.ts +12 -0
- package/src/fabric/Fabric.ts +28 -40
- package/src/fabric/TestFabric.ts +1 -1
- package/src/peer/ControllerCommissioningFlow.ts +2 -1
- package/src/session/case/CaseClient.ts +3 -3
- package/src/session/case/CaseServer.ts +2 -2
- package/dist/cjs/certificate/CertificateManager.d.ts +0 -578
- package/dist/cjs/certificate/CertificateManager.d.ts.map +0 -1
- package/dist/cjs/certificate/CertificateManager.js +0 -843
- package/dist/cjs/certificate/CertificateManager.js.map +0 -6
- package/dist/cjs/certificate/CertificationDeclarationManager.d.ts +0 -11
- package/dist/cjs/certificate/CertificationDeclarationManager.d.ts.map +0 -1
- package/dist/cjs/certificate/CertificationDeclarationManager.js +0 -54
- package/dist/cjs/certificate/CertificationDeclarationManager.js.map +0 -6
- package/dist/esm/certificate/CertificateManager.d.ts +0 -578
- package/dist/esm/certificate/CertificateManager.d.ts.map +0 -1
- package/dist/esm/certificate/CertificateManager.js +0 -870
- package/dist/esm/certificate/CertificateManager.js.map +0 -6
- package/dist/esm/certificate/CertificationDeclarationManager.d.ts +0 -11
- package/dist/esm/certificate/CertificationDeclarationManager.d.ts.map +0 -1
- package/dist/esm/certificate/CertificationDeclarationManager.js +0 -34
- package/dist/esm/certificate/CertificationDeclarationManager.js.map +0 -6
- package/src/certificate/CertificateManager.ts +0 -1176
- package/src/certificate/CertificationDeclarationManager.ts +0 -52
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var Noc_exports = {};
|
|
20
|
+
__export(Noc_exports, {
|
|
21
|
+
Noc: () => Noc
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(Noc_exports);
|
|
24
|
+
var import_general = require("#general");
|
|
25
|
+
var import_types = require("#types");
|
|
26
|
+
var import_common = require("./common.js");
|
|
27
|
+
var import_operational = require("./definitions/operational.js");
|
|
28
|
+
var import_OperationalBase = require("./OperationalBase.js");
|
|
29
|
+
/**
|
|
30
|
+
* @license
|
|
31
|
+
* Copyright 2022-2025 Matter.js Authors
|
|
32
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
33
|
+
*/
|
|
34
|
+
class Noc extends import_OperationalBase.OperationalBase {
|
|
35
|
+
/** Construct the class from a Tlv version of the certificate */
|
|
36
|
+
static fromTlv(tlv) {
|
|
37
|
+
return new Noc(import_operational.OperationalCertificate.TlvNoc.decode(tlv));
|
|
38
|
+
}
|
|
39
|
+
/** Validates all basic certificate fields on construction. */
|
|
40
|
+
validateFields() {
|
|
41
|
+
const {
|
|
42
|
+
issuer: { icacId, rcacId },
|
|
43
|
+
extensions: {
|
|
44
|
+
basicConstraints: { isCa }
|
|
45
|
+
}
|
|
46
|
+
} = this.cert;
|
|
47
|
+
if (icacId === void 0 && rcacId === void 0) {
|
|
48
|
+
throw new import_common.CertificateError("Issuer RCAC or ICAC ID must be defined for an operational certificate.");
|
|
49
|
+
}
|
|
50
|
+
if (isCa) {
|
|
51
|
+
throw new import_common.CertificateError("Node operational certificate must not be a CA.");
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Encodes the certificate with the signature as Matter Tlv.
|
|
56
|
+
* If the certificate is not signed, it throws a CertificateError.
|
|
57
|
+
*/
|
|
58
|
+
asSignedTlv() {
|
|
59
|
+
return import_operational.OperationalCertificate.TlvNoc.encode({ ...this.cert, signature: this.signature });
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Verify requirements a Matter Node Operational certificate must fulfill.
|
|
63
|
+
* Rules for this are listed in @see {@link MatterSpecification.v12.Core} §6.5.x
|
|
64
|
+
*/
|
|
65
|
+
async verify(crypto, root, ica) {
|
|
66
|
+
this.generalVerify();
|
|
67
|
+
const {
|
|
68
|
+
subject,
|
|
69
|
+
extensions: { extendedKeyUsage, subjectKeyIdentifier, authorityKeyIdentifier }
|
|
70
|
+
} = this.cert;
|
|
71
|
+
const { nodeId, fabricId, caseAuthenticatedTags } = subject;
|
|
72
|
+
const {
|
|
73
|
+
subject: { fabricId: rootFabricId }
|
|
74
|
+
} = root.cert;
|
|
75
|
+
const {
|
|
76
|
+
subject: { fabricId: icaFabricId }
|
|
77
|
+
} = ica?.cert ?? { subject: {} };
|
|
78
|
+
if (nodeId === void 0 || Array.isArray(nodeId)) {
|
|
79
|
+
throw new import_common.CertificateError(`Invalid nodeId in NoC certificate: ${import_general.Diagnostic.json(nodeId)}`);
|
|
80
|
+
}
|
|
81
|
+
if (!import_types.NodeId.isOperationalNodeId(nodeId)) {
|
|
82
|
+
throw new import_common.CertificateError(`Invalid nodeId in NoC certificate: ${import_general.Diagnostic.json(nodeId)}`);
|
|
83
|
+
}
|
|
84
|
+
if (fabricId === void 0 || Array.isArray(fabricId)) {
|
|
85
|
+
throw new import_common.CertificateError(`Invalid fabricId in NoC certificate: ${import_general.Diagnostic.json(fabricId)}`);
|
|
86
|
+
}
|
|
87
|
+
if (fabricId === (0, import_types.FabricId)(0)) {
|
|
88
|
+
throw new import_common.CertificateError(`Invalid fabricId in NoC certificate: ${import_general.Diagnostic.json(fabricId)}`);
|
|
89
|
+
}
|
|
90
|
+
if ("icacId" in subject) {
|
|
91
|
+
throw new import_common.CertificateError(`Noc certificate must not contain an icacId.`);
|
|
92
|
+
}
|
|
93
|
+
if ("rcacId" in subject) {
|
|
94
|
+
throw new import_common.CertificateError(`Noc certificate must not contain an rcacId.`);
|
|
95
|
+
}
|
|
96
|
+
if (caseAuthenticatedTags !== void 0) {
|
|
97
|
+
import_types.CaseAuthenticatedTag.validateNocTagList(caseAuthenticatedTags);
|
|
98
|
+
}
|
|
99
|
+
if (rootFabricId !== void 0 && rootFabricId !== fabricId) {
|
|
100
|
+
throw new import_common.CertificateError(
|
|
101
|
+
`FabricId in NoC certificate does not match the fabricId in the parent certificate. ${import_general.Diagnostic.json(
|
|
102
|
+
rootFabricId
|
|
103
|
+
)} !== ${import_general.Diagnostic.json(fabricId)}`
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
if (icaFabricId !== void 0 && icaFabricId !== fabricId) {
|
|
107
|
+
throw new import_common.CertificateError(
|
|
108
|
+
`FabricId in NoC certificate does not match the fabricId in the parent certificate. ${import_general.Diagnostic.json(
|
|
109
|
+
icaFabricId
|
|
110
|
+
)} !== ${import_general.Diagnostic.json(fabricId)}`
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
if (this.cert.extensions.basicConstraints.isCa) {
|
|
114
|
+
throw new import_common.CertificateError(`Noc certificate must not have isCa set to true.`);
|
|
115
|
+
}
|
|
116
|
+
if (!this.cert.extensions.keyUsage.digitalSignature) {
|
|
117
|
+
throw new import_common.CertificateError(`Noc certificate must have keyUsage set to digitalSignature.`);
|
|
118
|
+
}
|
|
119
|
+
if (extendedKeyUsage === void 0 || !extendedKeyUsage.includes(1) && !extendedKeyUsage.includes(2)) {
|
|
120
|
+
throw new import_common.CertificateError(
|
|
121
|
+
`Noc certificate must have extendedKeyUsage with serverAuth and clientAuth: ${import_general.Diagnostic.json(extendedKeyUsage)}`
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
if (subjectKeyIdentifier === void 0) {
|
|
125
|
+
throw new import_common.CertificateError(`Noc certificate must have subjectKeyIdentifier set.`);
|
|
126
|
+
}
|
|
127
|
+
if (subjectKeyIdentifier.length !== 20) {
|
|
128
|
+
throw new import_common.CertificateError(`Noc certificate subjectKeyIdentifier must be 160 bit.`);
|
|
129
|
+
}
|
|
130
|
+
if (authorityKeyIdentifier === void 0) {
|
|
131
|
+
throw new import_common.CertificateError(`Noc certificate must have authorityKeyIdentifier set.`);
|
|
132
|
+
}
|
|
133
|
+
if (authorityKeyIdentifier.length !== 20) {
|
|
134
|
+
throw new import_common.CertificateError(`Noc certificate authorityKeyIdentifier must be 160 bit.`);
|
|
135
|
+
}
|
|
136
|
+
if (!import_general.Bytes.areEqual(authorityKeyIdentifier, (ica?.cert ?? root.cert).extensions.subjectKeyIdentifier)) {
|
|
137
|
+
throw new import_common.CertificateError(
|
|
138
|
+
`Noc certificate authorityKeyIdentifier must be equal to Root/Ica subjectKeyIdentifier.`
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
await crypto.verifyEcdsa(
|
|
142
|
+
(0, import_general.PublicKey)((ica?.cert ?? root.cert).ellipticCurvePublicKey),
|
|
143
|
+
this.asUnsignedAsn1(),
|
|
144
|
+
this.signature
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
//# 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,qBAAqD;AACrD,mBAAuD;AACvD,oBAAiC;AACjC,yBAAuC;AAEvC,6BAAgC;AAXhC;AAAA;AAAA;AAAA;AAAA;AAcO,MAAM,YAAY,uCAA4C;AAAA;AAAA,EAEjE,OAAO,QAAQ,KAAiB;AAC5B,WAAO,IAAI,IAAI,0CAAuB,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,+BAAiB,wEAAwE;AAAA,IACvG;AACA,QAAI,MAAM;AACN,YAAM,IAAI,+BAAiB,gDAAgD;AAAA,IAC/E;AAAA,EACJ;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,cAAc;AACV,WAAO,0CAAuB,OAAO,OAAO,EAAE,GAAG,KAAK,MAAM,WAAW,KAAK,UAAU,CAAC;AAAA,EAC3F;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,OAAO,QAAgB,MAAY,KAAY;AACjD,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025 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,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var OperationalBase_exports = {};
|
|
20
|
+
__export(OperationalBase_exports, {
|
|
21
|
+
OperationalBase: () => OperationalBase
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(OperationalBase_exports);
|
|
24
|
+
var import_general = require("#general");
|
|
25
|
+
var import_X509Base = require("./X509Base.js");
|
|
26
|
+
var import_common = require("./common.js");
|
|
27
|
+
/**
|
|
28
|
+
* @license
|
|
29
|
+
* Copyright 2022-2025 Matter.js Authors
|
|
30
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
31
|
+
*/
|
|
32
|
+
const logger = import_general.Logger.get("OperationalBaseCertificate");
|
|
33
|
+
class OperationalBase extends import_X509Base.X509Base {
|
|
34
|
+
constructor(cert) {
|
|
35
|
+
super(cert);
|
|
36
|
+
this.validateFields();
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Verifies general requirements a Matter certificate fields must fulfill.
|
|
40
|
+
* Rules for this are listed in @see {@link MatterSpecification.v12.Core} §6.5.x
|
|
41
|
+
*/
|
|
42
|
+
generalVerify() {
|
|
43
|
+
const cert = this.cert;
|
|
44
|
+
if (cert.serialNumber.length > 20)
|
|
45
|
+
throw new import_common.CertificateError(
|
|
46
|
+
`Serial number must not be longer then 20 octets. Current serial number has ${cert.serialNumber.length} octets.`
|
|
47
|
+
);
|
|
48
|
+
if (cert.signatureAlgorithm !== 1) {
|
|
49
|
+
throw new import_common.CertificateError(`Unsupported signature algorithm: ${cert.signatureAlgorithm}`);
|
|
50
|
+
}
|
|
51
|
+
if (cert.publicKeyAlgorithm !== 1) {
|
|
52
|
+
throw new import_common.CertificateError(`Unsupported public key algorithm: ${cert.publicKeyAlgorithm}`);
|
|
53
|
+
}
|
|
54
|
+
if (cert.ellipticCurveIdentifier !== 1) {
|
|
55
|
+
throw new import_common.CertificateError(`Unsupported elliptic curve identifier: ${cert.ellipticCurveIdentifier}`);
|
|
56
|
+
}
|
|
57
|
+
if (Object.keys(cert.subject).length > 5) {
|
|
58
|
+
throw new import_common.CertificateError(`Certificate subject must not contain more than 5 RDNs.`);
|
|
59
|
+
}
|
|
60
|
+
if (Object.keys(cert.issuer).length > 5) {
|
|
61
|
+
throw new import_common.CertificateError(`Certificate issuer must not contain more than 5 RDNs.`);
|
|
62
|
+
}
|
|
63
|
+
if (cert.notBefore * 1e3 > import_general.Time.nowMs()) {
|
|
64
|
+
logger.warn(`Certificate notBefore date is in the future: ${cert.notBefore * 1e3} vs ${import_general.Time.nowMs()}`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=OperationalBase.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
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|
+
/**
|
|
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,119 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var Rcac_exports = {};
|
|
20
|
+
__export(Rcac_exports, {
|
|
21
|
+
Rcac: () => Rcac
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(Rcac_exports);
|
|
24
|
+
var import_general = require("#general");
|
|
25
|
+
var import_types = require("#types");
|
|
26
|
+
var import_common = require("./common.js");
|
|
27
|
+
var import_base = require("./definitions/base.js");
|
|
28
|
+
var import_operational = require("./definitions/operational.js");
|
|
29
|
+
var import_OperationalBase = require("./OperationalBase.js");
|
|
30
|
+
/**
|
|
31
|
+
* @license
|
|
32
|
+
* Copyright 2022-2025 Matter.js Authors
|
|
33
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
34
|
+
*/
|
|
35
|
+
class Rcac extends import_OperationalBase.OperationalBase {
|
|
36
|
+
/** Construct the class from a Tlv version of the certificate */
|
|
37
|
+
static fromTlv(tlv) {
|
|
38
|
+
return new Rcac(import_operational.OperationalCertificate.TlvRcac.decode(tlv));
|
|
39
|
+
}
|
|
40
|
+
/** Validates all basic certificate fields on construction. */
|
|
41
|
+
validateFields() {
|
|
42
|
+
const {
|
|
43
|
+
extensions: {
|
|
44
|
+
basicConstraints: { isCa }
|
|
45
|
+
}
|
|
46
|
+
} = this.cert;
|
|
47
|
+
if (!isCa) {
|
|
48
|
+
throw new import_common.CertificateError("Root certificate must be a CA.");
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Encodes the certificate with the signature as Matter Tlv.
|
|
53
|
+
* If the certificate is not signed, it throws a CertificateError.
|
|
54
|
+
*/
|
|
55
|
+
asSignedTlv() {
|
|
56
|
+
return import_operational.OperationalCertificate.TlvRcac.encode({ ...this.cert, signature: this.signature });
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Verify requirements a Matter Root certificate must fulfill.
|
|
60
|
+
* Rules for this are listed in @see {@link MatterSpecification.v12.Core} §6.5.x
|
|
61
|
+
*/
|
|
62
|
+
async verify(crypto) {
|
|
63
|
+
this.generalVerify();
|
|
64
|
+
const { subject, extensions } = this.cert;
|
|
65
|
+
const { fabricId, rcacId } = subject;
|
|
66
|
+
const { basicConstraints, subjectKeyIdentifier, authorityKeyIdentifier } = extensions;
|
|
67
|
+
if ("nodeId" in subject) {
|
|
68
|
+
throw new import_common.CertificateError(`Root certificate must not contain a nodeId.`);
|
|
69
|
+
}
|
|
70
|
+
if (fabricId !== void 0) {
|
|
71
|
+
if (Array.isArray(fabricId)) {
|
|
72
|
+
throw new import_common.CertificateError(`Invalid fabricId in NoC certificate: ${import_general.Diagnostic.json(fabricId)}`);
|
|
73
|
+
}
|
|
74
|
+
if (fabricId === (0, import_types.FabricId)(0)) {
|
|
75
|
+
throw new import_common.CertificateError(`Invalid fabricId in NoC certificate: ${import_general.Diagnostic.json(fabricId)}`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if ("icacId" in subject) {
|
|
79
|
+
throw new import_common.CertificateError(`Root certificate must not contain an icacId.`);
|
|
80
|
+
}
|
|
81
|
+
if (rcacId === void 0 || Array.isArray(rcacId)) {
|
|
82
|
+
throw new import_common.CertificateError(`Invalid rcacId in Root certificate: ${import_general.Diagnostic.json(rcacId)}`);
|
|
83
|
+
}
|
|
84
|
+
if ("caseAuthenticatedTags" in subject) {
|
|
85
|
+
throw new import_common.CertificateError(`Root certificate must not contain a caseAuthenticatedTags.`);
|
|
86
|
+
}
|
|
87
|
+
if (basicConstraints.isCa !== true) {
|
|
88
|
+
throw new import_common.CertificateError(`Root certificate must have isCa set to true.`);
|
|
89
|
+
}
|
|
90
|
+
const keyUsage = import_base.ExtensionKeyUsageSchema.encode(extensions.keyUsage);
|
|
91
|
+
if (keyUsage !== 96 && keyUsage !== 97) {
|
|
92
|
+
throw new import_common.CertificateError(
|
|
93
|
+
`Root certificate keyUsage must have keyCertSign and CRLSign and optionally digitalSignature set.`
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
if (extensions.extendedKeyUsage !== void 0) {
|
|
97
|
+
throw new import_common.CertificateError(`Root certificate must not have extendedKeyUsage set.`);
|
|
98
|
+
}
|
|
99
|
+
if (subjectKeyIdentifier === void 0) {
|
|
100
|
+
throw new import_common.CertificateError(`Root certificate must have subjectKeyIdentifier set.`);
|
|
101
|
+
}
|
|
102
|
+
if (subjectKeyIdentifier.length !== 20) {
|
|
103
|
+
throw new import_common.CertificateError(`Root certificate subjectKeyIdentifier must be 160 bit.`);
|
|
104
|
+
}
|
|
105
|
+
if (authorityKeyIdentifier === void 0) {
|
|
106
|
+
throw new import_common.CertificateError(`Root certificate must have authorityKeyIdentifier set.`);
|
|
107
|
+
}
|
|
108
|
+
if (authorityKeyIdentifier.length !== 20) {
|
|
109
|
+
throw new import_common.CertificateError(`Root certificate authorityKeyIdentifier must be 160 bit.`);
|
|
110
|
+
}
|
|
111
|
+
if (!import_general.Bytes.areEqual(authorityKeyIdentifier, subjectKeyIdentifier)) {
|
|
112
|
+
throw new import_common.CertificateError(
|
|
113
|
+
`Root certificate authorityKeyIdentifier must be equal to subjectKeyIdentifier.`
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
await crypto.verifyEcdsa((0, import_general.PublicKey)(this.cert.ellipticCurvePublicKey), this.asUnsignedAsn1(), this.signature);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=Rcac.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/certificate/kinds/Rcac.ts"],
|
|
4
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,qBAAqD;AACrD,mBAAyB;AACzB,oBAAiC;AACjC,kBAAwC;AACxC,yBAAuC;AACvC,6BAAgC;AAXhC;AAAA;AAAA;AAAA;AAAA;AAaO,MAAM,aAAa,uCAA6C;AAAA;AAAA,EAEnE,OAAO,QAAQ,KAAuB;AAClC,WAAO,IAAI,KAAK,0CAAuB,QAAQ,OAAO,GAAG,CAAC;AAAA,EAC9D;AAAA;AAAA,EAGU,iBAAiB;AACvB,UAAM;AAAA,MACF,YAAY;AAAA,QACR,kBAAkB,EAAE,KAAK;AAAA,MAC7B;AAAA,IACJ,IAAI,KAAK;AACT,QAAI,CAAC,MAAM;AACP,YAAM,IAAI,+BAAiB,gCAAgC;AAAA,IAC/D;AAAA,EACJ;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,cAAc;AACV,WAAO,0CAAuB,QAAQ,OAAO,EAAE,GAAG,KAAK,MAAM,WAAW,KAAK,UAAU,CAAC;AAAA,EAC5F;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,MAAM,OAAO,QAAgB;AACzB,SAAK,cAAc;AAEnB,UA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IAAI,+BAAiB,wDAAwD;AAAA,IACvF;AACA,QAAI,uBAAuB,WAAW,IAAI;AACtC,YAAM,IAAI,+BAAiB,0DAA0D;AAAA,IACzF;AAGA,QAAI,CAAC,qBAAM,SAAS,wBAAwB,oBAAoB,GAAG;AAC/D,YAAM,IAAI;AAAA,QACN;AAAA,MACJ;AAAA,IACJ;AAEA,UAAM,OAAO,gBAAY,0BAAU,KAAK,KAAK,sBAAsB,GAAG,KAAK,eAAe,GAAG,KAAK,SAAS;AAAA,EAC/G;AACJ;",
|
|
5
|
+
"names": []
|
|
6
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022-2025 Matter.js Authors
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { Crypto, DerType, Key } from "#general";
|
|
7
|
+
import { 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"}
|