Development Artifact Cleanup: ✅ BROTHER_NODE REORGANIZATION: Moved development test node to appropriate location - dev/test-nodes/brother_node/: Moved from root directory for better organization - Contains development configuration, test logs, and test chain data - No impact on production systems - purely development/testing artifact ✅ DEVELOPMENT ARTIFACTS IDENTIFIED: - Chain ID: aitbc-brother-chain (test/development chain) - Ports: 8010 (P2P) and 8011 (RPC) - different from production - Environment: .env file with test configuration - Logs: rpc.log and node.log from development testing session (March 15, 2026) ✅ ROOT DIRECTORY CLEANUP: Removed development clutter from production directory - brother_node/ moved to dev/test-nodes/brother_node/ - Root directory now contains only production-ready components - Development artifacts properly organized in dev/ subdirectory DIRECTORY STRUCTURE IMPROVEMENT: 📁 dev/test-nodes/: Development and testing node configurations 🏗️ Root Directory: Clean production structure with only essential components 🧪 Development Isolation: Test environments separated from production BENEFITS: ✅ Clean Production Directory: No development artifacts in root ✅ Better Organization: Development nodes grouped in dev/ subdirectory ✅ Clear Separation: Production vs development environments clearly distinguished ✅ Maintainability: Easier to identify and manage development components RESULT: Successfully moved brother_node development artifact to dev/test-nodes/ subdirectory, cleaning up the root directory while preserving development testing environment for future use.
52 lines
1.5 KiB
TypeScript
Executable File
52 lines
1.5 KiB
TypeScript
Executable File
/**
|
|
* An **HMAC** enables verification that a given key was used
|
|
* to authenticate a payload.
|
|
*
|
|
* See: [[link-wiki-hmac]]
|
|
*
|
|
* @_subsection: api/crypto:HMAC [about-hmac]
|
|
*/
|
|
import { createHmac } from "./crypto.js";
|
|
import { getBytes, hexlify } from "../utils/index.js";
|
|
|
|
import type { BytesLike } from "../utils/index.js";
|
|
|
|
|
|
let locked = false;
|
|
|
|
const _computeHmac = function(algorithm: "sha256" | "sha512", key: Uint8Array, data: Uint8Array): BytesLike {
|
|
return createHmac(algorithm, key).update(data).digest();
|
|
}
|
|
|
|
let __computeHmac = _computeHmac;
|
|
|
|
/**
|
|
* Return the HMAC for %%data%% using the %%key%% key with the underlying
|
|
* %%algo%% used for compression.
|
|
*
|
|
* @example:
|
|
* key = id("some-secret")
|
|
*
|
|
* // Compute the HMAC
|
|
* computeHmac("sha256", key, "0x1337")
|
|
* //_result:
|
|
*
|
|
* // To compute the HMAC of UTF-8 data, the data must be
|
|
* // converted to UTF-8 bytes
|
|
* computeHmac("sha256", key, toUtf8Bytes("Hello World"))
|
|
* //_result:
|
|
*
|
|
*/
|
|
export function computeHmac(algorithm: "sha256" | "sha512", _key: BytesLike, _data: BytesLike): string {
|
|
const key = getBytes(_key, "key");
|
|
const data = getBytes(_data, "data");
|
|
return hexlify(__computeHmac(algorithm, key, data));
|
|
}
|
|
computeHmac._ = _computeHmac;
|
|
computeHmac.lock = function() { locked = true; }
|
|
computeHmac.register = function(func: (algorithm: "sha256" | "sha512", key: Uint8Array, data: Uint8Array) => BytesLike) {
|
|
if (locked) { throw new Error("computeHmac is locked"); }
|
|
__computeHmac = func;
|
|
}
|
|
Object.freeze(computeHmac);
|