{"_id":"@blowfishxyz/safeguard","_rev":"1-2f733eff08e91ad87c88887364760e3f","name":"@blowfishxyz/safeguard","dist-tags":{"latest":"2.0.0"},"versions":{"1.0.0":{"name":"@blowfishxyz/safeguard","version":"1.0.0","keywords":[],"author":"","license":"ISC","_id":"@blowfishxyz/safeguard@1.0.0","dist":{"shasum":"5e2c2bf06dc0e31a490ba5c418606f6541a5316a","tarball":"https://registry.npmjs.org/@blowfishxyz/safeguard/-/safeguard-1.0.0.tgz","fileCount":12,"integrity":"sha512-B4rciXIi5NtVx6luMSiQJ/vtLYbw+KYGWxSgn/eTq9fjGAuG5WTgX4c0m505Ohkf9mHvAoualjisq62JYhFfew==","signatures":[{"sig":"MEQCIBOMeExSJWLUp4vHFs5LAxQ3UYcR9C3e1lxkwktHiIXKAiBJAcisC6hB7EZruh/WiMTzIdcNwYbBjbU/U1yHfbElzA==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":52863},"main":"./build/index.js","types":"./build/index.d.ts","module":"./build/index.mjs","gitHead":"f3a8105b84805bd5f1b3169b698b14057a152a48","scripts":{"test":"pnpm vitest run","build":"rm -rf build && tsup","prepare":"pnpm run build","test:dev":"pnpm vitest","build:dev":"rm -rf build && tsup --watch","typecheck":"tsc --noEmit"},"_npmUser":{"name":"chriskvl","email":"covali.christian@gmail.com"},"_npmVersion":"10.5.2","description":"![](https://framerusercontent.com/images/LMkkyrT6aZKMqZNobSZKDY8lnM.jpg)","directories":{},"_nodeVersion":"20.13.1","dependencies":{"bs58":"^5.0.0","buffer":"^6.0.0"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^6.6.3","eslint":"8.35.0","vitest":"^1.4.0","ts-node":"^10.9.1","typescript":"4.9.5","@blowfish/tsconfig":"workspace:*","@typescript-eslint/parser":"^5.54.0","@typescript-eslint/eslint-plugin":"^5.54.0"},"peerDependencies":{"@solana/web3.js":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/safeguard_1.0.0_1719829432443_0.9751426304043092","host":"s3://npm-registry-packages"}},"2.0.0":{"name":"@blowfishxyz/safeguard","version":"2.0.0","description":"![](https://framerusercontent.com/images/LMkkyrT6aZKMqZNobSZKDY8lnM.jpg)","main":"./build/index.js","module":"./build/index.mjs","dependencies":{"bs58":"^5.0.0","buffer":"^6.0.0"},"peerDependencies":{"@solana/web3.js":"^1.0.0"},"devDependencies":{"@typescript-eslint/eslint-plugin":"^5.54.0","@typescript-eslint/parser":"^5.54.0","eslint":"8.35.0","ts-node":"^10.9.1","tsup":"^6.6.3","typescript":"4.9.5","vitest":"^1.4.0","@blowfish/tsconfig":"0.0.1"},"keywords":[],"author":"","license":"ISC","scripts":{"build":"rm -rf build && tsup","build:dev":"rm -rf build && tsup --watch","typecheck":"tsc --noEmit","test":"pnpm vitest run","test:dev":"pnpm vitest"},"types":"./build/index.d.ts","_id":"@blowfishxyz/safeguard@2.0.0","_integrity":"sha512-3i8tU2cJmiG401rFq84ZYFtZA2Hvk/xFvuIZsoy5/d5REmrCm2qLi00/wB95B8nyYF6PwNpR4P3noyCpRn1eLQ==","_resolved":"/private/var/folders/22/kg7rkhfj4js02wwjfpzzvd_c0000gn/T/a255311c49b292db7b97c3a3a14b05ba/blowfishxyz-safeguard-2.0.0.tgz","_from":"file:blowfishxyz-safeguard-2.0.0.tgz","_nodeVersion":"20.13.1","_npmVersion":"10.5.2","dist":{"integrity":"sha512-3i8tU2cJmiG401rFq84ZYFtZA2Hvk/xFvuIZsoy5/d5REmrCm2qLi00/wB95B8nyYF6PwNpR4P3noyCpRn1eLQ==","shasum":"e0d1feb5db954ff1e0c371db7c5d5b0e48419404","tarball":"https://registry.npmjs.org/@blowfishxyz/safeguard/-/safeguard-2.0.0.tgz","fileCount":14,"unpackedSize":68260,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHsLOemrbgJKPYa1QgQxn3R+bb8OFuXMuxGmqD1A0vqvAiEAuqW8K0Pz1J/ODKGyK4yzNsG5Zvb1WDKG4C0hdU7l5Ew="}]},"_npmUser":{"name":"chriskvl","email":"covali.christian@gmail.com"},"directories":{},"maintainers":[{"name":"chriskvl","email":"covali.christian@gmail.com"},{"name":"metreniuk","email":"metreniuk@gmail.com"},{"name":"kimpers","email":"hi@kimpers.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/safeguard_2.0.0_1720771672836_0.7634992065815513"},"_hasShrinkwrap":false}},"time":{"created":"2024-07-01T10:23:52.318Z","modified":"2024-07-12T08:07:53.244Z","1.0.0":"2024-07-01T10:23:52.589Z","2.0.0":"2024-07-12T08:07:52.982Z"},"license":"ISC","keywords":[],"description":"![](https://framerusercontent.com/images/LMkkyrT6aZKMqZNobSZKDY8lnM.jpg)","maintainers":[{"name":"chriskvl","email":"covali.christian@gmail.com"},{"name":"metreniuk","email":"metreniuk@gmail.com"},{"name":"kimpers","email":"hi@kimpers.com"}],"readme":"![](https://framerusercontent.com/images/LMkkyrT6aZKMqZNobSZKDY8lnM.jpg)\n\n# Blowfish Safeguard Transaction Verification\n\nThis package provides functionality to verify Solana transactions against Blowfish Safeguard generated transactions. \nIt is used to ensure that the original transaction is not tampered with and that the safeguard transaction meets the criteria defined in the configuration.\n\n## Table of Contents\n\n- [Installation](#installation)\n- [Usage](#usage)\n- [Configuration](#configuration)\n- [API](#api)\n    - [verifyTransaction](#verifytransaction)\n- [Errors](#errors)\n- [Contributing](#contributing)\n\n## Installation\n\nTo install this package run one of the following commands:\n\n```bash\nnpm install @blowfishxyz/safeguard\n# or\nyarn add @blowfishxyz/safeguard\n# or\npnpm add @blowfishxyz/safeguard\n```\n\n## Usage\n\n```javascript\nimport { verifyTransactions } from '@blowfishxyz/safeguard';\n\nconst originalTxs = ['...'];  // Base58 or Base64 encoded original transactions\nconst safeGuardTx = ['...']; // Base58 or Base64 encoded safeguard transactions\nconst solUsdRate = 137.5;   // Current SOL to USD rate\n\nconst options = {\n  solUsdRate,\n  // Other optional configuration overrides can be specified here\n};\n\ntry {\n  verifyTransactions(originalTxs, safeGuardTxs, options);\n  console.log('Transaction verification succeeded.');\n} catch (error) {\n  console.error('Transaction verification failed:', error.message);\n}\n```\n\n## Configuration\n\nThe `VerifyConfig` type defines the configuration used to verify safeguard transaction against the original one.\n\n```typescript\nexport type VerifyConfig = {\n  lightHouseIds: string[]; // Lighthouse program ids\n  blowfishServiceFeeAccount: string; // Blowfish service fee account\n  blowfishFeeInUsd: number; // Expected Blowfish service fee in USD\n  solUsdRate: number; // Current SOL/USD rate\n  feeSlippage: number; // Fee slippage in percentage\n};\n```\n\n### Default Configuration\n\nThe default configuration values are:\n\n```javascript\nconst DEFAULT_CONFIG = {\n  blowfishFeeInUsd: 0.01, // 1 cent\n  blowfishServiceFeeAccount: \"EPr6e66NYBKrP3u688U2VHmxdviUAV7FeRFWqfqZD9So\",\n  feeSlippage: 0.1, // 10%\n  lightHouseIds: [\n    \"L1TEVtgA75k273wWz1s6XMmDhQY5i3MwcvKb4VbZzfK\", \n    \"L2TExMFKdjpN9kozasaurPirfHy9P8sbXoAN1qA3S95\",\n  ],\n};\n```\n\n## API\n\n### verifyTransaction\n\nVerifies that a transaction meets the criteria defined in the configuration.\n\n```typescript\nfunction verifyTransactions(\n  originalTxsB58orB64: string[],\n  safeGuardTxsB58orB64: string[],\n  options: VerifyTransactionOptions\n): void\n```\n\n- `originalTxsB58orB64`: Array of original transactions in Base58 or Base64 encoding.\n- `safeGuardTxsB58orB64`: Array of Safeguarded transactions in Base58 or Base64 encoding.\n- `options`: Optional configuration overrides.\n\n### Errors\n\nThe function throws specific errors to indicate different types of verification failures:\n\n- `INSTRUCTION_MISSMATCH`: Instructions do not match the initial transaction.\n- `UNKNOWN_PROGRAM_INTERACTION`: Instruction is attempting to interact with an unknown program.\n- `MISSING_BLOWFISH_FEE`: Instructions are missing Blowfish service fee.\n- `MISSING_LIGHTHOUSE_PROGRAM_CALL`: Instructions are missing Lighthouse program call.\n- `FEE_MISMATCH`: Fee does not match the expected Blowfish service fee.\n\n## Contributing\n\nContributions are welcome! Please open an issue or submit a pull request on GitHub.\n","readmeFilename":"README.md"}