{"name":"@xrplf/isomorphic","version":"1.0.2","description":"A collection of isomorphic and tree-shakeable crypto hashes and utils for xrpl.js","keywords":["crypto","isomorphic","xrpl"],"scripts":{"build":"tsc --build ./tsconfig.build.json","test":"npm run build && jest --verbose false --silent=false ./test/*.test.ts","test:browser":"npm run build && karma start ./karma.config.js","clean":"rm -rf ./dist ./coverage ./test/testCompiledForWeb tsconfig.build.tsbuildinfo","lint":"eslint . --max-warnings 0","prepublish":"npm run lint && npm test"},"directories":{"test":"test"},"dependencies":{"@noble/hashes":"^2.0.1","eventemitter3":"5.0.1","ws":"^8.20.0"},"devDependencies":{"@types/node":"^18.18.38","@types/ws":"^8.18.1"},"repository":{"type":"git","url":"git+ssh://git@github.com/XRPLF/xrpl.js.git"},"license":"ISC","prettier":"@xrplf/prettier-config","engines":{"node":">=18.0.0"},"_id":"@xrplf/isomorphic@1.0.2","bugs":{"url":"https://github.com/XRPLF/xrpl.js/issues"},"homepage":"https://github.com/XRPLF/xrpl.js#readme","_integrity":"sha512-ncZUdMXr6VlSXtdoiDi0jTH+gBrgGxwVeEidhoegII3PmyErbQsyj6e+j7acmR4LW/lvBkPkzb9QzRfJH0n3rA==","_resolved":"/home/runner/work/xrpl.js/xrpl.js/dist/xrplf-isomorphic-1.0.2.tgz","_from":"file:xrplf-isomorphic-1.0.2.tgz","_nodeVersion":"20.20.2","_npmVersion":"11.6.0","dist":{"integrity":"sha512-ncZUdMXr6VlSXtdoiDi0jTH+gBrgGxwVeEidhoegII3PmyErbQsyj6e+j7acmR4LW/lvBkPkzb9QzRfJH0n3rA==","shasum":"15e6f1e9dba25690f0e7585568554a7a1cb01cdd","tarball":"http://registry-npm.ywwl.com/@xrplf/isomorphic/download/@xrplf/isomorphic-1.0.2.tgz","fileCount":88,"unpackedSize":55656,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@xrplf%2fisomorphic@1.0.2","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCyS22FkG4nMo8nsptdaClo6cBtdMf9aphZweSipW7B8gIgLFuCdJSgGL4vhnyp+UPb6A9kCI25j5KjeLJMF6/PyJM="}],"size":14875,"noattachment":false,"key":"/@xrplf/isomorphic/-/@xrplf/isomorphic-1.0.2.tgz"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:50065203-ac6b-4f9c-b20c-ce391ec81699"}},"maintainers":[{"name":"bmollin","email":"brett@xrpl.foundation"},{"name":"transia","email":"dangell@transia.co"},{"name":"shichengripple001","email":"cshi@ripple.com"},{"name":"vjkhannaripple","email":"vraviraj@ripple.com"},{"name":"ripplex-automation","email":"ripplegithub@ripple.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/isomorphic_1.0.2_1780596709063_0.8830652471777785"},"_hasShrinkwrap":false,"readme":"# @xrplf/isomorphic\n\nA collection of isomorphic implementations of crypto and utility functions.\n\nBrowser implementations of cryptographic functions use `@noble/hashes` and `crypto` for node .\n\n### Hashes\n\nAll hash functions operate similarly to `@noble/hashes` and have the following properties:\n\n- They can be called directly by providing a Uint8Array or string which will be converted into a UInt8Array via UTF-8 encoding (not hex).\n- They all return a UInt8Array.\n\n```\nfunction hash(message: Uint8Array | string): Uint8Array;\nhash(new Uint8Array([1, 3]));\nhash('string') == hash(new TextEncoder().encode('string'));\n```\n\nAll hash functions can be constructed via `hash.create()` method:\n\n- The result is `Hash` subclass instance, which has `update()` and `digest()` methods.\n- `digest()` finalizes the hash and makes it no longer usable\n\n```typescript\nhash\n  .create()\n  .update(new Uint8Array([1, 3]))\n  .digest();\n```\n\n### `@xrplf/isomorphic/ripemd160`\n```typescript\nimport { ripemd160 } from '@xrplf/isomorphic/ripemd160';\nconst hashA = ripemd160('abc');\nconst hashB = ripemd160\n  .create()\n  .update(Uint8Array.from([1, 2, 3]))\n  .digest();\n```\n\n### `@xrplf/isomorphic/sha256`\n\n```typescript\nimport { sha256 } from '@xrplf/isomorphic/sha256';\nconst hashA = sha256('abc');\nconst hashB = sha256\n  .create()\n  .update(Uint8Array.from([1, 2, 3]))\n  .digest();\n```\n\n### `@xrplf/isomorphic/sha512`\n\n```typescript\nimport { sha512 } from '@xrplf/isomorphic/sha512';\nconst hashA = sha512('abc');\nconst hashB = sha512\n  .create()\n  .update(Uint8Array.from([1, 2, 3]))\n  .digest();\n```\n\n## Utilities\n\n### `@xrplf/isomorphic/utils`\n\n#### randomBytes\n\nCreate an UInt8Array of the supplied size\n\n```typescript\nimport { randomBytes } from @xrplf/isomorphic/utils\n\nconsole.log(randomBytes(12)) // Uint8Array(12) [95, 236, 188,  55, 208, 128, 161, 249, 171, 57, 141, 7]\n```\n\n#### bytesToHex\n\nConvert an UInt8Array to hex.\n\n```typescript\nimport { bytesToHex } from @xrplf/isomorphic/utils\n\nconsole.log(bytesToHex([222, 173, 190, 239])) // \"DEADBEEF\"\n```\n\n#### hexToBytes\n\nConvert hex to an UInt8Array.\n\n```typescript\nimport { hexToBytes } from @xrplf/isomorphic/utils\n\nconsole.log(hexToBytes('DEADBEEF')) // [222, 173, 190, 239]\n```\n\n#### hexToString\n\nConverts hex to its string equivalent. Useful to read the Domain field and some Memos.\n\n```typescript\nimport { hexToString } from @xrplf/isomorphic/utils\n\nconsole.log(hexToString('6465616462656566D68D')) // \"deadbeef֍\"\n```\n\n#### stringToHex\n\nConverts a utf-8 to its hex equivalent. Useful for Memos.\n\n```typescript\nimport { stringToHex } from @xrplf/isomorphic/utils\n\nconsole.log(stringToHex('deadbeef֍')) // \"6465616462656566D68D\"\n```\n\n### `@xrplf/isomorphic/ws`\n\n```typescript\nimport WebSocket from '@xrplf/isomorphic/ws'\n\nconst socket = new WebSocket('wss://localhost:8080')\n```\n","publish_time":1780596709204,"_cnpm_publish_time":1780596709204,"dist-tags":{"beta":"1.0.0-beta.1","latest":"1.0.2"}}