{"_id":"@atticplaygroup/pua","_rev":"2-d195df6ddce11f8772d4fb53c85d3d2f","name":"@atticplaygroup/pua","dist-tags":{"latest":"0.1.1"},"versions":{"0.1.0":{"name":"@atticplaygroup/pua","version":"0.1.0","keywords":[],"author":"","license":"Apache-2.0","_id":"@atticplaygroup/pua@0.1.0","maintainers":[{"name":"atticplaygroup","email":"atticplaygroup@morke.org"}],"dist":{"shasum":"61272e37bf135698c21158e7beb852b8060c3f34","tarball":"https://registry.npmjs.org/@atticplaygroup/pua/-/pua-0.1.0.tgz","fileCount":3,"integrity":"sha512-owsTUg7XGFQ79tF5mA09gIIa/qPc44//3AFPMdf3e+ls/88gjLQAyY+erCSO8IhHhsDEv7bYKz0mhCLC1HvS7Q==","signatures":[{"sig":"MEUCIDosABnxJ0gG+IoJDUOxrpRMkZdWmEHtA7UyxIWkEv+qAiEA/nHOQc12qWEXvURq6LKpBJpdlh0o7z/oOj0WuTiyMEE=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":16815},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"gitHead":"080bfb1f14b21fa0039367533915ecb046994c1d","scripts":{"dev":"tsup --watch","test":"vitest run","build":"tsup","test:watch":"vitest"},"_npmUser":{"name":"atticplaygroup","email":"atticplaygroup@morke.org"},"_npmVersion":"9.2.0","description":"Paid User Agent Library to control spending and choose parties in PAID services automatically","directories":{},"_nodeVersion":"18.20.4","dependencies":{"wkt":"link:@bufbuild/protobuf/wkt","dids":"^5.0.3","tslib":"^2.8.1","libp2p":"^2.9.0","codegenv2":"link:@bufbuild/protobuf/codegenv2","@helia/http":"^2.2.0","@helia/ipns":"^8.2.4","@mysten/sui":"^1.35.0","uint8arrays":"^5.1.0","multiformats":"^13.3.7","@helia/routers":"^3.1.3","@libp2p/crypto":"^5.1.7","@libp2p/webrtc":"^5.2.24","@libp2p/peer-id":"^5.1.8","kubo-rpc-client":"^5.2.0","@helia/interface":"^5.4.0","key-did-resolver":"^4.0.0","@libp2p/interface":"^2.10.5","@bufbuild/protobuf":"^2.8.0","@connectrpc/connect":"^2.1.0","@helia/block-brokers":"^4.2.3","@helia/verified-fetch":"^3.2.0","@connectrpc/connect-web":"^2.1.0","key-did-provider-ed25519":"^4.0.2","@ipshipyard/node-datachannel":"^0.26.6","@multiformats/multiaddr-to-uri":"^12.0.0"},"_hasShrinkwrap":false,"packageManager":"pnpm@10.12.4","devDependencies":{"tsup":"^8.5.0","jsdom":"^26.1.0","eslint":"^9.30.1","vitest":"^3.2.4","fastify":"^5.4.0","ts-node":"^10.9.2","@eslint/js":"^9.30.1","typescript":"^5.8.3","@types/node":"^24.4.0","@helia/unixfs":"^5.0.4","@eslint/eslintrc":"^3.3.1","eslint-config-prettier":"^10.1.5","@typescript-eslint/parser":"^8.36.0","@typescript-eslint/eslint-plugin":"^8.36.0","@helia/delegated-routing-v1-http-api-server":"^4.0.6"},"_npmOperationalInternal":{"tmp":"tmp/pua_0.1.0_1760789730142_0.31944384945781823","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@atticplaygroup/pua","version":"0.1.1","type":"module","description":"Paid User Agent Library to control spending and choose parties in PAID services automatically","main":"./dist/index.cjs","module":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"keywords":[],"author":"","license":"Apache-2.0","repository":{"type":"git","url":"git+https://github.com/atticplaygroup/pua.git"},"dependencies":{"@bufbuild/protobuf":"^2.8.0","@connectrpc/connect":"^2.1.0","@connectrpc/connect-web":"^2.1.0","@helia/block-brokers":"^4.2.3","@helia/http":"^2.2.0","@helia/interface":"^5.4.0","@helia/ipns":"^8.2.4","@helia/routers":"^3.1.3","@helia/verified-fetch":"^3.2.0","@ipshipyard/node-datachannel":"^0.26.6","@libp2p/crypto":"^5.1.7","@libp2p/interface":"^2.10.5","@libp2p/peer-id":"^5.1.8","@libp2p/webrtc":"^5.2.24","@multiformats/multiaddr-to-uri":"^12.0.0","@mysten/sui":"^1.35.0","codegenv2":"link:@bufbuild/protobuf/codegenv2","dids":"^5.0.3","key-did-provider-ed25519":"^4.0.2","key-did-resolver":"^4.0.0","kubo-rpc-client":"^5.2.0","libp2p":"^2.9.0","multiformats":"^13.3.7","tslib":"^2.8.1","uint8arrays":"^5.1.0","wkt":"link:@bufbuild/protobuf/wkt"},"devDependencies":{"@eslint/eslintrc":"^3.3.1","@eslint/js":"^9.30.1","@helia/delegated-routing-v1-http-api-server":"^4.0.6","@helia/unixfs":"^5.0.4","@types/node":"^24.4.0","@typescript-eslint/eslint-plugin":"^8.36.0","@typescript-eslint/parser":"^8.36.0","eslint":"^9.30.1","eslint-config-prettier":"^10.1.5","fastify":"^5.4.0","jsdom":"^26.1.0","ts-node":"^10.9.2","tsup":"^8.5.0","typescript":"^5.8.3","vitest":"^3.2.4"},"scripts":{"test":"vitest run","test:watch":"vitest","build":"tsup","dev":"tsup --watch"},"_id":"@atticplaygroup/pua@0.1.1","bugs":{"url":"https://github.com/atticplaygroup/pua/issues"},"homepage":"https://github.com/atticplaygroup/pua#readme","_integrity":"sha512-c5VMHSxWS+n9Jgq4eRyE1cvjQMpE/sr03E2nOtp2xZJRka+SAL8qUwla4FIRab/ixbt8zgKvEU9BzNsQQB1BzQ==","_resolved":"/tmp/242d9142e99df2c1622c15bdf15abbe7/atticplaygroup-pua-0.1.1.tgz","_from":"file:atticplaygroup-pua-0.1.1.tgz","_nodeVersion":"22.20.0","_npmVersion":"11.6.2","dist":{"integrity":"sha512-c5VMHSxWS+n9Jgq4eRyE1cvjQMpE/sr03E2nOtp2xZJRka+SAL8qUwla4FIRab/ixbt8zgKvEU9BzNsQQB1BzQ==","shasum":"5832b15477b2c59ec051fdd017c859523cf767ac","tarball":"https://registry.npmjs.org/@atticplaygroup/pua/-/pua-0.1.1.tgz","fileCount":9,"unpackedSize":603014,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@atticplaygroup%2fpua@0.1.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIDag3E2xG47HwY4DOqrJGBcOGreQ9qYWEJLYhNBwSWzlAiAYPywlxcydle9Onfy/8LDO+AaF2GsyVoqq6vgGLRdRjw=="}]},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:f84cfef7-b861-4e05-9815-a428b3089d22"}},"directories":{},"maintainers":[{"name":"atticplaygroup","email":"atticplaygroup@morke.org"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/pua_0.1.1_1760812497584_0.4296904129217085"},"_hasShrinkwrap":false}},"time":{"created":"2025-10-18T12:15:30.056Z","modified":"2025-10-18T18:34:58.203Z","0.1.0":"2025-10-18T12:15:30.363Z","0.1.1":"2025-10-18T18:34:57.790Z"},"license":"Apache-2.0","keywords":[],"description":"Paid User Agent Library to control spending and choose parties in PAID services automatically","maintainers":[{"name":"atticplaygroup","email":"atticplaygroup@morke.org"}],"readme":"# PUA - Paid User Agent\n\nThis is a library acting as a [Block Broker](https://www.npmjs.com/package/@helia/block-brokers)\nin [Helia](https://github.com/ipfs/helia).\nYou may use it with Helia's [Verified Fetch](https://github.com/ipfs/helia-verified-fetch)\nto get blocks from [Pkv](https://github.com/atticplaygroup/pkv) with these benefits:\n\n- Automatic exchange selection based on their reputation\n- Automatic service provider selection based on their prices and reputation\n- Automatic payment to those services\n\n> [!CAUTION]\n> The library is in active development. It does not guarantee a smart spending now.\n> You may unexpectedly spend a lot if you use mainnet tokens.\n> We will improve its spending on the way.\n\n## Usage\n\nInitialize it with mnemonics, which should already have money in it.\nIf not, please deposit from mainnet or get from faucet,\nwith some tools beyond the scope of this library,\nfor example a [Sui wallet](https://blog.sui.io/sui-wallets/).\n\nStoring mnemonics in browser can be dangerous but is acceptable for our usage.\nSee a discussion on this topic [here](https://github.com/atticplaygroup/prex/wiki/paid-service#permissionless).\n\n```typescript\nimport { pkvBlockBroker, PaymentEnvironment } from '@atticplaygroup/pua';\n\nconst pkvBlockBrokerInstance = pkvBlockBroker({\n  paymentEnvironment: PaymentEnvironment.DEVNET,\n  mnemonics:\n    'wild shiver source slam trouble talent fantasy depart sleep burger fit trumpet',\n});\n```\n\nThen create use Helia's verified fetch to fetch an IPFS file.\n\n```typescript\nimport type { VerifiedFetch } from '@helia/verified-fetch';\nimport { createVerifiedFetch } from '@helia/verified-fetch';\nimport { createHeliaHTTP } from '@helia/http';\nimport { delegatedHTTPRouting } from '@helia/routers';\n\nasync function initVerifiedFetch(): Promise<VerifiedFetch> {\n  // Delegated routing provider URL.\n  // It can be a public one run by 3rd parties like https://delegated-ipfs.dev\n  // It does not need to be the same as the storage provider.\n  // Helia will find a storage provider itself.\n  const PKV_URL = 'http://localhost:3000';\n  const helia = await createHeliaHTTP({\n    routers: [\n      delegatedHTTPRouting(PKV_URL, {\n        timeout: 1_000_000,\n      }),\n    ],\n    blockBrokers: [pkvBlockBrokerInstance],\n  });\n  return await createVerifiedFetch(helia);\n}\n\nasync function main() {\n  const vFetch = await initVerifiedFetch();\n  const response = await vFetch(\n    'ipfs://bafkreiepisknsjkso33wxxta5i7voiyzulfrghh2uryxyd5ptin7v5rbva',\n  );\n  const blob = await response.blob();\n  console.log(blob.bytes());\n}\n```\n\n## Tests\n\nCurrently tests require a setup written in bash script. Later we will write an e2e test purely in typescript.\n\nFirst prepare binaries in the `bin/` folder.\n\n```\nbin\n├── buf\n├── gateway\n├── pkv\n├── prex\n├── sql-migrate\n└── sui\n```\n\nGet `gateway`, `pkv` from `cmd/gateway/gateway.go` and `cmd/pkv/pkv.go`\nfrom the [Pkv](https://github.com/atticplaygroup/pkv) project,\nand `prex` from `main.go` of the [Prex](https://github.com/atticplaygroup/prex) project.\n\nGet `buf` by `go install github.com/bufbuild/buf/cmd/buf@latest`.\nAnd `sql-migrate` from `https://github.com/rubenv/sql-migrate`.\n\nYou don't need a local sui binary if you want to use devnet.\n\nThen run the tests:\n\n```bash\ncd scripts\nbash run-tests.sh\n```\n","readmeFilename":"README.md","homepage":"https://github.com/atticplaygroup/pua#readme","repository":{"type":"git","url":"git+https://github.com/atticplaygroup/pua.git"},"bugs":{"url":"https://github.com/atticplaygroup/pua/issues"}}