@zwave-js/cc 15.26.0 → 15.27.0
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/build/cjs/cc/NotificationCC.js +7 -3
- package/build/cjs/cc/NotificationCC.js.map +2 -2
- package/build/cjs/cc/Security2CC.js +1 -1
- package/build/cjs/cc/Security2CC.js.map +2 -2
- package/build/cjs/cc/SecurityCC.js +1 -1
- package/build/cjs/cc/SecurityCC.js.map +2 -2
- package/build/cjs/cc/UserCodeCC.js +1 -2
- package/build/cjs/cc/UserCodeCC.js.map +2 -2
- package/build/cjs/lib/Security2/Extension.js +1 -1
- package/build/cjs/lib/Security2/Extension.js.map +2 -2
- package/build/esm/cc/NotificationCC.d.ts.map +1 -1
- package/build/esm/cc/NotificationCC.js +16 -5
- package/build/esm/cc/NotificationCC.js.map +1 -1
- package/build/esm/cc/Security2CC.d.ts.map +1 -1
- package/build/esm/cc/Security2CC.js +3 -3
- package/build/esm/cc/Security2CC.js.map +1 -1
- package/build/esm/cc/SecurityCC.d.ts.map +1 -1
- package/build/esm/cc/SecurityCC.js +3 -3
- package/build/esm/cc/SecurityCC.js.map +1 -1
- package/build/esm/cc/UserCodeCC.d.ts.map +1 -1
- package/build/esm/cc/UserCodeCC.js +3 -2
- package/build/esm/cc/UserCodeCC.js.map +1 -1
- package/build/esm/lib/Security2/Extension.d.ts.map +1 -1
- package/build/esm/lib/Security2/Extension.js +3 -3
- package/build/esm/lib/Security2/Extension.js.map +1 -1
- package/package.json +7 -7
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src_gen/cc/SecurityCC.ts"],
|
|
4
|
-
"sourcesContent": ["import { CommandClasses, EncapsulationFlags, type GetNode, type GetValueDB, type MaybeNotKnown, type MessageOrCCLogEntry, MessagePriority, type MessageRecord, type NodeId, SecurityClass, type SecurityManager, type SupportsCC, TransmitOptions, type WithAddress, ZWaveError, ZWaveErrorCodes, computeMAC, decryptAES128OFB, encodeCCList, encryptAES128OFB, generateAuthKey, generateEncryptionKey, getCCName, isTransmissionError, logDict, logList, logText, parseCCList, randomBytes, validatePayload, } from \"@zwave-js/core\";\nimport { Bytes, type BytesView, buffer2hex, num2hex, pick, } from \"@zwave-js/shared\";\nimport { wait } from \"alcalzone-shared/async\";\nimport { CCAPI, PhysicalCCAPI } from \"../lib/API.js\";\nimport { type CCRaw, CommandClass, type InterviewContext, } from \"../lib/CommandClass.js\";\nimport { API, CCCommand, commandClass, expectedCCResponse, implementedVersion, } from \"../lib/CommandClassDecorators.js\";\nimport { SecurityCommand } from \"../lib/_Types.js\";\nimport type { CCEncodingContext, CCParsingContext } from \"../lib/traits.js\";\nimport { CRC16CC } from \"./CRC16CC.js\";\nimport { Security2CC } from \"./Security2CC.js\";\nimport { TransportServiceCC } from \"./TransportServiceCC.js\";\n// @noSetValueAPI This is an encapsulation CC\nfunction getAuthenticationData(senderNonce: BytesView, receiverNonce: BytesView, ccCommand: SecurityCommand, sendingNodeId: number, receivingNodeId: number, encryptedPayload: BytesView): BytesView {\n return Bytes.concat([\n senderNonce,\n receiverNonce,\n [\n ccCommand,\n sendingNodeId,\n receivingNodeId,\n encryptedPayload.length,\n ],\n encryptedPayload,\n ]);\n}\nfunction throwNoNonce(reason?: string): never {\n let message = `Security CC requires a nonce to be sent!`;\n if (reason)\n message += ` Reason: ${reason}`;\n throw new ZWaveError(message, ZWaveErrorCodes.SecurityCC_NoNonce);\n}\nconst HALF_NONCE_SIZE = 8;\nfunction assertSecurityRX(ctx: CCParsingContext): asserts ctx is CCParsingContext & {\n securityManager: SecurityManager;\n} {\n if (!ctx.ownNodeId) {\n throw new ZWaveError(`Secure commands (S0) can only be decoded when the controller's node id is known!`, ZWaveErrorCodes.Driver_NotReady);\n }\n if (!ctx.securityManager) {\n throw new ZWaveError(`Secure commands (S0) can only be decoded when the security manager is set up!`, ZWaveErrorCodes.Driver_NoSecurity);\n }\n}\nfunction assertSecurityTX(ctx: CCEncodingContext): asserts ctx is CCEncodingContext & {\n securityManager: SecurityManager;\n} {\n if (!ctx.ownNodeId) {\n throw new ZWaveError(`Secure commands (S0) can only be sent when the controller's node id is known!`, ZWaveErrorCodes.Driver_NotReady);\n }\n if (!ctx.securityManager) {\n throw new ZWaveError(`Secure commands (S0) can only be sent when the security manager is set up!`, ZWaveErrorCodes.Driver_NoSecurity);\n }\n}\n// TODO: Ignore commands if received via multicast\n// Encapsulation CCs are used internally and too frequently that we\n// want to pay the cost of validating each call\n/* eslint-disable @zwave-js/ccapi-validate-args */\n@API(CommandClasses.Security)\nexport class SecurityCCAPI extends PhysicalCCAPI {\n public supportsCommand(_cmd: SecurityCommand): MaybeNotKnown<boolean> {\n // All commands are mandatory\n return true;\n }\n public async sendEncapsulated(encapsulated: CommandClass, requestNextNonce: boolean = false): Promise<void> {\n if (requestNextNonce) {\n this.assertSupportsCommand(SecurityCommand, SecurityCommand.CommandEncapsulation);\n }\n else {\n this.assertSupportsCommand(SecurityCommand, SecurityCommand.CommandEncapsulationNonceGet);\n }\n const cc = new (requestNextNonce\n ? SecurityCCCommandEncapsulationNonceGet\n : SecurityCCCommandEncapsulation)({\n nodeId: this.endpoint.nodeId,\n encapsulated,\n });\n await this.host.sendCommand(cc, this.commandOptions);\n }\n /**\n * Requests a new nonce for Security CC encapsulation which is not directly linked to a specific command.\n */\n public async getNonce(): Promise<BytesView | undefined> {\n this.assertSupportsCommand(SecurityCommand, SecurityCommand.NonceGet);\n const cc = new SecurityCCNonceGet({\n nodeId: this.endpoint.nodeId,\n endpointIndex: this.endpoint.index,\n });\n const response = await this.host.sendCommand<SecurityCCNonceReport>(cc, {\n ...this.commandOptions,\n // Only try getting a nonce once\n maxSendAttempts: 1,\n });\n if (!response)\n return;\n const nonce = response.nonce;\n const secMan = this.host.securityManager!;\n secMan.setNonce({\n issuer: this.endpoint.nodeId,\n nonceId: secMan.getNonceId(nonce),\n }, { nonce, receiver: this.host.ownNodeId }, { free: true });\n return nonce;\n }\n /**\n * Responds to a NonceGet request. The message is sent without any retransmission etc.\n * The return value indicates whether a nonce was successfully sent\n */\n public async sendNonce(): Promise<boolean> {\n this.assertSupportsCommand(SecurityCommand, SecurityCommand.NonceReport);\n if (!this.host.securityManager) {\n throw new ZWaveError(`Nonces can only be sent if secure communication is set up!`, ZWaveErrorCodes.Driver_NoSecurity);\n }\n const nonce = this.host.securityManager.generateNonce(this.endpoint.nodeId, HALF_NONCE_SIZE);\n const nonceId = this.host.securityManager.getNonceId(nonce);\n const cc = new SecurityCCNonceReport({\n nodeId: this.endpoint.nodeId,\n endpointIndex: this.endpoint.index,\n nonce,\n });\n try {\n await this.host.sendCommand(cc, {\n ...this.commandOptions,\n // Seems we need these options or some nodes won't accept the nonce\n transmitOptions: TransmitOptions.ACK\n | TransmitOptions.AutoRoute,\n // Only try sending a nonce once\n maxSendAttempts: 1,\n // Nonce requests must be handled immediately\n priority: MessagePriority.Immediate,\n // We don't want failures causing us to treat the node as asleep or dead\n changeNodeStatusOnMissingACK: false,\n });\n }\n catch (e) {\n if (isTransmissionError(e)) {\n // The nonce could not be sent, invalidate it\n this.host.securityManager.deleteNonce(nonceId);\n return false;\n }\n else {\n // Pass other errors through\n throw e;\n }\n }\n return true;\n }\n public async getSecurityScheme(): Promise<[\n 0\n ]> {\n this.assertSupportsCommand(SecurityCommand, SecurityCommand.SchemeGet);\n const cc = new SecurityCCSchemeGet({\n nodeId: this.endpoint.nodeId,\n endpointIndex: this.endpoint.index,\n });\n await this.host.sendCommand(cc, this.commandOptions);\n // There is only one scheme, so we hardcode it\n return [0];\n }\n public async reportSecurityScheme(encapsulated: boolean): Promise<void> {\n this.assertSupportsCommand(SecurityCommand, SecurityCommand.SchemeReport);\n let cc: CommandClass = new SecurityCCSchemeReport({\n nodeId: this.endpoint.nodeId,\n endpointIndex: this.endpoint.index,\n });\n if (encapsulated) {\n cc = new SecurityCCCommandEncapsulation({\n nodeId: this.endpoint.nodeId,\n endpointIndex: this.endpoint.index,\n encapsulated: cc,\n });\n }\n await this.host.sendCommand(cc, this.commandOptions);\n }\n public async inheritSecurityScheme(): Promise<void> {\n this.assertSupportsCommand(SecurityCommand, SecurityCommand.SchemeInherit);\n const cc = new SecurityCCSchemeInherit({\n nodeId: this.endpoint.nodeId,\n endpointIndex: this.endpoint.index,\n });\n await this.host.sendCommand(cc, this.commandOptions);\n // There is only one scheme, so we don't return anything here\n }\n public async setNetworkKey(networkKey: BytesView): Promise<void> {\n this.assertSupportsCommand(SecurityCommand, SecurityCommand.NetworkKeySet);\n const keySet = new SecurityCCNetworkKeySet({\n nodeId: this.endpoint.nodeId,\n endpointIndex: this.endpoint.index,\n networkKey,\n });\n const cc = new SecurityCCCommandEncapsulation({\n nodeId: this.endpoint.nodeId,\n endpointIndex: this.endpoint.index,\n encapsulated: keySet,\n alternativeNetworkKey: new Uint8Array(16).fill(0),\n });\n await this.host.sendCommand(cc, this.commandOptions);\n }\n public async verifyNetworkKey(): Promise<void> {\n this.assertSupportsCommand(SecurityCommand, SecurityCommand.NetworkKeyVerify);\n const cc = new SecurityCCNetworkKeyVerify({\n nodeId: this.endpoint.nodeId,\n endpointIndex: this.endpoint.index,\n });\n await this.host.sendCommand(cc, this.commandOptions);\n }\n // oxlint-disable-next-line typescript/explicit-module-boundary-types\n public async getSupportedCommands() {\n this.assertSupportsCommand(SecurityCommand, SecurityCommand.CommandsSupportedGet);\n const cc = new SecurityCCCommandsSupportedGet({\n nodeId: this.endpoint.nodeId,\n endpointIndex: this.endpoint.index,\n });\n const response = await this.host.sendCommand<SecurityCCCommandsSupportedReport>(cc, this.commandOptions);\n if (response) {\n return pick(response, [\"supportedCCs\", \"controlledCCs\"]);\n }\n }\n public async reportSupportedCommands(supportedCCs: CommandClasses[], controlledCCs: CommandClasses[]): Promise<void> {\n this.assertSupportsCommand(SecurityCommand, SecurityCommand.CommandsSupportedReport);\n const cc = new SecurityCCCommandsSupportedReport({\n nodeId: this.endpoint.nodeId,\n endpointIndex: this.endpoint.index,\n supportedCCs,\n controlledCCs,\n reportsToFollow: 0,\n });\n await this.host.sendCommand(cc, this.commandOptions);\n }\n}\n@commandClass(CommandClasses.Security)\n@implementedVersion(1)\nexport class SecurityCC extends CommandClass {\n declare ccCommand: SecurityCommand;\n // Force singlecast for the Security CC\n declare nodeId: number;\n public async interview(ctx: InterviewContext): Promise<void> {\n const node = this.getNode(ctx)!;\n const endpoint = this.getEndpoint(ctx)!;\n const api = CCAPI.create(CommandClasses.Security, ctx, endpoint).withOptions({\n priority: MessagePriority.NodeQuery,\n tag: \"interview\",\n });\n ctx.logNode(node.id, {\n message: \"Querying securely supported commands (S0)...\",\n direction: \"outbound\",\n });\n let supportedCCs: CommandClasses[] | undefined;\n let controlledCCs: CommandClasses[] | undefined;\n // Try up to 3 times on the root device. We REALLY don't want a spurious timeout or collision to cause us to discard a known good security class\n const MAX_ATTEMPTS = this.endpointIndex === 0 ? 3 : 1;\n for (let attempts = 1; attempts <= MAX_ATTEMPTS; attempts++) {\n const resp = await api.getSupportedCommands();\n if (resp) {\n supportedCCs = resp.supportedCCs;\n controlledCCs = resp.controlledCCs;\n break;\n }\n else if (attempts < MAX_ATTEMPTS) {\n ctx.logNode(node.id, {\n endpoint: this.endpointIndex,\n message: `Querying securely supported commands (S0), attempt ${attempts}/${MAX_ATTEMPTS} failed. Retrying in 500ms...`,\n level: \"warn\",\n });\n await wait(500);\n }\n }\n if (!supportedCCs || !controlledCCs) {\n if (node.hasSecurityClass(SecurityClass.S0_Legacy) === true) {\n ctx.logNode(node.id, {\n endpoint: this.endpointIndex,\n message: \"Querying securely supported commands (S0) failed\",\n level: \"warn\",\n });\n // TODO: Abort interview?\n }\n else {\n // We didn't know if the node was secure and it didn't respond,\n // assume that it doesn't have the S0 security class\n ctx.logNode(node.id, `The node was not granted the S0 security class. Continuing interview non-securely.`);\n node.setSecurityClass(SecurityClass.S0_Legacy, false);\n }\n return;\n }\n ctx.logNode(node.id, {\n message: logText(\"received secure commands (S0)\", {\n nested: logDict({\n \"supported CCs\": logList(supportedCCs.map((cc) => getCCName(cc))),\n \"controlled CCs\": logList(controlledCCs.map((cc) => getCCName(cc))),\n }),\n }),\n direction: \"inbound\",\n });\n // Remember which commands are supported securely\n for (const cc of supportedCCs) {\n // Basic CC has special rules for when it is considered supported\n // Therefore we mark all other CCs as supported, but not Basic CC,\n // for which support is determined later.\n if (cc === CommandClasses.Basic) {\n endpoint.addCC(cc, { secure: true });\n }\n else {\n endpoint.addCC(cc, {\n isSupported: true,\n secure: true,\n });\n }\n }\n for (const cc of controlledCCs) {\n // Basic CC has special rules for when it is considered supported\n // Therefore we mark all other CCs as supported, but not Basic CC,\n // for which support is determined later.\n if (cc === CommandClasses.Basic) {\n endpoint.addCC(cc, { secure: true });\n }\n else {\n endpoint.addCC(cc, {\n isControlled: true,\n secure: true,\n });\n }\n }\n // We know for sure that the node is included securely\n if (node.hasSecurityClass(SecurityClass.S0_Legacy) !== true) {\n node.setSecurityClass(SecurityClass.S0_Legacy, true);\n ctx.logNode(node.id, `The node was granted the S0 security class`);\n }\n // Remember that the interview is complete\n this.setInterviewComplete(ctx, true);\n }\n /** Tests if a command should be sent secure and thus requires encapsulation */\n public static requiresEncapsulation(cc: CommandClass): boolean {\n // No security flag -> no encapsulation\n if (!(cc.encapsulationFlags & EncapsulationFlags.Security)) {\n return false;\n }\n // S2, CRC16, Transport Service -> no S2 encapsulation\n if (cc instanceof Security2CC\n || cc instanceof CRC16CC\n || cc instanceof TransportServiceCC) {\n return false;\n }\n // S0: check command\n if (cc instanceof SecurityCC) {\n switch (cc.ccCommand) {\n // Already encapsulated\n case SecurityCommand.CommandEncapsulation:\n case SecurityCommand.CommandEncapsulationNonceGet:\n // Cannot be sent encapsulated:\n case SecurityCommand.NonceGet:\n case SecurityCommand.NonceReport:\n case SecurityCommand.SchemeGet:\n case SecurityCommand.SchemeReport:\n return false;\n default:\n // All other commands must be encapsulated\n return true;\n }\n }\n // Everything else needs to be encapsulated if the CC is secure\n return true;\n }\n /** Encapsulates a command that should be sent encrypted */\n public static encapsulate(ownNodeId: number, securityManager: SecurityManager, cc: CommandClass): SecurityCCCommandEncapsulation {\n // TODO: When to return a SecurityCCCommandEncapsulationNonceGet?\n const ret = new SecurityCCCommandEncapsulation({\n nodeId: cc.nodeId,\n encapsulated: cc,\n });\n // Copy the encapsulation flags from the encapsulated command\n // but omit Security, since we're doing that right now\n ret.encapsulationFlags = cc.encapsulationFlags\n & ~EncapsulationFlags.Security;\n return ret;\n }\n}\ninterface SecurityCCNonceReportOptions {\n nonce: BytesView;\n}\n@CCCommand(SecurityCommand.NonceReport)\nexport class SecurityCCNonceReport extends SecurityCC {\n constructor(options: WithAddress<SecurityCCNonceReportOptions>) {\n super(options);\n if (options.nonce.length !== HALF_NONCE_SIZE) {\n throw new ZWaveError(`Nonce must have length ${HALF_NONCE_SIZE}!`, ZWaveErrorCodes.Argument_Invalid);\n }\n this.nonce = options.nonce;\n }\n public static from(raw: CCRaw, ctx: CCParsingContext): SecurityCCNonceReport {\n validatePayload.withReason(\"Invalid nonce length\")(raw.payload.length === HALF_NONCE_SIZE);\n return new this({\n nodeId: ctx.sourceNodeId,\n nonce: raw.payload,\n });\n }\n public nonce: BytesView;\n public serialize(ctx: CCEncodingContext): Promise<Bytes> {\n this.payload = Bytes.view(this.nonce);\n return super.serialize(ctx);\n }\n public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n return {\n ...super.toLogEntry(ctx),\n message: { nonce: buffer2hex(this.nonce) },\n };\n }\n}\n@CCCommand(SecurityCommand.NonceGet)\n@expectedCCResponse(SecurityCCNonceReport)\nexport class SecurityCCNonceGet extends SecurityCC {\n}\n// @publicAPI\nexport type SecurityCCCommandEncapsulationOptions = {\n alternativeNetworkKey?: BytesView;\n} & ({\n encapsulated: CommandClass;\n} | {\n decryptedCCBytes: BytesView;\n sequenced: boolean;\n secondFrame: boolean;\n sequenceCounter: number;\n});\nfunction getCCResponseForCommandEncapsulation(ctx: GetNode<NodeId & SupportsCC>, sent: SecurityCCCommandEncapsulation) {\n if (sent.encapsulated.expectsCCResponse(ctx)) {\n return SecurityCCCommandEncapsulation;\n }\n}\n@CCCommand(SecurityCommand.CommandEncapsulation)\n@expectedCCResponse(getCCResponseForCommandEncapsulation, () => \"checkEncapsulated\")\nexport class SecurityCCCommandEncapsulation extends SecurityCC {\n public constructor(options: WithAddress<SecurityCCCommandEncapsulationOptions>) {\n super(options);\n if (\"encapsulated\" in options) {\n this.encapsulated = options.encapsulated;\n this.encapsulated.encapsulatingCC = this as any;\n }\n else {\n this.decryptedCCBytes = options.decryptedCCBytes;\n this.sequenced = options.sequenced;\n this.secondFrame = options.secondFrame;\n this.sequenceCounter = options.sequenceCounter;\n }\n this.alternativeNetworkKey = options.alternativeNetworkKey;\n }\n public static async from(raw: CCRaw, ctx: CCParsingContext): Promise<SecurityCCCommandEncapsulation> {\n assertSecurityRX(ctx);\n // HALF_NONCE_SIZE bytes iv, 1 byte frame control, at least 1 CC byte, 1 byte nonce id, 8 bytes auth code\n validatePayload(raw.payload.length >= HALF_NONCE_SIZE + 1 + 1 + 1 + 8);\n const iv = raw.payload.subarray(0, HALF_NONCE_SIZE);\n const encryptedPayload = raw.payload.subarray(HALF_NONCE_SIZE, -9);\n const nonceId = raw.payload.at(-9)!;\n const authCode = raw.payload.subarray(-8);\n // Retrieve the used nonce from the nonce store\n const nonce = ctx.securityManager.getNonce(nonceId);\n // Only accept the message if the nonce hasn't expired\n if (!nonce) {\n validatePayload.fail(`Nonce ${num2hex(nonceId)} expired, cannot decode security encapsulated command.`);\n }\n // and mark the nonce as used\n ctx.securityManager.deleteNonce(nonceId);\n // Validate the encrypted data\n const authData = getAuthenticationData(iv, nonce, SecurityCommand.CommandEncapsulation, ctx.sourceNodeId, ctx.ownNodeId, encryptedPayload);\n const expectedAuthCode = await computeMAC(authData, await ctx.securityManager.getAuthKey());\n // Only accept messages with a correct auth code\n validatePayload.withReason(\"Invalid auth code, won't accept security encapsulated command.\")(authCode.equals(expectedAuthCode));\n // Decrypt the encapsulated CC\n const frameControlAndDecryptedCC = await decryptAES128OFB(encryptedPayload, await ctx.securityManager.getEncryptionKey(), Bytes.concat([iv, nonce]));\n const frameControl = frameControlAndDecryptedCC[0];\n const sequenceCounter = frameControl & 0b1111;\n const sequenced = !!(frameControl & 16);\n const secondFrame = !!(frameControl & 32);\n const decryptedCCBytes = frameControlAndDecryptedCC.subarray(1);\n const ret = new SecurityCCCommandEncapsulation({\n nodeId: ctx.sourceNodeId,\n sequenceCounter,\n sequenced,\n secondFrame,\n decryptedCCBytes,\n });\n ret.authData = authData;\n ret.authCode = authCode;\n ret.iv = iv;\n return ret;\n }\n private sequenced: boolean | undefined;\n private secondFrame: boolean | undefined;\n private sequenceCounter: number | undefined;\n private decryptedCCBytes: BytesView | undefined;\n public encapsulated!: CommandClass;\n private alternativeNetworkKey?: BytesView;\n public get nonceId(): number | undefined {\n return this.nonce?.[0];\n }\n public nonce: BytesView | undefined;\n // Only used testing/for debugging purposes\n private iv?: BytesView;\n private authData?: BytesView;\n private authCode?: BytesView;\n private ciphertext?: BytesView;\n public getPartialCCSessionId(): Record<string, any> | undefined {\n if (this.sequenced) {\n return {\n // Treat Encapsulation and EncapsulationNonceGet as one\n ccCommand: undefined,\n sequence: this.sequenceCounter,\n };\n }\n else {\n return {\n // Treat Encapsulation and EncapsulationNonceGet as one\n ccCommand: undefined,\n };\n }\n }\n public getRemainingSegments(): number | undefined {\n // Sequenced S0 commands are always split into exactly two frames\n if (!this.sequenced)\n return 0;\n return this.secondFrame ? 0 : 1;\n }\n public async mergePartialCCs(partials: SecurityCCCommandEncapsulation[], ctx: CCParsingContext): Promise<void> {\n // Concat the CC buffers\n this.decryptedCCBytes = Bytes.concat([...partials, this].map((cc) => cc.decryptedCCBytes!));\n // make sure this contains a complete CC command that's worth splitting\n validatePayload(this.decryptedCCBytes.length >= 2);\n // and deserialize the CC\n this.encapsulated = await CommandClass.parse(this.decryptedCCBytes, ctx);\n this.encapsulated.encapsulatingCC = this as any;\n }\n public async serialize(ctx: CCEncodingContext): Promise<Bytes> {\n if (!this.nonce)\n throwNoNonce();\n if (this.nonce.length !== HALF_NONCE_SIZE) {\n throwNoNonce(\"Invalid nonce size\");\n }\n assertSecurityTX(ctx);\n let authKey: BytesView;\n let encryptionKey: BytesView;\n if (this.alternativeNetworkKey) {\n authKey = await generateAuthKey(this.alternativeNetworkKey);\n encryptionKey = await generateEncryptionKey(this.alternativeNetworkKey);\n }\n else {\n authKey = await ctx.securityManager.getAuthKey();\n encryptionKey = await ctx.securityManager.getEncryptionKey();\n }\n const serializedCC = await this.encapsulated.serialize(ctx);\n const plaintext = Bytes.concat([\n [0], // TODO: frame control\n serializedCC,\n ]);\n // Encrypt the payload\n const senderNonce = randomBytes(HALF_NONCE_SIZE);\n const iv = Bytes.concat([senderNonce, this.nonce]);\n const ciphertext = await encryptAES128OFB(plaintext, encryptionKey, iv);\n // And generate the auth code\n const authData = getAuthenticationData(senderNonce, this.nonce, this.ccCommand, ctx.ownNodeId, this.nodeId, ciphertext);\n const authCode = await computeMAC(authData, authKey);\n // Remember for debugging purposes\n this.iv = iv;\n this.authData = authData;\n this.authCode = authCode;\n this.ciphertext = ciphertext;\n this.payload = Bytes.concat([\n senderNonce,\n ciphertext,\n [this.nonceId!],\n authCode,\n ]);\n return super.serialize(ctx);\n }\n protected computeEncapsulationOverhead(): number {\n // Security CC adds 8 bytes IV, 1 byte frame control, 1 byte nonce ID, 8 bytes MAC\n return super.computeEncapsulationOverhead() + 18;\n }\n public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n const message: MessageRecord = {};\n if (this.nonceId != undefined) {\n message[\"nonce id\"] = this.nonceId;\n }\n if (this.sequenced != undefined) {\n message.sequenced = this.sequenced;\n if (this.sequenced) {\n if (this.secondFrame != undefined) {\n message[\"second frame\"] = this.secondFrame;\n }\n if (this.sequenceCounter != undefined) {\n message[\"sequence counter\"] = this.sequenceCounter;\n }\n }\n }\n // Log the plaintext in integration tests and development mode\n if (process.env.NODE_ENV === \"test\"\n || process.env.NODE_ENV === \"development\") {\n if (this.iv) {\n message.IV = buffer2hex(this.iv);\n }\n if (this.ciphertext) {\n message.ciphertext = buffer2hex(this.ciphertext);\n }\n else if (this.decryptedCCBytes) {\n message.plaintext = buffer2hex(this.decryptedCCBytes);\n }\n if (this.authData) {\n message[\"auth data\"] = buffer2hex(this.authData);\n }\n if (this.authCode) {\n message[\"auth code\"] = buffer2hex(this.authCode);\n }\n }\n return {\n ...super.toLogEntry(ctx),\n message,\n };\n }\n}\n// This is the same message, but with another CC command\n@CCCommand(SecurityCommand.CommandEncapsulationNonceGet)\nexport class SecurityCCCommandEncapsulationNonceGet extends SecurityCCCommandEncapsulation {\n}\n@CCCommand(SecurityCommand.SchemeReport)\nexport class SecurityCCSchemeReport extends SecurityCC {\n public static from(raw: CCRaw, ctx: CCParsingContext): SecurityCCSchemeReport {\n validatePayload(raw.payload.length >= 1);\n // The including controller MUST NOT perform any validation of the Supported Security Schemes byte\n return new this({\n nodeId: ctx.sourceNodeId,\n });\n }\n public serialize(ctx: CCEncodingContext): Promise<Bytes> {\n // Since it is unlikely that any more schemes will be added to S0, we hardcode the default scheme here (bit 0 = 0)\n this.payload = Bytes.from([0]);\n return super.serialize(ctx);\n }\n public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n return {\n ...super.toLogEntry(ctx),\n // Hide the default payload line\n message: undefined,\n };\n }\n}\n@CCCommand(SecurityCommand.SchemeGet)\n@expectedCCResponse(SecurityCCSchemeReport)\nexport class SecurityCCSchemeGet extends SecurityCC {\n public static from(raw: CCRaw, ctx: CCParsingContext): SecurityCCSchemeGet {\n validatePayload(raw.payload.length >= 1);\n // The joining node MUST NOT perform any validation of the Supported Security Schemes byte\n return new this({\n nodeId: ctx.sourceNodeId,\n });\n }\n public serialize(ctx: CCEncodingContext): Promise<Bytes> {\n // Since it is unlikely that any more schemes will be added to S0, we hardcode the default scheme here (bit 0 = 0)\n this.payload = Bytes.from([0]);\n return super.serialize(ctx);\n }\n public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n return {\n ...super.toLogEntry(ctx),\n // Hide the default payload line\n message: undefined,\n };\n }\n}\n@CCCommand(SecurityCommand.SchemeInherit)\n@expectedCCResponse(SecurityCCSchemeReport)\nexport class SecurityCCSchemeInherit extends SecurityCC {\n public static from(raw: CCRaw, ctx: CCParsingContext): SecurityCCSchemeInherit {\n validatePayload(raw.payload.length >= 1);\n // The joining node MUST NOT perform any validation of the Supported Security Schemes byte\n return new this({\n nodeId: ctx.sourceNodeId,\n });\n }\n public serialize(ctx: CCEncodingContext): Promise<Bytes> {\n // Since it is unlikely that any more schemes will be added to S0, we hardcode the default scheme here (bit 0 = 0)\n this.payload = Bytes.from([0]);\n return super.serialize(ctx);\n }\n public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n return {\n ...super.toLogEntry(ctx),\n // Hide the default payload line\n message: undefined,\n };\n }\n}\n@CCCommand(SecurityCommand.NetworkKeyVerify)\nexport class SecurityCCNetworkKeyVerify extends SecurityCC {\n}\n// @publicAPI\nexport interface SecurityCCNetworkKeySetOptions {\n networkKey: BytesView;\n}\n@CCCommand(SecurityCommand.NetworkKeySet)\n@expectedCCResponse(SecurityCCNetworkKeyVerify)\nexport class SecurityCCNetworkKeySet extends SecurityCC {\n public constructor(options: WithAddress<SecurityCCNetworkKeySetOptions>) {\n super(options);\n if (options.networkKey.length !== 16) {\n throw new ZWaveError(`The network key must have length 16!`, ZWaveErrorCodes.Argument_Invalid);\n }\n this.networkKey = options.networkKey;\n }\n public static from(raw: CCRaw, ctx: CCParsingContext): SecurityCCNetworkKeySet {\n validatePayload(raw.payload.length >= 16);\n const networkKey: BytesView = raw.payload.subarray(0, 16);\n return new this({\n nodeId: ctx.sourceNodeId,\n networkKey,\n });\n }\n public networkKey: BytesView;\n public serialize(ctx: CCEncodingContext): Promise<Bytes> {\n this.payload = Bytes.view(this.networkKey);\n return super.serialize(ctx);\n }\n public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n // The network key shouldn't be logged, so users can safely post their logs online\n const { message, ...log } = super.toLogEntry(ctx);\n return log;\n }\n}\n// @publicAPI\nexport interface SecurityCCCommandsSupportedReportOptions {\n reportsToFollow?: number;\n supportedCCs: CommandClasses[];\n controlledCCs: CommandClasses[];\n}\n@CCCommand(SecurityCommand.CommandsSupportedReport)\nexport class SecurityCCCommandsSupportedReport extends SecurityCC {\n public constructor(options: WithAddress<SecurityCCCommandsSupportedReportOptions>) {\n super(options);\n this.supportedCCs = options.supportedCCs;\n this.controlledCCs = options.controlledCCs;\n // TODO: properly split the CCs into multiple reports\n this.reportsToFollow = options.reportsToFollow ?? 0;\n }\n public static from(raw: CCRaw, ctx: CCParsingContext): SecurityCCCommandsSupportedReport {\n validatePayload(raw.payload.length >= 1);\n const reportsToFollow = raw.payload[0];\n const list = parseCCList(raw.payload.subarray(1));\n const supportedCCs: CommandClasses[] = list.supportedCCs;\n const controlledCCs: CommandClasses[] = list.controlledCCs;\n return new this({\n nodeId: ctx.sourceNodeId,\n reportsToFollow,\n supportedCCs,\n controlledCCs,\n });\n }\n public reportsToFollow: number;\n public supportedCCs: CommandClasses[];\n public controlledCCs: CommandClasses[];\n public getPartialCCSessionId(): Record<string, any> | undefined {\n // Nothing special we can distinguish sessions with\n return {};\n }\n public getRemainingSegments(): number | undefined {\n return this.reportsToFollow;\n }\n public mergePartialCCs(partials: SecurityCCCommandsSupportedReport[]): Promise<void> {\n // Concat the lists of CCs\n this.supportedCCs = [...partials, this]\n .map((report) => report.supportedCCs)\n .reduce((prev, cur) => prev.concat(...cur), []);\n this.controlledCCs = [...partials, this]\n .map((report) => report.controlledCCs)\n .reduce((prev, cur) => prev.concat(...cur), []);\n return Promise.resolve();\n }\n public serialize(ctx: CCEncodingContext): Promise<Bytes> {\n this.payload = Bytes.concat([\n [this.reportsToFollow],\n encodeCCList(this.supportedCCs, this.controlledCCs),\n ]);\n return super.serialize(ctx);\n }\n public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n return {\n ...super.toLogEntry(ctx),\n message: {\n reportsToFollow: this.reportsToFollow,\n supportedCCs: logList(this.supportedCCs.map((cc) => getCCName(cc))),\n controlledCCs: logList(this.controlledCCs.map((cc) => getCCName(cc))),\n },\n };\n }\n}\n@CCCommand(SecurityCommand.CommandsSupportedGet)\n@expectedCCResponse(SecurityCCCommandsSupportedReport)\nexport class SecurityCCCommandsSupportedGet extends SecurityCC {\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kBAAqf;AACrf,oBAAkE;AAClE,mBAAqB;AACrB,iBAAqC;AACrC,0BAAiE;AACjE,oCAAsF;AACtF,mBAAgC;AAEhC,qBAAwB;AACxB,yBAA4B;AAC5B,gCAAmC;AAEnC,SAAS,sBAAsB,aAAwB,eAA0B,WAA4B,eAAuB,iBAAyB,kBAA2B;AACpL,SAAO,oBAAM,OAAO;IAChB;IACA;IACA;MACI;MACA;MACA;MACA,iBAAiB;;IAErB;GACH;AACL;AAZS;AAaT,SAAS,aAAa,QAAe;AACjC,MAAI,UAAU;AACd,MAAI;AACA,eAAW,YAAY,MAAM;AACjC,QAAM,IAAI,uBAAW,SAAS,4BAAgB,kBAAkB;AACpE;AALS;AAMT,MAAM,kBAAkB;AACxB,SAAS,iBAAiB,KAAqB;AAG3C,MAAI,CAAC,IAAI,WAAW;AAChB,UAAM,IAAI,uBAAW,oFAAoF,4BAAgB,eAAe;EAC5I;AACA,MAAI,CAAC,IAAI,iBAAiB;AACtB,UAAM,IAAI,uBAAW,iFAAiF,4BAAgB,iBAAiB;EAC3I;AACJ;AATS;AAUT,SAAS,iBAAiB,KAAsB;AAG5C,MAAI,CAAC,IAAI,WAAW;AAChB,UAAM,IAAI,uBAAW,iFAAiF,4BAAgB,eAAe;EACzI;AACA,MAAI,CAAC,IAAI,iBAAiB;AACtB,UAAM,IAAI,uBAAW,8EA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,iBAAiB,KAAK;UACtB,kBAAc,qBAAQ,KAAK,aAAa,IAAI,CAAC,WAAO,uBAAU,EAAE,CAAC,CAAC;UAClE,mBAAe,qBAAQ,KAAK,cAAc,IAAI,CAAC,WAAO,uBAAU,EAAE,CAAC,CAAC;;;IAGhF;;;;IAIS,kCAA8B,MAAA;8BAF1C,yCAAU,6BAAgB,oBAAoB,OAC9C,kDAAmB,iCAAiC,CAAC;;;;oBACF;sDAAA,YAAU;WAAA;;;;;;;;AAA9D,qCAAA,MAAA,mBAAA,EAAA,OAAA,WAAA,GAAA,kBAAA,EAAA,MAAA,SAAA,MAAA,WAAA,MAAA,UAAA,UAAA,GAAA,MAAA,uBAAA;;;AAAa,0CAAA,YAAA,uBAAA;;;;;",
|
|
4
|
+
"sourcesContent": ["import { CommandClasses, EncapsulationFlags, type GetNode, type GetValueDB, type MaybeNotKnown, type MessageOrCCLogEntry, MessagePriority, type MessageRecord, type NodeId, SecurityClass, type SecurityManager, type SupportsCC, TransmitOptions, type WithAddress, ZWaveError, ZWaveErrorCodes, computeMAC, decryptAES128OFB, encodeCCList, encryptAES128OFB, generateAuthKey, generateEncryptionKey, getCCName, isTransmissionError, logDict, logList, logText, parseCCList, randomBytes, validatePayload, } from \"@zwave-js/core\";\nimport { Bytes, type BytesView, buffer2hex, getenv, num2hex, pick, } from \"@zwave-js/shared\";\nimport { wait } from \"alcalzone-shared/async\";\nimport { CCAPI, PhysicalCCAPI } from \"../lib/API.js\";\nimport { type CCRaw, CommandClass, type InterviewContext, } from \"../lib/CommandClass.js\";\nimport { API, CCCommand, commandClass, expectedCCResponse, implementedVersion, } from \"../lib/CommandClassDecorators.js\";\nimport { SecurityCommand } from \"../lib/_Types.js\";\nimport type { CCEncodingContext, CCParsingContext } from \"../lib/traits.js\";\nimport { CRC16CC } from \"./CRC16CC.js\";\nimport { Security2CC } from \"./Security2CC.js\";\nimport { TransportServiceCC } from \"./TransportServiceCC.js\";\n// @noSetValueAPI This is an encapsulation CC\nfunction getAuthenticationData(senderNonce: BytesView, receiverNonce: BytesView, ccCommand: SecurityCommand, sendingNodeId: number, receivingNodeId: number, encryptedPayload: BytesView): BytesView {\n return Bytes.concat([\n senderNonce,\n receiverNonce,\n [\n ccCommand,\n sendingNodeId,\n receivingNodeId,\n encryptedPayload.length,\n ],\n encryptedPayload,\n ]);\n}\nfunction throwNoNonce(reason?: string): never {\n let message = `Security CC requires a nonce to be sent!`;\n if (reason)\n message += ` Reason: ${reason}`;\n throw new ZWaveError(message, ZWaveErrorCodes.SecurityCC_NoNonce);\n}\nconst HALF_NONCE_SIZE = 8;\nfunction assertSecurityRX(ctx: CCParsingContext): asserts ctx is CCParsingContext & {\n securityManager: SecurityManager;\n} {\n if (!ctx.ownNodeId) {\n throw new ZWaveError(`Secure commands (S0) can only be decoded when the controller's node id is known!`, ZWaveErrorCodes.Driver_NotReady);\n }\n if (!ctx.securityManager) {\n throw new ZWaveError(`Secure commands (S0) can only be decoded when the security manager is set up!`, ZWaveErrorCodes.Driver_NoSecurity);\n }\n}\nfunction assertSecurityTX(ctx: CCEncodingContext): asserts ctx is CCEncodingContext & {\n securityManager: SecurityManager;\n} {\n if (!ctx.ownNodeId) {\n throw new ZWaveError(`Secure commands (S0) can only be sent when the controller's node id is known!`, ZWaveErrorCodes.Driver_NotReady);\n }\n if (!ctx.securityManager) {\n throw new ZWaveError(`Secure commands (S0) can only be sent when the security manager is set up!`, ZWaveErrorCodes.Driver_NoSecurity);\n }\n}\n// TODO: Ignore commands if received via multicast\n// Encapsulation CCs are used internally and too frequently that we\n// want to pay the cost of validating each call\n/* eslint-disable @zwave-js/ccapi-validate-args */\n@API(CommandClasses.Security)\nexport class SecurityCCAPI extends PhysicalCCAPI {\n public supportsCommand(_cmd: SecurityCommand): MaybeNotKnown<boolean> {\n // All commands are mandatory\n return true;\n }\n public async sendEncapsulated(encapsulated: CommandClass, requestNextNonce: boolean = false): Promise<void> {\n if (requestNextNonce) {\n this.assertSupportsCommand(SecurityCommand, SecurityCommand.CommandEncapsulation);\n }\n else {\n this.assertSupportsCommand(SecurityCommand, SecurityCommand.CommandEncapsulationNonceGet);\n }\n const cc = new (requestNextNonce\n ? SecurityCCCommandEncapsulationNonceGet\n : SecurityCCCommandEncapsulation)({\n nodeId: this.endpoint.nodeId,\n encapsulated,\n });\n await this.host.sendCommand(cc, this.commandOptions);\n }\n /**\n * Requests a new nonce for Security CC encapsulation which is not directly linked to a specific command.\n */\n public async getNonce(): Promise<BytesView | undefined> {\n this.assertSupportsCommand(SecurityCommand, SecurityCommand.NonceGet);\n const cc = new SecurityCCNonceGet({\n nodeId: this.endpoint.nodeId,\n endpointIndex: this.endpoint.index,\n });\n const response = await this.host.sendCommand<SecurityCCNonceReport>(cc, {\n ...this.commandOptions,\n // Only try getting a nonce once\n maxSendAttempts: 1,\n });\n if (!response)\n return;\n const nonce = response.nonce;\n const secMan = this.host.securityManager!;\n secMan.setNonce({\n issuer: this.endpoint.nodeId,\n nonceId: secMan.getNonceId(nonce),\n }, { nonce, receiver: this.host.ownNodeId }, { free: true });\n return nonce;\n }\n /**\n * Responds to a NonceGet request. The message is sent without any retransmission etc.\n * The return value indicates whether a nonce was successfully sent\n */\n public async sendNonce(): Promise<boolean> {\n this.assertSupportsCommand(SecurityCommand, SecurityCommand.NonceReport);\n if (!this.host.securityManager) {\n throw new ZWaveError(`Nonces can only be sent if secure communication is set up!`, ZWaveErrorCodes.Driver_NoSecurity);\n }\n const nonce = this.host.securityManager.generateNonce(this.endpoint.nodeId, HALF_NONCE_SIZE);\n const nonceId = this.host.securityManager.getNonceId(nonce);\n const cc = new SecurityCCNonceReport({\n nodeId: this.endpoint.nodeId,\n endpointIndex: this.endpoint.index,\n nonce,\n });\n try {\n await this.host.sendCommand(cc, {\n ...this.commandOptions,\n // Seems we need these options or some nodes won't accept the nonce\n transmitOptions: TransmitOptions.ACK\n | TransmitOptions.AutoRoute,\n // Only try sending a nonce once\n maxSendAttempts: 1,\n // Nonce requests must be handled immediately\n priority: MessagePriority.Immediate,\n // We don't want failures causing us to treat the node as asleep or dead\n changeNodeStatusOnMissingACK: false,\n });\n }\n catch (e) {\n if (isTransmissionError(e)) {\n // The nonce could not be sent, invalidate it\n this.host.securityManager.deleteNonce(nonceId);\n return false;\n }\n else {\n // Pass other errors through\n throw e;\n }\n }\n return true;\n }\n public async getSecurityScheme(): Promise<[\n 0\n ]> {\n this.assertSupportsCommand(SecurityCommand, SecurityCommand.SchemeGet);\n const cc = new SecurityCCSchemeGet({\n nodeId: this.endpoint.nodeId,\n endpointIndex: this.endpoint.index,\n });\n await this.host.sendCommand(cc, this.commandOptions);\n // There is only one scheme, so we hardcode it\n return [0];\n }\n public async reportSecurityScheme(encapsulated: boolean): Promise<void> {\n this.assertSupportsCommand(SecurityCommand, SecurityCommand.SchemeReport);\n let cc: CommandClass = new SecurityCCSchemeReport({\n nodeId: this.endpoint.nodeId,\n endpointIndex: this.endpoint.index,\n });\n if (encapsulated) {\n cc = new SecurityCCCommandEncapsulation({\n nodeId: this.endpoint.nodeId,\n endpointIndex: this.endpoint.index,\n encapsulated: cc,\n });\n }\n await this.host.sendCommand(cc, this.commandOptions);\n }\n public async inheritSecurityScheme(): Promise<void> {\n this.assertSupportsCommand(SecurityCommand, SecurityCommand.SchemeInherit);\n const cc = new SecurityCCSchemeInherit({\n nodeId: this.endpoint.nodeId,\n endpointIndex: this.endpoint.index,\n });\n await this.host.sendCommand(cc, this.commandOptions);\n // There is only one scheme, so we don't return anything here\n }\n public async setNetworkKey(networkKey: BytesView): Promise<void> {\n this.assertSupportsCommand(SecurityCommand, SecurityCommand.NetworkKeySet);\n const keySet = new SecurityCCNetworkKeySet({\n nodeId: this.endpoint.nodeId,\n endpointIndex: this.endpoint.index,\n networkKey,\n });\n const cc = new SecurityCCCommandEncapsulation({\n nodeId: this.endpoint.nodeId,\n endpointIndex: this.endpoint.index,\n encapsulated: keySet,\n alternativeNetworkKey: new Uint8Array(16).fill(0),\n });\n await this.host.sendCommand(cc, this.commandOptions);\n }\n public async verifyNetworkKey(): Promise<void> {\n this.assertSupportsCommand(SecurityCommand, SecurityCommand.NetworkKeyVerify);\n const cc = new SecurityCCNetworkKeyVerify({\n nodeId: this.endpoint.nodeId,\n endpointIndex: this.endpoint.index,\n });\n await this.host.sendCommand(cc, this.commandOptions);\n }\n // oxlint-disable-next-line typescript/explicit-module-boundary-types\n public async getSupportedCommands() {\n this.assertSupportsCommand(SecurityCommand, SecurityCommand.CommandsSupportedGet);\n const cc = new SecurityCCCommandsSupportedGet({\n nodeId: this.endpoint.nodeId,\n endpointIndex: this.endpoint.index,\n });\n const response = await this.host.sendCommand<SecurityCCCommandsSupportedReport>(cc, this.commandOptions);\n if (response) {\n return pick(response, [\"supportedCCs\", \"controlledCCs\"]);\n }\n }\n public async reportSupportedCommands(supportedCCs: CommandClasses[], controlledCCs: CommandClasses[]): Promise<void> {\n this.assertSupportsCommand(SecurityCommand, SecurityCommand.CommandsSupportedReport);\n const cc = new SecurityCCCommandsSupportedReport({\n nodeId: this.endpoint.nodeId,\n endpointIndex: this.endpoint.index,\n supportedCCs,\n controlledCCs,\n reportsToFollow: 0,\n });\n await this.host.sendCommand(cc, this.commandOptions);\n }\n}\n@commandClass(CommandClasses.Security)\n@implementedVersion(1)\nexport class SecurityCC extends CommandClass {\n declare ccCommand: SecurityCommand;\n // Force singlecast for the Security CC\n declare nodeId: number;\n public async interview(ctx: InterviewContext): Promise<void> {\n const node = this.getNode(ctx)!;\n const endpoint = this.getEndpoint(ctx)!;\n const api = CCAPI.create(CommandClasses.Security, ctx, endpoint).withOptions({\n priority: MessagePriority.NodeQuery,\n tag: \"interview\",\n });\n ctx.logNode(node.id, {\n message: \"Querying securely supported commands (S0)...\",\n direction: \"outbound\",\n });\n let supportedCCs: CommandClasses[] | undefined;\n let controlledCCs: CommandClasses[] | undefined;\n // Try up to 3 times on the root device. We REALLY don't want a spurious timeout or collision to cause us to discard a known good security class\n const MAX_ATTEMPTS = this.endpointIndex === 0 ? 3 : 1;\n for (let attempts = 1; attempts <= MAX_ATTEMPTS; attempts++) {\n const resp = await api.getSupportedCommands();\n if (resp) {\n supportedCCs = resp.supportedCCs;\n controlledCCs = resp.controlledCCs;\n break;\n }\n else if (attempts < MAX_ATTEMPTS) {\n ctx.logNode(node.id, {\n endpoint: this.endpointIndex,\n message: `Querying securely supported commands (S0), attempt ${attempts}/${MAX_ATTEMPTS} failed. Retrying in 500ms...`,\n level: \"warn\",\n });\n await wait(500);\n }\n }\n if (!supportedCCs || !controlledCCs) {\n if (node.hasSecurityClass(SecurityClass.S0_Legacy) === true) {\n ctx.logNode(node.id, {\n endpoint: this.endpointIndex,\n message: \"Querying securely supported commands (S0) failed\",\n level: \"warn\",\n });\n // TODO: Abort interview?\n }\n else {\n // We didn't know if the node was secure and it didn't respond,\n // assume that it doesn't have the S0 security class\n ctx.logNode(node.id, `The node was not granted the S0 security class. Continuing interview non-securely.`);\n node.setSecurityClass(SecurityClass.S0_Legacy, false);\n }\n return;\n }\n ctx.logNode(node.id, {\n message: logText(\"received secure commands (S0)\", {\n nested: logDict({\n \"supported CCs\": logList(supportedCCs.map((cc) => getCCName(cc))),\n \"controlled CCs\": logList(controlledCCs.map((cc) => getCCName(cc))),\n }),\n }),\n direction: \"inbound\",\n });\n // Remember which commands are supported securely\n for (const cc of supportedCCs) {\n // Basic CC has special rules for when it is considered supported\n // Therefore we mark all other CCs as supported, but not Basic CC,\n // for which support is determined later.\n if (cc === CommandClasses.Basic) {\n endpoint.addCC(cc, { secure: true });\n }\n else {\n endpoint.addCC(cc, {\n isSupported: true,\n secure: true,\n });\n }\n }\n for (const cc of controlledCCs) {\n // Basic CC has special rules for when it is considered supported\n // Therefore we mark all other CCs as supported, but not Basic CC,\n // for which support is determined later.\n if (cc === CommandClasses.Basic) {\n endpoint.addCC(cc, { secure: true });\n }\n else {\n endpoint.addCC(cc, {\n isControlled: true,\n secure: true,\n });\n }\n }\n // We know for sure that the node is included securely\n if (node.hasSecurityClass(SecurityClass.S0_Legacy) !== true) {\n node.setSecurityClass(SecurityClass.S0_Legacy, true);\n ctx.logNode(node.id, `The node was granted the S0 security class`);\n }\n // Remember that the interview is complete\n this.setInterviewComplete(ctx, true);\n }\n /** Tests if a command should be sent secure and thus requires encapsulation */\n public static requiresEncapsulation(cc: CommandClass): boolean {\n // No security flag -> no encapsulation\n if (!(cc.encapsulationFlags & EncapsulationFlags.Security)) {\n return false;\n }\n // S2, CRC16, Transport Service -> no S2 encapsulation\n if (cc instanceof Security2CC\n || cc instanceof CRC16CC\n || cc instanceof TransportServiceCC) {\n return false;\n }\n // S0: check command\n if (cc instanceof SecurityCC) {\n switch (cc.ccCommand) {\n // Already encapsulated\n case SecurityCommand.CommandEncapsulation:\n case SecurityCommand.CommandEncapsulationNonceGet:\n // Cannot be sent encapsulated:\n case SecurityCommand.NonceGet:\n case SecurityCommand.NonceReport:\n case SecurityCommand.SchemeGet:\n case SecurityCommand.SchemeReport:\n return false;\n default:\n // All other commands must be encapsulated\n return true;\n }\n }\n // Everything else needs to be encapsulated if the CC is secure\n return true;\n }\n /** Encapsulates a command that should be sent encrypted */\n public static encapsulate(ownNodeId: number, securityManager: SecurityManager, cc: CommandClass): SecurityCCCommandEncapsulation {\n // TODO: When to return a SecurityCCCommandEncapsulationNonceGet?\n const ret = new SecurityCCCommandEncapsulation({\n nodeId: cc.nodeId,\n encapsulated: cc,\n });\n // Copy the encapsulation flags from the encapsulated command\n // but omit Security, since we're doing that right now\n ret.encapsulationFlags = cc.encapsulationFlags\n & ~EncapsulationFlags.Security;\n return ret;\n }\n}\ninterface SecurityCCNonceReportOptions {\n nonce: BytesView;\n}\n@CCCommand(SecurityCommand.NonceReport)\nexport class SecurityCCNonceReport extends SecurityCC {\n constructor(options: WithAddress<SecurityCCNonceReportOptions>) {\n super(options);\n if (options.nonce.length !== HALF_NONCE_SIZE) {\n throw new ZWaveError(`Nonce must have length ${HALF_NONCE_SIZE}!`, ZWaveErrorCodes.Argument_Invalid);\n }\n this.nonce = options.nonce;\n }\n public static from(raw: CCRaw, ctx: CCParsingContext): SecurityCCNonceReport {\n validatePayload.withReason(\"Invalid nonce length\")(raw.payload.length === HALF_NONCE_SIZE);\n return new this({\n nodeId: ctx.sourceNodeId,\n nonce: raw.payload,\n });\n }\n public nonce: BytesView;\n public serialize(ctx: CCEncodingContext): Promise<Bytes> {\n this.payload = Bytes.view(this.nonce);\n return super.serialize(ctx);\n }\n public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n return {\n ...super.toLogEntry(ctx),\n message: { nonce: buffer2hex(this.nonce) },\n };\n }\n}\n@CCCommand(SecurityCommand.NonceGet)\n@expectedCCResponse(SecurityCCNonceReport)\nexport class SecurityCCNonceGet extends SecurityCC {\n}\n// @publicAPI\nexport type SecurityCCCommandEncapsulationOptions = {\n alternativeNetworkKey?: BytesView;\n} & ({\n encapsulated: CommandClass;\n} | {\n decryptedCCBytes: BytesView;\n sequenced: boolean;\n secondFrame: boolean;\n sequenceCounter: number;\n});\nfunction getCCResponseForCommandEncapsulation(ctx: GetNode<NodeId & SupportsCC>, sent: SecurityCCCommandEncapsulation) {\n if (sent.encapsulated.expectsCCResponse(ctx)) {\n return SecurityCCCommandEncapsulation;\n }\n}\n@CCCommand(SecurityCommand.CommandEncapsulation)\n@expectedCCResponse(getCCResponseForCommandEncapsulation, () => \"checkEncapsulated\")\nexport class SecurityCCCommandEncapsulation extends SecurityCC {\n public constructor(options: WithAddress<SecurityCCCommandEncapsulationOptions>) {\n super(options);\n if (\"encapsulated\" in options) {\n this.encapsulated = options.encapsulated;\n this.encapsulated.encapsulatingCC = this as any;\n }\n else {\n this.decryptedCCBytes = options.decryptedCCBytes;\n this.sequenced = options.sequenced;\n this.secondFrame = options.secondFrame;\n this.sequenceCounter = options.sequenceCounter;\n }\n this.alternativeNetworkKey = options.alternativeNetworkKey;\n }\n public static async from(raw: CCRaw, ctx: CCParsingContext): Promise<SecurityCCCommandEncapsulation> {\n assertSecurityRX(ctx);\n // HALF_NONCE_SIZE bytes iv, 1 byte frame control, at least 1 CC byte, 1 byte nonce id, 8 bytes auth code\n validatePayload(raw.payload.length >= HALF_NONCE_SIZE + 1 + 1 + 1 + 8);\n const iv = raw.payload.subarray(0, HALF_NONCE_SIZE);\n const encryptedPayload = raw.payload.subarray(HALF_NONCE_SIZE, -9);\n const nonceId = raw.payload.at(-9)!;\n const authCode = raw.payload.subarray(-8);\n // Retrieve the used nonce from the nonce store\n const nonce = ctx.securityManager.getNonce(nonceId);\n // Only accept the message if the nonce hasn't expired\n if (!nonce) {\n validatePayload.fail(`Nonce ${num2hex(nonceId)} expired, cannot decode security encapsulated command.`);\n }\n // and mark the nonce as used\n ctx.securityManager.deleteNonce(nonceId);\n // Validate the encrypted data\n const authData = getAuthenticationData(iv, nonce, SecurityCommand.CommandEncapsulation, ctx.sourceNodeId, ctx.ownNodeId, encryptedPayload);\n const expectedAuthCode = await computeMAC(authData, await ctx.securityManager.getAuthKey());\n // Only accept messages with a correct auth code\n validatePayload.withReason(\"Invalid auth code, won't accept security encapsulated command.\")(authCode.equals(expectedAuthCode));\n // Decrypt the encapsulated CC\n const frameControlAndDecryptedCC = await decryptAES128OFB(encryptedPayload, await ctx.securityManager.getEncryptionKey(), Bytes.concat([iv, nonce]));\n const frameControl = frameControlAndDecryptedCC[0];\n const sequenceCounter = frameControl & 0b1111;\n const sequenced = !!(frameControl & 16);\n const secondFrame = !!(frameControl & 32);\n const decryptedCCBytes = frameControlAndDecryptedCC.subarray(1);\n const ret = new SecurityCCCommandEncapsulation({\n nodeId: ctx.sourceNodeId,\n sequenceCounter,\n sequenced,\n secondFrame,\n decryptedCCBytes,\n });\n ret.authData = authData;\n ret.authCode = authCode;\n ret.iv = iv;\n return ret;\n }\n private sequenced: boolean | undefined;\n private secondFrame: boolean | undefined;\n private sequenceCounter: number | undefined;\n private decryptedCCBytes: BytesView | undefined;\n public encapsulated!: CommandClass;\n private alternativeNetworkKey?: BytesView;\n public get nonceId(): number | undefined {\n return this.nonce?.[0];\n }\n public nonce: BytesView | undefined;\n // Only used testing/for debugging purposes\n private iv?: BytesView;\n private authData?: BytesView;\n private authCode?: BytesView;\n private ciphertext?: BytesView;\n public getPartialCCSessionId(): Record<string, any> | undefined {\n if (this.sequenced) {\n return {\n // Treat Encapsulation and EncapsulationNonceGet as one\n ccCommand: undefined,\n sequence: this.sequenceCounter,\n };\n }\n else {\n return {\n // Treat Encapsulation and EncapsulationNonceGet as one\n ccCommand: undefined,\n };\n }\n }\n public getRemainingSegments(): number | undefined {\n // Sequenced S0 commands are always split into exactly two frames\n if (!this.sequenced)\n return 0;\n return this.secondFrame ? 0 : 1;\n }\n public async mergePartialCCs(partials: SecurityCCCommandEncapsulation[], ctx: CCParsingContext): Promise<void> {\n // Concat the CC buffers\n this.decryptedCCBytes = Bytes.concat([...partials, this].map((cc) => cc.decryptedCCBytes!));\n // make sure this contains a complete CC command that's worth splitting\n validatePayload(this.decryptedCCBytes.length >= 2);\n // and deserialize the CC\n this.encapsulated = await CommandClass.parse(this.decryptedCCBytes, ctx);\n this.encapsulated.encapsulatingCC = this as any;\n }\n public async serialize(ctx: CCEncodingContext): Promise<Bytes> {\n if (!this.nonce)\n throwNoNonce();\n if (this.nonce.length !== HALF_NONCE_SIZE) {\n throwNoNonce(\"Invalid nonce size\");\n }\n assertSecurityTX(ctx);\n let authKey: BytesView;\n let encryptionKey: BytesView;\n if (this.alternativeNetworkKey) {\n authKey = await generateAuthKey(this.alternativeNetworkKey);\n encryptionKey = await generateEncryptionKey(this.alternativeNetworkKey);\n }\n else {\n authKey = await ctx.securityManager.getAuthKey();\n encryptionKey = await ctx.securityManager.getEncryptionKey();\n }\n const serializedCC = await this.encapsulated.serialize(ctx);\n const plaintext = Bytes.concat([\n [0], // TODO: frame control\n serializedCC,\n ]);\n // Encrypt the payload\n const senderNonce = randomBytes(HALF_NONCE_SIZE);\n const iv = Bytes.concat([senderNonce, this.nonce]);\n const ciphertext = await encryptAES128OFB(plaintext, encryptionKey, iv);\n // And generate the auth code\n const authData = getAuthenticationData(senderNonce, this.nonce, this.ccCommand, ctx.ownNodeId, this.nodeId, ciphertext);\n const authCode = await computeMAC(authData, authKey);\n // Remember for debugging purposes\n this.iv = iv;\n this.authData = authData;\n this.authCode = authCode;\n this.ciphertext = ciphertext;\n this.payload = Bytes.concat([\n senderNonce,\n ciphertext,\n [this.nonceId!],\n authCode,\n ]);\n return super.serialize(ctx);\n }\n protected computeEncapsulationOverhead(): number {\n // Security CC adds 8 bytes IV, 1 byte frame control, 1 byte nonce ID, 8 bytes MAC\n return super.computeEncapsulationOverhead() + 18;\n }\n public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n const message: MessageRecord = {};\n if (this.nonceId != undefined) {\n message[\"nonce id\"] = this.nonceId;\n }\n if (this.sequenced != undefined) {\n message.sequenced = this.sequenced;\n if (this.sequenced) {\n if (this.secondFrame != undefined) {\n message[\"second frame\"] = this.secondFrame;\n }\n if (this.sequenceCounter != undefined) {\n message[\"sequence counter\"] = this.sequenceCounter;\n }\n }\n }\n // Log the plaintext in integration tests and development mode\n if (getenv(\"NODE_ENV\") === \"test\"\n || getenv(\"NODE_ENV\") === \"development\") {\n if (this.iv) {\n message.IV = buffer2hex(this.iv);\n }\n if (this.ciphertext) {\n message.ciphertext = buffer2hex(this.ciphertext);\n }\n else if (this.decryptedCCBytes) {\n message.plaintext = buffer2hex(this.decryptedCCBytes);\n }\n if (this.authData) {\n message[\"auth data\"] = buffer2hex(this.authData);\n }\n if (this.authCode) {\n message[\"auth code\"] = buffer2hex(this.authCode);\n }\n }\n return {\n ...super.toLogEntry(ctx),\n message,\n };\n }\n}\n// This is the same message, but with another CC command\n@CCCommand(SecurityCommand.CommandEncapsulationNonceGet)\nexport class SecurityCCCommandEncapsulationNonceGet extends SecurityCCCommandEncapsulation {\n}\n@CCCommand(SecurityCommand.SchemeReport)\nexport class SecurityCCSchemeReport extends SecurityCC {\n public static from(raw: CCRaw, ctx: CCParsingContext): SecurityCCSchemeReport {\n validatePayload(raw.payload.length >= 1);\n // The including controller MUST NOT perform any validation of the Supported Security Schemes byte\n return new this({\n nodeId: ctx.sourceNodeId,\n });\n }\n public serialize(ctx: CCEncodingContext): Promise<Bytes> {\n // Since it is unlikely that any more schemes will be added to S0, we hardcode the default scheme here (bit 0 = 0)\n this.payload = Bytes.from([0]);\n return super.serialize(ctx);\n }\n public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n return {\n ...super.toLogEntry(ctx),\n // Hide the default payload line\n message: undefined,\n };\n }\n}\n@CCCommand(SecurityCommand.SchemeGet)\n@expectedCCResponse(SecurityCCSchemeReport)\nexport class SecurityCCSchemeGet extends SecurityCC {\n public static from(raw: CCRaw, ctx: CCParsingContext): SecurityCCSchemeGet {\n validatePayload(raw.payload.length >= 1);\n // The joining node MUST NOT perform any validation of the Supported Security Schemes byte\n return new this({\n nodeId: ctx.sourceNodeId,\n });\n }\n public serialize(ctx: CCEncodingContext): Promise<Bytes> {\n // Since it is unlikely that any more schemes will be added to S0, we hardcode the default scheme here (bit 0 = 0)\n this.payload = Bytes.from([0]);\n return super.serialize(ctx);\n }\n public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n return {\n ...super.toLogEntry(ctx),\n // Hide the default payload line\n message: undefined,\n };\n }\n}\n@CCCommand(SecurityCommand.SchemeInherit)\n@expectedCCResponse(SecurityCCSchemeReport)\nexport class SecurityCCSchemeInherit extends SecurityCC {\n public static from(raw: CCRaw, ctx: CCParsingContext): SecurityCCSchemeInherit {\n validatePayload(raw.payload.length >= 1);\n // The joining node MUST NOT perform any validation of the Supported Security Schemes byte\n return new this({\n nodeId: ctx.sourceNodeId,\n });\n }\n public serialize(ctx: CCEncodingContext): Promise<Bytes> {\n // Since it is unlikely that any more schemes will be added to S0, we hardcode the default scheme here (bit 0 = 0)\n this.payload = Bytes.from([0]);\n return super.serialize(ctx);\n }\n public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n return {\n ...super.toLogEntry(ctx),\n // Hide the default payload line\n message: undefined,\n };\n }\n}\n@CCCommand(SecurityCommand.NetworkKeyVerify)\nexport class SecurityCCNetworkKeyVerify extends SecurityCC {\n}\n// @publicAPI\nexport interface SecurityCCNetworkKeySetOptions {\n networkKey: BytesView;\n}\n@CCCommand(SecurityCommand.NetworkKeySet)\n@expectedCCResponse(SecurityCCNetworkKeyVerify)\nexport class SecurityCCNetworkKeySet extends SecurityCC {\n public constructor(options: WithAddress<SecurityCCNetworkKeySetOptions>) {\n super(options);\n if (options.networkKey.length !== 16) {\n throw new ZWaveError(`The network key must have length 16!`, ZWaveErrorCodes.Argument_Invalid);\n }\n this.networkKey = options.networkKey;\n }\n public static from(raw: CCRaw, ctx: CCParsingContext): SecurityCCNetworkKeySet {\n validatePayload(raw.payload.length >= 16);\n const networkKey: BytesView = raw.payload.subarray(0, 16);\n return new this({\n nodeId: ctx.sourceNodeId,\n networkKey,\n });\n }\n public networkKey: BytesView;\n public serialize(ctx: CCEncodingContext): Promise<Bytes> {\n this.payload = Bytes.view(this.networkKey);\n return super.serialize(ctx);\n }\n public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n // The network key shouldn't be logged, so users can safely post their logs online\n const { message, ...log } = super.toLogEntry(ctx);\n return log;\n }\n}\n// @publicAPI\nexport interface SecurityCCCommandsSupportedReportOptions {\n reportsToFollow?: number;\n supportedCCs: CommandClasses[];\n controlledCCs: CommandClasses[];\n}\n@CCCommand(SecurityCommand.CommandsSupportedReport)\nexport class SecurityCCCommandsSupportedReport extends SecurityCC {\n public constructor(options: WithAddress<SecurityCCCommandsSupportedReportOptions>) {\n super(options);\n this.supportedCCs = options.supportedCCs;\n this.controlledCCs = options.controlledCCs;\n // TODO: properly split the CCs into multiple reports\n this.reportsToFollow = options.reportsToFollow ?? 0;\n }\n public static from(raw: CCRaw, ctx: CCParsingContext): SecurityCCCommandsSupportedReport {\n validatePayload(raw.payload.length >= 1);\n const reportsToFollow = raw.payload[0];\n const list = parseCCList(raw.payload.subarray(1));\n const supportedCCs: CommandClasses[] = list.supportedCCs;\n const controlledCCs: CommandClasses[] = list.controlledCCs;\n return new this({\n nodeId: ctx.sourceNodeId,\n reportsToFollow,\n supportedCCs,\n controlledCCs,\n });\n }\n public reportsToFollow: number;\n public supportedCCs: CommandClasses[];\n public controlledCCs: CommandClasses[];\n public getPartialCCSessionId(): Record<string, any> | undefined {\n // Nothing special we can distinguish sessions with\n return {};\n }\n public getRemainingSegments(): number | undefined {\n return this.reportsToFollow;\n }\n public mergePartialCCs(partials: SecurityCCCommandsSupportedReport[]): Promise<void> {\n // Concat the lists of CCs\n this.supportedCCs = [...partials, this]\n .map((report) => report.supportedCCs)\n .reduce((prev, cur) => prev.concat(...cur), []);\n this.controlledCCs = [...partials, this]\n .map((report) => report.controlledCCs)\n .reduce((prev, cur) => prev.concat(...cur), []);\n return Promise.resolve();\n }\n public serialize(ctx: CCEncodingContext): Promise<Bytes> {\n this.payload = Bytes.concat([\n [this.reportsToFollow],\n encodeCCList(this.supportedCCs, this.controlledCCs),\n ]);\n return super.serialize(ctx);\n }\n public toLogEntry(ctx?: GetValueDB): MessageOrCCLogEntry {\n return {\n ...super.toLogEntry(ctx),\n message: {\n reportsToFollow: this.reportsToFollow,\n supportedCCs: logList(this.supportedCCs.map((cc) => getCCName(cc))),\n controlledCCs: logList(this.controlledCCs.map((cc) => getCCName(cc))),\n },\n };\n }\n}\n@CCCommand(SecurityCommand.CommandsSupportedGet)\n@expectedCCResponse(SecurityCCCommandsSupportedReport)\nexport class SecurityCCCommandsSupportedGet extends SecurityCC {\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kBAAqf;AACrf,oBAA0E;AAC1E,mBAAqB;AACrB,iBAAqC;AACrC,0BAAiE;AACjE,oCAAsF;AACtF,mBAAgC;AAEhC,qBAAwB;AACxB,yBAA4B;AAC5B,gCAAmC;AAEnC,SAAS,sBAAsB,aAAwB,eAA0B,WAA4B,e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
563
563
|
if (u3cUsers == void 0) {
|
|
564
564
|
ctx.logNode(node.id, {
|
|
565
565
|
endpoint: this.endpointIndex,
|
|
566
|
-
message: "
|
|
566
|
+
message: "Could not determine if the node uses User Credential CC for user management, continuing with User Code CC interview...",
|
|
567
567
|
level: "warn"
|
|
568
568
|
});
|
|
569
|
-
return;
|
|
570
569
|
} else if (u3cUsers > 0) {
|
|
571
570
|
ctx.logNode(node.id, {
|
|
572
571
|
endpoint: this.endpointIndex,
|