{"_id":"@brilliant-ember/secure-channel","_rev":"6-3b99841b1f8b9c5196fa166ea3743bef","name":"@brilliant-ember/secure-channel","dist-tags":{"latest":"1.0.5"},"versions":{"1.0.0":{"name":"@brilliant-ember/secure-channel","version":"1.0.0","keywords":["crypto","key-exchange","x25519","ed25519","sign","verify","hkdf","aes-gcm","cross-platform","typescript","secure-channel"],"author":{"name":"Mohammed Al-Ameen"},"license":"MIT","_id":"@brilliant-ember/secure-channel@1.0.0","maintainers":[{"name":"brilliant-ember","email":"mohammed.j.alameen@gmail.com"}],"homepage":"https://github.com/brilliant-ember/secure-channel-npm#readme","bugs":{"url":"https://github.com/brilliant-ember/secure-channel-npm/issues"},"dist":{"shasum":"1aa0ddeb74f0109c6e86316a5b29a61e535933cf","tarball":"https://registry.npmjs.org/@brilliant-ember/secure-channel/-/secure-channel-1.0.0.tgz","fileCount":63,"integrity":"sha512-KDP/VChBoVyCUNDorYJZq0R5/rY9WnxcqyFTDhw+Cf1EnF8UFr1rdboXEJnY0IyybN8z8w+CB4tO+kktmzdHZw==","signatures":[{"sig":"MEYCIQDL6dTSJFPyXY2LvpGu0ADUWF0Zn/SqnuLTR75cVxGXVwIhAMTBwzRZs+uLLBGpyUhvx8BFzdCyvqtzEOFWBpD49I3L","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":160597},"main":"dist/node/index.js","types":"dist/index.d.ts","browser":"dist/browser/index.js","engines":{"node":">=15.0.0"},"exports":{".":{"node":{"import":"dist/node/index.js","require":"dist/node/index.js"},"browser":{"import":"dist/browser/index.js","require":"dist/browser/index.js"},"default":"dist/node/index.js"}},"scripts":{"test":"jest","build":"npm run build:node && npm run build:browser","build:node":"tsc -p tsconfig.node.json","test:watch":"jest --watch","build:browser":"tsc -p tsconfig.browser.json","test:coverage":"jest --coverage","prepublishOnly":"npm run build"},"_npmUser":{"name":"brilliant-ember","email":"mohammed.j.alameen@gmail.com"},"repository":{"url":"git+https://github.com/brilliant-ember/secure-channel-npm.git","type":"git"},"_npmVersion":"11.6.1","description":"Cross-platform (Node & browser) authenticated, encrypted channel: X25519 key-exchange + HKDF + AES-GCM **and** Ed25519 sign/verify in one zero-dependency TypeScript package","directories":{},"_nodeVersion":"24.11.0","_hasShrinkwrap":false,"devDependencies":{"jest":"^29.5.0","ts-jest":"^29.1.0","typescript":"^5.0.0","@types/jest":"^29.5.0","@types/node":"^24.10.0"},"_npmOperationalInternal":{"tmp":"tmp/secure-channel_1.0.0_1762899726426_0.42377391678826215","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@brilliant-ember/secure-channel","version":"1.0.1","keywords":["crypto","key-exchange","x25519","ed25519","sign","verify","hkdf","aes-gcm","cross-platform","typescript","secure-channel"],"author":{"name":"Mohammed Al-Ameen"},"license":"MIT","_id":"@brilliant-ember/secure-channel@1.0.1","maintainers":[{"name":"brilliant-ember","email":"mohammed.j.alameen@gmail.com"}],"homepage":"https://github.com/brilliant-ember/secure-channel-npm#readme","bugs":{"url":"https://github.com/brilliant-ember/secure-channel-npm/issues"},"dist":{"shasum":"9a761691c9ea5925a8aed7e2efed05bef138e829","tarball":"https://registry.npmjs.org/@brilliant-ember/secure-channel/-/secure-channel-1.0.1.tgz","fileCount":63,"integrity":"sha512-08K3f2AyKoXwWbc2/KoxIV3XKvZpeR2FnH2ZWgSQyEsQofQVaBkbGnjm+LtcEb/+FoCaYiKk7qqzXNmA3Lbl7A==","signatures":[{"sig":"MEUCIQDw+K7T7x04ZVBP/D3XzdKJrVgG0VF36wXusLZ1xxvXnQIgAhrhyWlQPAGutC33+P+mHvTW6dLrRe8yO7b73iqXKuo=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":160597},"main":"dist/node/index.js","types":"dist/index.d.ts","browser":"dist/browser/index.js","engines":{"node":">=15.0.0"},"exports":{".":{"node":{"import":"dist/node/index.js","require":"dist/node/index.js"},"browser":{"import":"dist/browser/index.js","require":"dist/browser/index.js"},"default":"dist/node/index.js"}},"scripts":{"test":"jest","build":"npm run build:node && npm run build:browser","build:node":"tsc -p tsconfig.node.json","test:watch":"jest --watch","build:browser":"tsc -p tsconfig.browser.json","test:coverage":"jest --coverage","prepublishOnly":"npm run build"},"_npmUser":{"name":"brilliant-ember","email":"mohammed.j.alameen@gmail.com"},"repository":{"url":"git+https://github.com/brilliant-ember/secure-channel-npm.git","type":"git"},"_npmVersion":"11.6.1","description":"Cross-platform (Node & browser) authenticated, encrypted channel: X25519 key-exchange + HKDF + AES-GCM **and** Ed25519 sign/verify in one zero-dependency TypeScript package","directories":{},"_nodeVersion":"24.11.0","_hasShrinkwrap":false,"devDependencies":{"jest":"^29.5.0","ts-jest":"^29.1.0","typescript":"^5.0.0","@types/jest":"^29.5.0","@types/node":"^24.10.0"},"_npmOperationalInternal":{"tmp":"tmp/secure-channel_1.0.1_1762899884143_0.8617249737744415","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@brilliant-ember/secure-channel","version":"1.0.2","keywords":["crypto","key-exchange","x25519","ed25519","sign","verify","hkdf","aes-gcm","cross-platform","typescript","secure-channel"],"author":{"name":"Mohammed Al-Ameen"},"license":"MIT","_id":"@brilliant-ember/secure-channel@1.0.2","maintainers":[{"name":"brilliant-ember","email":"mohammed.j.alameen@gmail.com"}],"homepage":"https://github.com/brilliant-ember/secure-channel-npm#readme","bugs":{"url":"https://github.com/brilliant-ember/secure-channel-npm/issues"},"dist":{"shasum":"e909684dd093a463a3c9ae765b5d981b54a99f0c","tarball":"https://registry.npmjs.org/@brilliant-ember/secure-channel/-/secure-channel-1.0.2.tgz","fileCount":63,"integrity":"sha512-VC4sHyp9Zp0LYw+qj7T1IEt3jQQtRu2/zU98IwTmmhP31nHlbK6eCvWiKAT6I++2kyTZs9NhFr7ibqDnpyYlyA==","signatures":[{"sig":"MEQCIEHHt+uQFgjhBP0bHNJVZbcjeiEpFq28nYNcRNceFsj6AiBuHXyi29/YTIFgPsJmRTA5gD0nvPSpYAtSp1dWMPCvrA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":162427},"main":"dist/node/index.js","types":"dist/index.d.ts","browser":"dist/browser/index.js","engines":{"node":">=15.0.0"},"exports":{".":{"node":{"import":"dist/node/index.js","require":"dist/node/index.js"},"browser":{"import":"dist/browser/index.js","require":"dist/browser/index.js"},"default":"dist/node/index.js"}},"scripts":{"test":"jest","build":"npm run build:node && npm run build:browser","build:node":"tsc -p tsconfig.node.json","test:watch":"jest --watch","build:browser":"tsc -p tsconfig.browser.json","test:coverage":"jest --coverage","prepublishOnly":"npm run build"},"_npmUser":{"name":"brilliant-ember","email":"mohammed.j.alameen@gmail.com"},"repository":{"url":"git+https://github.com/brilliant-ember/secure-channel-npm.git","type":"git"},"_npmVersion":"11.6.1","description":"Cross-platform (Node & browser) authenticated, encrypted channel: X25519 key-exchange + HKDF + AES-GCM **and** Ed25519 sign/verify in one zero-dependency TypeScript package","directories":{},"_nodeVersion":"24.11.0","_hasShrinkwrap":false,"devDependencies":{"jest":"^29.5.0","ts-jest":"^29.1.0","typescript":"^5.0.0","@types/jest":"^29.5.0","@types/node":"^24.10.0"},"_npmOperationalInternal":{"tmp":"tmp/secure-channel_1.0.2_1762900096248_0.5885732758009881","host":"s3://npm-registry-packages-npm-production"}},"1.0.3":{"name":"@brilliant-ember/secure-channel","version":"1.0.3","keywords":["crypto","key-exchange","x25519","ed25519","sign","verify","hkdf","aes-gcm","cross-platform","typescript","secure-channel"],"author":{"name":"Mohammed Al-Ameen"},"license":"MIT","_id":"@brilliant-ember/secure-channel@1.0.3","maintainers":[{"name":"brilliant-ember","email":"mohammed.j.alameen@gmail.com"}],"homepage":"https://github.com/brilliant-ember/secure-channel-npm#readme","bugs":{"url":"https://github.com/brilliant-ember/secure-channel-npm/issues"},"dist":{"shasum":"484bc131c79b8d0ca956d586ba99bb1b8be9392c","tarball":"https://registry.npmjs.org/@brilliant-ember/secure-channel/-/secure-channel-1.0.3.tgz","fileCount":63,"integrity":"sha512-GcCwB7Q3XXdnsl9dinBV2b1kKlcX+SAPIO4bYMnKxJ1j0VzIQOU94h22Tmsa3EBNSWFCv5/HdvjcUmJTO9cnDA==","signatures":[{"sig":"MEYCIQCmCXBxWD8dvKrY5Zd3OhYXhobbjBBJ+o9OGk1LCZlkBgIhAPzkkUPMKmODBDkTtEdxPhzp/7n5h/1nset1qMARI+ng","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":164144},"main":"dist/node/index.js","types":"dist/index.d.ts","browser":"dist/browser/index.js","engines":{"node":">=15.0.0"},"exports":{".":{"node":{"import":"./dist/node/index.js","require":"./dist/node/index.js"},"browser":{"import":"./dist/browser/index.js","require":"./dist/browser/index.js"},"default":"./dist/node/index.js"}},"scripts":{"test":"jest","build":"npm run build:node && npm run build:browser","build:node":"tsc -p tsconfig.node.json","test:watch":"jest --watch","build:browser":"tsc -p tsconfig.browser.json","test:coverage":"jest --coverage","prepublishOnly":"npm run build"},"_npmUser":{"name":"brilliant-ember","email":"mohammed.j.alameen@gmail.com"},"repository":{"url":"git+https://github.com/brilliant-ember/secure-channel-npm.git","type":"git"},"_npmVersion":"11.6.1","description":"Cross-platform (Node & browser) authenticated, encrypted channel: X25519 key-exchange + HKDF + AES-GCM **and** Ed25519 sign/verify in one zero-dependency TypeScript package","directories":{},"_nodeVersion":"24.11.0","_hasShrinkwrap":false,"devDependencies":{"jest":"^29.5.0","ts-jest":"^29.1.0","typescript":"^5.0.0","@types/jest":"^29.5.0","@types/node":"^24.10.0"},"_npmOperationalInternal":{"tmp":"tmp/secure-channel_1.0.3_1762906194346_0.022627779655793434","host":"s3://npm-registry-packages-npm-production"}},"1.0.4":{"name":"@brilliant-ember/secure-channel","version":"1.0.4","keywords":["crypto","key-exchange","x25519","ed25519","sign","verify","hkdf","aes-gcm","cross-platform","typescript","secure-channel"],"author":{"name":"Mohammed Al-Ameen"},"license":"MIT","_id":"@brilliant-ember/secure-channel@1.0.4","maintainers":[{"name":"brilliant-ember","email":"mohammed.j.alameen@gmail.com"}],"homepage":"https://github.com/brilliant-ember/secure-channel-npm#readme","bugs":{"url":"https://github.com/brilliant-ember/secure-channel-npm/issues"},"dist":{"shasum":"6808b4d30ceaa6b8530b48fb783929f37f3f511a","tarball":"https://registry.npmjs.org/@brilliant-ember/secure-channel/-/secure-channel-1.0.4.tgz","fileCount":63,"integrity":"sha512-8MGpF6K7i7OEBCyWsSjsLzh4D9XJmXFApapQbiOnsw2YfeguC+t168I/UkrodMp5FemU/sibokBty+459T0Gwg==","signatures":[{"sig":"MEQCIBEO9tMZTI0ohePzSRIOya8i972/VDnmCFkrvWUd3giLAiBN0uSgsK1tkcqv+GPY8ME4AVl7J2mBmVlz66aHKX6kVQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":186542},"main":"dist/node/index.js","types":"dist/index.d.ts","browser":"dist/browser/index.js","engines":{"node":">=15.0.0"},"exports":{".":{"node":{"import":"./dist/node/index.js","require":"./dist/node/index.js"},"browser":{"import":"./dist/browser/index.js","require":"./dist/browser/index.js"},"default":"./dist/node/index.js"}},"scripts":{"test":"jest","build":"npm run build:node && npm run build:browser","build:node":"tsc -p tsconfig.node.json","test:watch":"jest --watch","build:browser":"tsc -p tsconfig.browser.json","test:coverage":"jest --coverage","prepublishOnly":"npm run build"},"_npmUser":{"name":"brilliant-ember","email":"mohammed.j.alameen@gmail.com"},"repository":{"url":"git+https://github.com/brilliant-ember/secure-channel-npm.git","type":"git"},"_npmVersion":"11.6.1","description":"Cross-platform (Node & browser) authenticated, encrypted channel: X25519 key-exchange + HKDF + AES-GCM **and** Ed25519 sign/verify in one zero-dependency TypeScript package","directories":{},"_nodeVersion":"24.11.0","_hasShrinkwrap":false,"devDependencies":{"jest":"^29.5.0","ts-jest":"^29.1.0","typescript":"^5.0.0","@types/jest":"^29.5.0","@types/node":"^24.10.0"},"_npmOperationalInternal":{"tmp":"tmp/secure-channel_1.0.4_1763333707246_0.14916068306741326","host":"s3://npm-registry-packages-npm-production"}},"1.0.5":{"name":"@brilliant-ember/secure-channel","version":"1.0.5","description":"Cross-platform (Node & browser) authenticated, encrypted channel: X25519 key-exchange + HKDF + AES-GCM **and** Ed25519 sign/verify in one zero-dependency TypeScript package","main":"dist/node/index.js","browser":"dist/browser/index.js","types":"dist/index.d.ts","scripts":{"build":"npm run build:node && npm run build:browser","build:node":"tsc -p tsconfig.node.json","build:browser":"tsc -p tsconfig.browser.json","prepublishOnly":"npm run build","test":"jest","test:watch":"jest --watch","test:coverage":"jest --coverage"},"keywords":["crypto","key-exchange","x25519","ed25519","sign","verify","hkdf","aes-gcm","cross-platform","typescript","secure-channel"],"author":{"name":"Mohammed Al-Ameen"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/brilliant-ember/secure-channel-npm.git"},"engines":{"node":">=15.0.0"},"devDependencies":{"@types/node":"^24.10.0","@types/jest":"^29.5.0","jest":"^29.5.0","ts-jest":"^29.1.0","typescript":"^5.0.0"},"exports":{".":{"node":{"import":"./dist/node/index.js","require":"./dist/node/index.js"},"browser":{"import":"./dist/browser/index.js","require":"./dist/browser/index.js"},"default":"./dist/node/index.js"}},"_id":"@brilliant-ember/secure-channel@1.0.5","bugs":{"url":"https://github.com/brilliant-ember/secure-channel-npm/issues"},"homepage":"https://github.com/brilliant-ember/secure-channel-npm#readme","_nodeVersion":"24.11.0","_npmVersion":"11.6.1","dist":{"integrity":"sha512-8N8Wz1+Wq5c8uNpK8iKlUW5KYCU4OC3H/84hgWt5BgZZRWJXsEytX7wTvQokbKSOFQQPLaUxjd6G2KXUPLrQVw==","shasum":"c2c040a3306390d134013eda2232be216dd46d7a","tarball":"https://registry.npmjs.org/@brilliant-ember/secure-channel/-/secure-channel-1.0.5.tgz","fileCount":63,"unpackedSize":198124,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDlztsy29E6XPdr3oqbwr/1iYsaJGgJzRFeWjwJWKfduwIgH8Ihz3PVsnx09056/h0yUK8lheuMWurtwfDKu6h5kHQ="}]},"_npmUser":{"name":"brilliant-ember","email":"mohammed.j.alameen@gmail.com"},"directories":{},"maintainers":[{"name":"brilliant-ember","email":"mohammed.j.alameen@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/secure-channel_1.0.5_1763361804414_0.955837730478521"},"_hasShrinkwrap":false}},"time":{"created":"2025-11-11T22:22:06.346Z","modified":"2025-11-17T06:43:24.770Z","1.0.0":"2025-11-11T22:22:06.645Z","1.0.1":"2025-11-11T22:24:44.336Z","1.0.2":"2025-11-11T22:28:16.454Z","1.0.3":"2025-11-12T00:09:54.555Z","1.0.4":"2025-11-16T22:55:07.481Z","1.0.5":"2025-11-17T06:43:24.593Z"},"bugs":{"url":"https://github.com/brilliant-ember/secure-channel-npm/issues"},"author":{"name":"Mohammed Al-Ameen"},"license":"MIT","homepage":"https://github.com/brilliant-ember/secure-channel-npm#readme","keywords":["crypto","key-exchange","x25519","ed25519","sign","verify","hkdf","aes-gcm","cross-platform","typescript","secure-channel"],"repository":{"type":"git","url":"git+https://github.com/brilliant-ember/secure-channel-npm.git"},"description":"Cross-platform (Node & browser) authenticated, encrypted channel: X25519 key-exchange + HKDF + AES-GCM **and** Ed25519 sign/verify in one zero-dependency TypeScript package","maintainers":[{"name":"brilliant-ember","email":"mohammed.j.alameen@gmail.com"}],"readme":"# Cross-Platform Key Exchange **and** Signature\n\nA TypeScript library for secure cross-platform key exchange and encryption, as well as signature and verification. Works in both Node.js (15+) and browsers.\n\n## Features\n\n- **X25519** for elliptic curve key exchange\n- **HKDF** for key derivation\n- **AES-GCM** for authenticated encryption\n- **Ed25519** signature / verification\n- **Cross-platform** - works in Node.js and browsers\n- **TypeScript** - fully typed\n- **Zero dependencies**\n\n## Installation\n\n```bash\n\nnpm install @brilliant-ember/secure-channel --save\n\n```\n\n\n## Use examples\n\n### NodeJS\n```typescript\n\n// completeNodeExample.js\nconst sc = require(\"@brilliant-ember/secure-channel\");\nconst { webcrypto } = require(\"crypto\");\nconst { subtle } = webcrypto;\n\nasync function main() {\n\n    // signature related\n    const signer = await sc.Signature.getInstance();\n    await signer.initializeServerKey(theOtherPartySignaturePublicKey);\n    const ourPublicSignatureKey = await signer.getPublicKey();\n    // sign our own response\n    const ourSignature = await signer.sign(ourDataBytes); // this has to be base64\n    // verify the response we got from the other server\n    const isOtherServerSignatureValid = await signer.verify(otherServerSignature, dataBytesFromOtherServer);\n\n\n    // encrypte and decrypt\n    const kx = await sc.KeyExchange.getInstance();\n    const otherServerPublicKxKey = getOtherServerKxKey(); // we need this from the other server we are talking to first to generate our own kx keys\n    const otherServerKxCryptoKey = await subtle.importKey(\n      \"raw\",\n      otherServerPublicKxKeyBytes,\n      { name: \"X25519\" },\n      false,\n      []\n    );\n    // we need to send our kxKey to the other server to finish the dh key exchange\n    const ourKxPublicKey = await kx.generateKey(otherServerKxCryptoKey);\n    sendKxToOtherServer(ourKxPublicKey);\n\n    const { ciphertext, nonce } = await kx.encrypt(\"Hello other server!\");\n    const response = await sendDataToOtherServer(ciphertext, nonce); // we must send the nonce too\n    const decryptedData = await kx.decrypt(response.ciphertext, response.nonce);\n    // this is a helper function\n    const plaintext = sc.byteArrToString(decryptedData);\n    console.log(plaintext) // will print \"Hello client!\"\n\n\n    // helper functions provided\n    sc.byteArrToString(Uint8Array);\n    sc.base64ToUint32(b64);\n    sc.uint32ToBase64(number);\n    sc.uint32ToBytes(num);\n    sc.copyToBuffer(Uint8Array, number, Uint8Array);\n    sc.base64StringtoByteArr(uint8array); \n    sc.byteArrayToBase64(ArrayBuffer | Uint8Array); \n    sc.numberToBase64(num); \n    sc.base64ToNumber(b64); \n    sc.generateRandomBytes(32); \n    sc.bigIntToBase64(1n); \n    sc.base64ToBigInt(b64); \n    sc.convertToJsonSerializable(obj);\n}\n\n```\n\n### React client\n```typescript\n// SecureComponent.jsx\nimport { useState, useEffect } from 'react';\nimport { KeyExchange, Signature } from '@brilliant-ember/secure-channel';\n\nexport function SecureComponent() {\n  const [crypto, setCrypto] = useState(null);\n  const [message, setMessage] = useState('');\n\n  useEffect(() => {\n    KeyExchange.getInstance().then(setCrypto);\n  }, []);\n\n  const encryptMessage = async () => {\n    const { ciphertext, nonce } = await crypto.encrypt(message);\n    console.log('Encrypted:', { ciphertext, nonce });\n  };\n\n  return (\n    <div>\n      <input value={message} onChange={e => setMessage(e.target.value)} />\n      <button onClick={encryptMessage}>Encrypt</button>\n    </div>\n  );\n}\n\n```\n\n\n### Raw browser javascript\n```html\n\n<script type=\"module\">\n  import { KeyExchange, Signature } from './@brilliant-ember/secure-channel.js';\n\n  // Initialize\n  const crypto = await KeyExchange.getInstance();\n  const sig = await Signature.getInstance();\n\n  // Generate keys with server's public key\n  const serverKey = await importServerKey();\n  await crypto.generateKey(serverKey);\n\n  // Encrypt\n  const { ciphertext, nonce } = await crypto.encrypt('Hello World!');\n\n  // Decrypt  \n  const decrypted = await crypto.decrypt(ciphertext, nonce);\n  console.log('Decrypted:', new TextDecoder().decode(decrypted));\n</script>\n\n```\n\n### Helpers\n\n#### Basic Base64 Conversion\n\n```javascript\nimport { byteArrayToBase64, base64StringToByteArr } from '@brilliant-ember/secure-channel';\n\n// Convert text to base64 and back\nconst text = \"Hello World\";\nconst bytes = new TextEncoder().encode(text);\nconst base64 = byteArrayToBase64(bytes);\nconsole.log('Base64:', base64); // \"SGVsbG8gV29ybGQ=\"\n\nconst decodedBytes = base64StringToByteArr(base64);\nconst decodedText = new TextDecoder().decode(decodedBytes);\nconsole.log('Decoded:', decodedText); // \"Hello World\"\n\n```\n#### BigInt Helpers for Timestamps/IDs\n\n```javascript\nimport { bigIntToBase64, base64ToBigInt } from '@brilliant-ember/secure-channel';\n\n// Store timestamps as compact base64\nconst timestamp = BigInt(Date.now());\nconst timestampB64 = bigIntToBase64(timestamp);\nconsole.log('Timestamp base64:', timestampB64);\n\nconst recovered = base64ToBigInt(timestampB64);\nconsole.log('Recovered timestamp:', Number(recovered));\n\n// For message IDs\nconst messageId = 1234567890123456789n;\nconst idB64 = bigIntToBase64(messageId);\nconsole.log('Message ID:', idB64);\n\n```\n#### Number Helpers (Safe Integer Range)\n\n```javascript\n\nimport { numberToBase64, base64ToNumber } from '@brilliant-ember/secure-channel';\n\n// For smaller numbers\nconst count = 1234567890;\nconst countB64 = numberToBase64(count);\nconsole.log('Count base64:', countB64);\n\nconst recoveredCount = base64ToNumber(countB64);\nconsole.log('Recovered count:', recoveredCount);\n```\n#### Random Bytes\n\n```javascript\n\nimport { generateRandomBytes } from '@brilliant-ember/secure-channel';\n\n// Generate secure random data\nconst randomData = await generateRandomBytes(32);\nconsole.log('Random bytes:', randomData);\n```\n\n#### Copy To Buffer \n\n\n```javascript\n\nfunction serializeData(data) {\n  const { id, type, payload, timestamp } = data;\n  \n  // Calculate total size\n  const idBytes = new TextEncoder().encode(id);\n  const typeBytes = new TextEncoder().encode(type);\n  const totalSize = idBytes.length + typeBytes.length + payload.length + 8;\n  \n  const buffer = new Uint8Array(totalSize);\n  let offset = 0;\n  \n  // Serialize structure\n  offset = copyToBuffer(buffer, offset, id);                    // String ID\n  offset = copyToBuffer(buffer, offset, \"|\");                   // Separator\n  offset = copyToBuffer(buffer, offset, type);                  // String type\n  offset = copyToBuffer(buffer, offset, \"|\");                   // Separator\n  \n  const timestampBytes = uint32ToBytes(timestamp);\n  offset = copyToBuffer(buffer, offset, timestampBytes);        // 4-byte timestamp\n  \n  offset = copyToBuffer(buffer, offset, payload);               // Binary payload\n  \n  return buffer;\n}\n\n// Usage\nconst message = {\n  id: \"msg-123\",\n  type: \"user_message\", \n  timestamp: Math.floor(Date.now() / 1000),\n  payload: new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8])\n};\n\nconst serialized = serializeData(message);\nconsole.log('Serialized size:', serialized.length);\n\n```\n\n#### Convert to JSON serializable\n\n```typescript\n\n// Storing binary data in JSON-based storage (LocalStorage, Redis, etc.)\nfunction saveToStorage(key: string, data: any) {\n  const serializableData = convertToJsonSerializable(data);\n  localStorage.setItem(key, JSON.stringify(serializableData));\n}\n\n// Usage with binary user data\nconst userData = {\n  id: 123,\n  profileImage: new Uint8Array([255, 255, 255, 0]), // Binary image data\n  preferences: {\n    theme: \"dark\",\n    customData: new Uint8Array([1, 2, 3])\n  }\n};\n\nsaveToStorage(\"userData\", userData);\n```","readmeFilename":"README.md"}