{"_id":"@aifinpay/gate","_rev":"10-9630553dc482a3167892cca2261d2d22","name":"@aifinpay/gate","dist-tags":{"latest":"0.3.0"},"versions":{"0.1.0":{"name":"@aifinpay/gate","version":"0.1.0","keywords":["aifinpay","ai-agent","ai-agents","ai-payments","agent-payments","agent-economy","x402","http-402","402-middleware","paywall","api-paywall","express-middleware","api-monetization","paid-apis","machine-payments","m2m-payments","usdc","stablecoin-payments","fintech","stripe-for-ai-agents"],"author":{"url":"SECCO","name":"CoinSecurities","email":"contact@aifinpay.io"},"license":"MIT","_id":"@aifinpay/gate@0.1.0","maintainers":[{"name":"aifinpay","email":"aifinpaycompany@gmail.com"}],"homepage":"https://github.com/AiFinPay/sdk#readme","bugs":{"url":"https://github.com/AiFinPay/sdk/issues"},"dist":{"shasum":"976cf45b36acf009f62fa01681b9a31906f4a689","tarball":"https://registry.npmjs.org/@aifinpay/gate/-/gate-0.1.0.tgz","fileCount":71,"integrity":"sha512-adNq/B9LsT7wFUiKbg1eaio7I8fZzcPj46e7kLmwVC/a2dDUi1R6MgXhVVllG69p5+SICzwrw5cyFpmWgj5KjQ==","signatures":[{"sig":"MEUCIQD+16M4+iaXSjEy96mhuIz4maLtbXkt93UF9YodachcQgIgf/IpVCgruN38S4dMHB4T3Y7f692AreIvslORl8ibKwA=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":158533},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","engines":{"node":">=18"},"exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"./stores":{"types":"./dist/stores/index.d.ts","default":"./dist/stores/index.js"},"./express":{"types":"./dist/express.d.ts","default":"./dist/express.js"},"./testing":{"types":"./dist/testing.d.ts","default":"./dist/testing.js"}},"gitHead":"eb2898d9944f5342241f2e9a745d0d608d28baa1","scripts":{"test":"vitest run","build":"tsc -p tsconfig.json","prepublishOnly":"npm run build"},"_npmUser":{"name":"aifinpay","email":"aifinpaycompany@gmail.com"},"repository":{"url":"git+https://github.com/AiFinPay/sdk.git","type":"git","directory":"gate"},"_npmVersion":"11.4.0","description":"Merchant-side AIFP-1 paywall for your own API — 402 challenge, local receipt verification, billing-unit quota metering.","directories":{},"_nodeVersion":"24.0.2","dependencies":{"jose":"^6.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^4.1.5","express":"^5.2.1","express4":"npm:express@^4.18.0","typescript":"^5.4.0","@types/node":"^20.0.0","@types/express":"^5.0.0"},"peerDependencies":{"express":"^4.18.0 || ^5.0.0"},"peerDependenciesMeta":{"express":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/gate_0.1.0_1787244523989_0.29513443209624524","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@aifinpay/gate","version":"0.1.1","keywords":["aifinpay","ai-agent","ai-agents","ai-payments","agent-payments","agent-economy","x402","http-402","402-middleware","paywall","api-paywall","express-middleware","api-monetization","paid-apis","machine-payments","m2m-payments","usdc","stablecoin-payments","fintech","stripe-for-ai-agents"],"author":{"url":"SECCO","name":"CoinSecurities","email":"contact@aifinpay.io"},"license":"MIT","_id":"@aifinpay/gate@0.1.1","maintainers":[{"name":"aifinpay","email":"aifinpaycompany@gmail.com"}],"homepage":"https://github.com/AiFinPay/sdk#readme","bugs":{"url":"https://github.com/AiFinPay/sdk/issues"},"dist":{"shasum":"6c5a46fc378bf28a182d2e1add026d3f545a70d6","tarball":"https://registry.npmjs.org/@aifinpay/gate/-/gate-0.1.1.tgz","fileCount":71,"integrity":"sha512-VeEKehKTS6Qxm71a4JOZFZXEZiFEayDGl3+2HW9tTgEHi4FYtYYU+/5fM6sCBGGv4lXOOUJ+Gr9gxcnrdamUEw==","signatures":[{"sig":"MEQCIBjDuboMN4438EXBQ/e+8lPPAiKCkmdqN2n6vIenXBTCAiBSGQygttDLf+9qBXXkaA4xFqClsa6bfOIjw7wwv/2Mfw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":165166},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","engines":{"node":">=18"},"exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"./stores":{"types":"./dist/stores/index.d.ts","default":"./dist/stores/index.js"},"./express":{"types":"./dist/express.d.ts","default":"./dist/express.js"},"./testing":{"types":"./dist/testing.d.ts","default":"./dist/testing.js"}},"gitHead":"e4c3a00194f22af87b883a2cb86da2090b5a1c7c","scripts":{"test":"vitest run","build":"tsc -p tsconfig.json","prepublishOnly":"npm run build"},"_npmUser":{"name":"aifinpay","email":"aifinpaycompany@gmail.com"},"repository":{"url":"git+https://github.com/AiFinPay/sdk.git","type":"git","directory":"gate"},"_npmVersion":"11.4.0","description":"Merchant-side AIFP-1 paywall for your own API — 402 challenge, local receipt verification, billing-unit quota metering.","directories":{},"_nodeVersion":"24.0.2","dependencies":{"jose":"^6.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^4.1.5","express":"^5.2.1","express4":"npm:express@^4.18.0","typescript":"^5.4.0","@types/node":"^20.0.0","@types/express":"^5.0.0"},"peerDependencies":{"express":"^4.18.0 || ^5.0.0"},"peerDependenciesMeta":{"express":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/gate_0.1.1_1787248169491_0.1117427939890332","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"name":"@aifinpay/gate","version":"0.2.0","keywords":["aifinpay","ai-agent","ai-agents","ai-payments","agent-payments","agent-economy","x402","http-402","402-middleware","paywall","api-paywall","express-middleware","api-monetization","paid-apis","machine-payments","m2m-payments","usdc","stablecoin-payments","fintech","stripe-for-ai-agents"],"author":{"url":"SECCO","name":"CoinSecurities","email":"contact@aifinpay.io"},"license":"MIT","_id":"@aifinpay/gate@0.2.0","maintainers":[{"name":"aifinpay","email":"aifinpaycompany@gmail.com"}],"homepage":"https://github.com/AiFinPay/sdk#readme","bugs":{"url":"https://github.com/AiFinPay/sdk/issues"},"dist":{"shasum":"a65b691c825611c80b998d051bd50e4f68834206","tarball":"https://registry.npmjs.org/@aifinpay/gate/-/gate-0.2.0.tgz","fileCount":75,"integrity":"sha512-gbZQQi3SDdvXQt/JqXhk9j3VKUx7SNlYsPzCCMO6Tpbei30Yhr3lWI27qr59JOyZrKqV2wOX3oXu8mrPjiDWkw==","signatures":[{"sig":"MEYCIQCxU8r23BoskLCcsQ6A7jbv4uFr/z0BZiwWzI57xIztDAIhAM7SFJu3BnMdUzEvkcnNNU7UfJiYtWmh+KZ6b3Hii7FD","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":177302},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","engines":{"node":">=18"},"exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"./stores":{"types":"./dist/stores/index.d.ts","default":"./dist/stores/index.js"},"./express":{"types":"./dist/express.d.ts","default":"./dist/express.js"},"./testing":{"types":"./dist/testing.d.ts","default":"./dist/testing.js"}},"gitHead":"2906491b80578626b925f08f93f29767b700a93e","scripts":{"test":"vitest run","build":"tsc -p tsconfig.json","prepublishOnly":"npm run build"},"_npmUser":{"name":"aifinpay","email":"aifinpaycompany@gmail.com"},"repository":{"url":"git+https://github.com/AiFinPay/sdk.git","type":"git","directory":"gate"},"_npmVersion":"11.4.0","description":"Merchant-side AIFP-1 paywall for your own API — 402 challenge, local receipt verification, billing-unit quota metering.","directories":{},"_nodeVersion":"24.0.2","dependencies":{"jose":"^6.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^4.1.5","express":"^5.2.1","express4":"npm:express@^4.18.0","typescript":"^5.4.0","@types/node":"^20.0.0","@types/express":"^5.0.0"},"peerDependencies":{"express":"^4.18.0 || ^5.0.0"},"peerDependenciesMeta":{"express":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/gate_0.2.0_1787273665321_0.2270993662740144","host":"s3://npm-registry-packages-npm-production"}},"0.2.1":{"name":"@aifinpay/gate","version":"0.2.1","keywords":["aifinpay","ai-agent","ai-agents","ai-payments","agent-payments","agent-economy","x402","http-402","402-middleware","paywall","api-paywall","express-middleware","api-monetization","paid-apis","machine-payments","m2m-payments","usdc","stablecoin-payments","fintech","stripe-for-ai-agents"],"author":{"url":"SECCO","name":"CoinSecurities","email":"contact@aifinpay.io"},"license":"MIT","_id":"@aifinpay/gate@0.2.1","maintainers":[{"name":"aifinpay","email":"aifinpaycompany@gmail.com"}],"homepage":"https://github.com/AiFinPay/sdk#readme","bugs":{"url":"https://github.com/AiFinPay/sdk/issues"},"dist":{"shasum":"213a314ee8abc38e0b6987e57f53f619b5e0af61","tarball":"https://registry.npmjs.org/@aifinpay/gate/-/gate-0.2.1.tgz","fileCount":75,"integrity":"sha512-NcxiWr795V5Izwp4QZbtDkfP2JtVVho3XfRiwPFKP9IXxEk7w4RNXzi8cSJunHpOW93AYXAf8hwcGAlEUMsf6Q==","signatures":[{"sig":"MEUCIQC/jnXQAqCRSZ5NQcBPRo0eK8YIItRKl26ATGWho+CiBgIgcHrxQIKVwSEA0t7TM0fbq8wpnLZt+iE/7OgJRTUnYB4=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":178052},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","engines":{"node":">=18"},"exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"./stores":{"types":"./dist/stores/index.d.ts","default":"./dist/stores/index.js"},"./express":{"types":"./dist/express.d.ts","default":"./dist/express.js"},"./testing":{"types":"./dist/testing.d.ts","default":"./dist/testing.js"}},"gitHead":"ec7dfa60b4c36b408c125d69dfece6ceb54489f2","scripts":{"test":"vitest run","build":"tsc -p tsconfig.json","prepublishOnly":"npm run build"},"_npmUser":{"name":"aifinpay","email":"aifinpaycompany@gmail.com"},"repository":{"url":"git+https://github.com/AiFinPay/sdk.git","type":"git","directory":"gate"},"_npmVersion":"11.4.0","description":"Merchant-side AIFP-1 paywall for your own API — 402 challenge, local receipt verification, billing-unit quota metering.","directories":{},"_nodeVersion":"24.0.2","dependencies":{"jose":"^6.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^4.1.5","express":"^5.2.1","express4":"npm:express@^4.18.0","typescript":"^5.4.0","@types/node":"^20.0.0","@types/express":"^5.0.0"},"peerDependencies":{"express":"^4.18.0 || ^5.0.0"},"peerDependenciesMeta":{"express":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/gate_0.2.1_1787330049953_0.7871976099952032","host":"s3://npm-registry-packages-npm-production"}},"0.2.2":{"name":"@aifinpay/gate","version":"0.2.2","keywords":["aifinpay","ai-agent","ai-agents","ai-payments","agent-payments","agent-economy","x402","http-402","402-middleware","paywall","api-paywall","express-middleware","api-monetization","paid-apis","machine-payments","m2m-payments","usdc","stablecoin-payments","fintech","stripe-for-ai-agents"],"author":{"url":"SECCO","name":"CoinSecurities","email":"contact@aifinpay.io"},"license":"MIT","_id":"@aifinpay/gate@0.2.2","maintainers":[{"name":"aifinpay","email":"aifinpaycompany@gmail.com"}],"homepage":"https://github.com/AiFinPay/sdk#readme","bugs":{"url":"https://github.com/AiFinPay/sdk/issues"},"dist":{"shasum":"210b7d27167a7fdc3eef0e8747555705ab7a3d37","tarball":"https://registry.npmjs.org/@aifinpay/gate/-/gate-0.2.2.tgz","fileCount":75,"integrity":"sha512-ebpNYDhJ++QVq53u3My8Kf+pByfUR9/wLUguQZ9IqX179dE27+HQLjdkXO2pftzOjxiUb6TLUJ7ARdPuDCATCA==","signatures":[{"sig":"MEYCIQDEBHCkdjQU+bvN6SVnkNtgI802uGajz2z7aDTNx1oeqwIhAKtgd2VXZqLP+Zv1TN+hXtomx61UtIT0AA+IqPp7lzzP","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":179948},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","engines":{"node":">=18"},"exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"./stores":{"types":"./dist/stores/index.d.ts","default":"./dist/stores/index.js"},"./express":{"types":"./dist/express.d.ts","default":"./dist/express.js"},"./testing":{"types":"./dist/testing.d.ts","default":"./dist/testing.js"}},"gitHead":"bf0ebc3a9402e68dba32c95e47b21aef6dad37e4","scripts":{"test":"vitest run","build":"tsc -p tsconfig.json","prepublishOnly":"npm run build"},"_npmUser":{"name":"aifinpay","email":"aifinpaycompany@gmail.com"},"repository":{"url":"git+https://github.com/AiFinPay/sdk.git","type":"git","directory":"gate"},"_npmVersion":"11.4.0","description":"Merchant-side AIFP-1 paywall for your own API — 402 challenge, local receipt verification, billing-unit quota metering.","directories":{},"_nodeVersion":"24.0.2","dependencies":{"jose":"^6.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^4.1.5","express":"^5.2.1","express4":"npm:express@^4.18.0","typescript":"^5.4.0","@types/node":"^20.0.0","@types/express":"^5.0.0"},"peerDependencies":{"express":"^4.18.0 || ^5.0.0"},"peerDependenciesMeta":{"express":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/gate_0.2.2_1787569451981_0.5928644765686868","host":"s3://npm-registry-packages-npm-production"}},"0.2.3":{"name":"@aifinpay/gate","version":"0.2.3","keywords":["aifinpay","ai-agent","ai-agents","ai-payments","agent-payments","agent-economy","x402","http-402","402-middleware","paywall","api-paywall","express-middleware","api-monetization","paid-apis","machine-payments","m2m-payments","usdc","stablecoin-payments","fintech","stripe-for-ai-agents"],"author":{"url":"SECCO","name":"CoinSecurities","email":"contact@aifinpay.io"},"license":"MIT","_id":"@aifinpay/gate@0.2.3","maintainers":[{"name":"aifinpay","email":"aifinpaycompany@gmail.com"}],"homepage":"https://github.com/AiFinPay/sdk#readme","bugs":{"url":"https://github.com/AiFinPay/sdk/issues"},"dist":{"shasum":"5c60ed224a6b50c8e5c194e5da0d924ee798a12f","tarball":"https://registry.npmjs.org/@aifinpay/gate/-/gate-0.2.3.tgz","fileCount":75,"integrity":"sha512-cbKWeYTjWC5mWu5wvdxDm5XC6/rhEwOEM9cbbrGyzJ+sHL+E2lsMj45fmLkMTv4aWeJWfCwOyzDeuFHXbKc4tw==","signatures":[{"sig":"MEQCIGSnAx4J/bDnztgQNE66r2iG/AhdKfdWMJbvaEtm2yogAiA3KRJ4VYk4KNWOkCyuzJdTKwBPpDkozC+cjqdINPJzwg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":188566},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","engines":{"node":">=18"},"exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"./stores":{"types":"./dist/stores/index.d.ts","default":"./dist/stores/index.js"},"./express":{"types":"./dist/express.d.ts","default":"./dist/express.js"},"./testing":{"types":"./dist/testing.d.ts","default":"./dist/testing.js"}},"gitHead":"e5db52b6eb3002d8dc273bcb4104831bfefedbf4","scripts":{"test":"vitest run","build":"tsc -p tsconfig.json","prepublishOnly":"npm run build"},"_npmUser":{"name":"aifinpay","email":"aifinpaycompany@gmail.com"},"repository":{"url":"git+https://github.com/AiFinPay/sdk.git","type":"git","directory":"gate"},"_npmVersion":"11.4.0","description":"Merchant-side AIFP-1 paywall for your own API — 402 challenge, local receipt verification, billing-unit quota metering.","directories":{},"_nodeVersion":"24.0.2","dependencies":{"jose":"^6.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^4.1.5","express":"^5.2.1","express4":"npm:express@^4.18.0","typescript":"^5.4.0","@types/node":"^20.0.0","@types/express":"^5.0.0"},"peerDependencies":{"express":"^4.18.0 || ^5.0.0"},"peerDependenciesMeta":{"express":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/gate_0.2.3_1788347076267_0.5963924548007573","host":"s3://npm-registry-packages-npm-production"}},"0.2.4":{"name":"@aifinpay/gate","version":"0.2.4","keywords":["aifinpay","ai-agent","ai-agents","ai-payments","agent-payments","agent-economy","x402","http-402","402-middleware","paywall","api-paywall","express-middleware","api-monetization","paid-apis","machine-payments","m2m-payments","usdc","stablecoin-payments","fintech","stripe-for-ai-agents"],"author":{"url":"SECCO","name":"CoinSecurities","email":"contact@aifinpay.io"},"license":"MIT","_id":"@aifinpay/gate@0.2.4","maintainers":[{"name":"aifinpay","email":"aifinpaycompany@gmail.com"}],"homepage":"https://github.com/AiFinPay/sdk#readme","bugs":{"url":"https://github.com/AiFinPay/sdk/issues"},"dist":{"shasum":"608d78d05e8ef962da5abaa077a12c7346735718","tarball":"https://registry.npmjs.org/@aifinpay/gate/-/gate-0.2.4.tgz","fileCount":75,"integrity":"sha512-FBCFtZoLAGG9bdxhiu1j8Ftuoxe1dqV5NHyE+PCBC0f7q5aWTSTi+1B1A9DIgq1T1VrPgXuooD0Agvjc2nbe7A==","signatures":[{"sig":"MEUCIAQJ4uYCRPndbt/4Wzj/x7/PtHj9LqRDEtRpona4ChGPAiEA8vBxn6lWd3z94Bs2h2FaeNlfBA2U6q/VJ3+A1w2V9MM=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":189766},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","engines":{"node":">=18"},"exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"./stores":{"types":"./dist/stores/index.d.ts","default":"./dist/stores/index.js"},"./express":{"types":"./dist/express.d.ts","default":"./dist/express.js"},"./testing":{"types":"./dist/testing.d.ts","default":"./dist/testing.js"}},"gitHead":"145710ca4241d7881cbb321be2bb30a5903775b8","scripts":{"test":"vitest run","build":"tsc -p tsconfig.json","prepublishOnly":"npm run build"},"_npmUser":{"name":"aifinpay","email":"aifinpaycompany@gmail.com"},"repository":{"url":"git+https://github.com/AiFinPay/sdk.git","type":"git","directory":"gate"},"_npmVersion":"11.4.0","description":"Merchant-side AIFP-1 paywall for your own API — 402 challenge, local receipt verification, billing-unit quota metering.","directories":{},"_nodeVersion":"24.0.2","dependencies":{"jose":"^6.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^4.1.5","express":"^5.2.1","express4":"npm:express@^4.18.0","typescript":"^5.4.0","@types/node":"^20.0.0","@types/express":"^5.0.0"},"peerDependencies":{"express":"^4.18.0 || ^5.0.0"},"peerDependenciesMeta":{"express":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/gate_0.2.4_1788409592139_0.5262769339015527","host":"s3://npm-registry-packages-npm-production"}},"0.3.0":{"name":"@aifinpay/gate","version":"0.3.0","keywords":["aifinpay","ai-agent","ai-agents","ai-payments","agent-payments","agent-economy","x402","http-402","402-middleware","paywall","api-paywall","express-middleware","api-monetization","paid-apis","machine-payments","m2m-payments","usdc","stablecoin-payments","fintech","stripe-for-ai-agents"],"author":{"url":"SECCO","name":"CoinSecurities","email":"contact@aifinpay.io"},"license":"MIT","_id":"@aifinpay/gate@0.3.0","maintainers":[{"name":"aifinpay","email":"aifinpaycompany@gmail.com"}],"homepage":"https://github.com/AiFinPay/sdk#readme","bugs":{"url":"https://github.com/AiFinPay/sdk/issues"},"dist":{"shasum":"465518953fa6ae9d9f9709e1dd3376cf981667a9","tarball":"https://registry.npmjs.org/@aifinpay/gate/-/gate-0.3.0.tgz","fileCount":79,"integrity":"sha512-wzcqw2kxEmBAestghRO27/ZqcORggOXenQQDoeW8xuh8NIGVwsMbTwm6FafU+wL5+HtN9xGFkr8D4aOBaTF+RA==","signatures":[{"sig":"MEUCIQCerky+sqf3Xb2RkY5vxJgyUPK2w5et25CEma/yd/rfjQIgBblYHWfaRtkQpt6L7KP2gnOvXaDxWQVc5J6zEMQDkB8=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":196508},"main":"dist/index.js","type":"module","types":"dist/index.d.ts","engines":{"node":">=18"},"exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"./stores":{"types":"./dist/stores/index.d.ts","default":"./dist/stores/index.js"},"./express":{"types":"./dist/express.d.ts","default":"./dist/express.js"},"./testing":{"types":"./dist/testing.d.ts","default":"./dist/testing.js"}},"gitHead":"cd32f821f1b05994b7708fb58d7f6b0ccfa86108","scripts":{"test":"vitest run","build":"tsc -p tsconfig.json","prepublishOnly":"npm run build"},"_npmUser":{"name":"aifinpay","email":"aifinpaycompany@gmail.com"},"repository":{"url":"git+https://github.com/AiFinPay/sdk.git","type":"git","directory":"gate"},"_npmVersion":"11.4.0","description":"Merchant-side AIFP-1 paywall for your own API — 402 challenge, local receipt verification, billing-unit quota metering.","directories":{},"_nodeVersion":"24.0.2","dependencies":{"jose":"^6.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^4.1.5","express":"^5.2.1","express4":"npm:express@^4.18.0","typescript":"^5.4.0","@types/node":"^20.0.0","@types/express":"^5.0.0"},"peerDependencies":{"express":"^4.18.0 || ^5.0.0"},"peerDependenciesMeta":{"express":{"optional":true}},"_npmOperationalInternal":{"tmp":"tmp/gate_0.3.0_1788527264989_0.08452793343673726","host":"s3://npm-registry-packages-npm-production"}}},"time":{"created":"2026-08-20T16:48:43.843Z","modified":"2026-09-16T09:05:38.846Z","0.1.0":"2026-08-20T16:48:44.180Z","0.1.1":"2026-08-20T17:49:29.666Z","0.2.0":"2026-08-21T00:54:25.479Z","0.2.1":"2026-08-21T16:34:10.112Z","0.2.2":"2026-08-24T11:04:12.140Z","0.2.3":"2026-09-02T11:04:36.417Z","0.2.4":"2026-09-03T04:26:32.279Z","0.3.0":"2026-09-04T13:07:45.122Z"},"bugs":{"url":"https://github.com/AiFinPay/sdk/issues"},"author":{"url":"SECCO","name":"CoinSecurities","email":"contact@aifinpay.io"},"license":"MIT","homepage":"https://github.com/AiFinPay/sdk#readme","keywords":["aifinpay","ai-agent","ai-agents","ai-payments","agent-payments","agent-economy","x402","http-402","402-middleware","paywall","api-paywall","express-middleware","api-monetization","paid-apis","machine-payments","m2m-payments","usdc","stablecoin-payments","fintech","stripe-for-ai-agents"],"repository":{"url":"git+https://github.com/AiFinPay/sdk.git","type":"git","directory":"gate"},"description":"Merchant-side AIFP-1 paywall for your own API — 402 challenge, local receipt verification, billing-unit quota metering.","maintainers":[{"email":"aifinpaycompany@gmail.com","name":"enot3615"},{"email":"paul.bolhar@gmail.com","name":"daochild"}],"readme":"# @aifinpay/gate\n\nPut your own API behind AIFP-1, in your own process. No proxy, no traffic\nthrough us, no round-trip per request.\n\nAn AI agent calls your endpoint. It has no account with you and no API key. It\ngets a `402` that tells it exactly what the call costs and how to buy a batch,\npays on-chain from its own wallet, and retries with a signed receipt. Your gate\nverifies that receipt locally and counts the prepaid units down.\n\n```\nnpm install @aifinpay/gate\n```\n\nRequires Node 18+. Express is an optional peer (4 or 5); the core has no\nframework dependency at all.\n\n---\n\n## 1. Sixty seconds\n\n```js\nimport express from \"express\";\nimport { aifpGate } from \"@aifinpay/gate\";\n\nconst app = express();\n\napp.get(\"/api/search\", aifpGate({\n  merchantId: process.env.AIFP_MERCHANT_ID,   // \"mrch_…\"\n  resource: \"/api/search\",\n  tier: \"complex\",                             // standard | complex | premium\n}), (req, res) => {\n  res.json({ results: [], billed_units: req.aifp.weight });\n});\n\napp.listen(3000);\n```\n\nThat is a working paywall. Before you ship it, read §3 — the default quota\nstore is per-process, and that is the one thing in this package that quietly\ncosts money if you get it wrong.\n\n---\n\n## 1b. Next.js, and the two ways it silently earns you nothing\n\nNext.js runs middleware only on paths matched by `config.matcher`, and\n`aifpGate` charges every request unless you tell it not to. Both defaults are\nreasonable on their own and together they produce the two failure modes we see\nmost often in real integrations — each of which leaves the dashboard showing\n`paywall_enabled: true` while the truth is very different.\n\n```ts\n// middleware.ts\nimport { aifpGate, knownAiAgent } from \"@aifinpay/gate\";\n\nexport default aifpGate({\n  merchantId: process.env.AIFP_MERCHANT_ID,\n  registry,\n  shouldCharge: knownAiAgent,     // ← see below\n});\n\nexport const config = {\n  matcher: [\n    \"/api/:path*\",\n    // Every PAGE you registered has to be here too. A page resource that the\n    // matcher does not cover is never seen by the gate, and serves free.\n    \"/\",\n    \"/movies/:path*\",\n  ],\n};\n```\n\n**Without the matcher entry**, the middleware never runs on that path. The\nresource is registered, priced, and shown as enabled — and enforcement is zero.\nNothing reports this; the endpoint simply answers 200 forever.\n\n**Without `shouldCharge`**, every request is charged, including human visitors\nand Googlebot. On an API that is usually right — agents are the only callers.\nOn a **page** it is almost never right: you have put a 402 in front of your own\nreaders and your search ranking.\n\n`knownAiAgent` returns true for the self-identifying AI crawlers — GPTBot,\nClaudeBot, PerplexityBot, CCBot, Bytespider, Google-Extended and the rest — plus\nanything already speaking AIFP. A browser passes through free.\n\nExtend it rather than replacing it when you have your own signal:\n\n```ts\nshouldCharge: (req) => knownAiAgent(req) || myEdgeStampedAiHeader(req),\n```\n\nA predicate that **throws** charges the request. Of the two wrong answers a\nbroken detector can give, a 402 to one human is visible and recoverable; a\ncrawler served free is silent and permanent.\n\n### robots.txt decides whether any of this runs at all\n\n```\nUser-agent: *\nDisallow: /\n```\n\nA well-behaved AI crawler reads that and leaves — before it ever reaches your\npaywall. You cannot forbid a crawler and bill it at the same time; those are\nopposite instructions to the same client, and robots.txt is the one it reads\nfirst.\n\nIf you arrived here from \"block the AI scrapers\", this line is probably already\nin your site and it guarantees zero revenue. Monetising AI traffic means\n**stop blocking, start charging** — a business decision, not a config toggle.\n\n---\n\n## 2. Register your endpoints with your API key\n\nYour routes live in code and change in pull requests. Their prices should too.\n\n```js\nimport { AifpMerchant, ResourceRegistry, aifpGate } from \"@aifinpay/gate\";\n\n// reads AIFP_MERCHANT_ID and AIFP_MERCHANT_SECRET from the environment\nconst merchant = new AifpMerchant();\n\nawait merchant.ensureResources([\n  { route_pattern: \"/api/search\",    type: \"api\", tier: \"complex\" },\n  { route_pattern: \"/api/lookup/*\",  type: \"api\", tier: \"standard\" },\n  { route_pattern: \"/api/report\",    type: \"api\", tier: \"premium\", name: \"Generate report\" },\n  { route_pattern: \"/api/health\",    type: \"api\", paywall_enabled: false },\n]);\n\nconst registry = new ResourceRegistry({ merchant });\nregistry.start();                              // refreshes every 60s\n\napp.use(aifpGate({ merchantId: merchant.merchantId, registry }));\n```\n\n`ensureResources` is idempotent by `route_pattern`, so this belongs in your boot\nscript and is safe on every deploy. Re-running it converges instead of piling up\nduplicates — which matters, because two records for the same path with different\nweights would charge unpredictably.\n\n**These endpoints appear in your AiFinPay dashboard immediately.** Not through a\nsync job — there is nothing to sync. The SDK writes the same endpoint registry\nthe dashboard's Paywall Builder writes and the dashboard reads, so a route\nregistered from a deploy script and a route registered by clicking are the same\nrecord, in the same table, on the same Insights charts. Register from code,\ntune prices in the panel, or both.\n\nOne prerequisite: **the merchant must be linked to a dashboard account.** The\nsimplest path is to create the merchant in the dashboard, copy the secret from\nthere, and give it to the SDK. A merchant created purely over the API has no\nowner, and the panel will not show you what your key registered under it.\n\nThe rest of the management surface, for scripts and internal tooling:\n\n```js\nawait merchant.listResources();\nawait merchant.getResource(\"res_…\");\nawait merchant.createResource({ route_pattern: \"/api/new\", type: \"api\" });   // 409 if it exists\nawait merchant.updateResource(\"res_…\", { tier: \"premium\" });\nawait merchant.deleteResource(\"res_…\");\nawait merchant.merchant();                     // name, payout wallets — log this on boot so\nawait merchant.stats();                        //   you can see WHICH merchant you configured\nawait merchant.activity(50);\nawait merchant.setWebhook(\"https://you.example/aifp-webhook\");\n```\n\nErrors are typed, so a deploy script can tell a mistake from an outage:\n`AifpValidationError` (your input, with the server's own hint), `AifpAuthError`\n(wrong or rotated secret), `AifpConflictError` (duplicate `route_pattern`, and\nit carries the existing `resource_id`). The secret is stored non-enumerably and\nnever appears in an error message, a stack, or `JSON.stringify(merchant)`.\n\n---\n\n## 3. Choose a store\n\nThe gate meters a prepaid batch by counting billing units against the receipt.\nThe store is where that count lives, and it has exactly two rules:\n\n1. **`incrBy` is atomic and returns the value AFTER the add.** The gate never\n   reads a counter and writes it back — it adds the call's weight and compares\n   what comes back. That is what makes overspend arithmetically impossible under\n   concurrency: whichever request receives the value that crosses the limit is\n   the one refused, exactly once.\n2. **The TTL is set on the first write only.** The counter must expire *with*\n   the receipt. A counter that outlives its receipt refuses paid calls; one that\n   expires early makes the whole batch spendable a second time.\n\n**Default — `MemoryStore`.** Correct on one process, and only on one process.\nIt is genuinely atomic there (the read-add-write runs with no `await` in the\nmiddle, so the event loop serializes it), it is capped so a flood of receipt ids\ncannot exhaust memory, and it needs no infrastructure.\n\n> Its two hard limits: counters are lost on restart, and **every process gets\n> its own copy**. Under `pm2 -i 4`, `node:cluster`, or two pods behind a load\n> balancer, a 200-unit batch will serve up to 800 calls, and nothing in the\n> request path can detect it. If you run more than one process, use a shared\n> store.\n\n**Shared — `redisStore`.** Pass your own client; this package declares no redis\ndependency and will not touch your connection policy.\n\n```js\nimport Redis from \"ioredis\";\nimport { redisStore } from \"@aifinpay/gate\";\n\nconst store = redisStore(new Redis(process.env.REDIS_URL));\napp.use(aifpGate({ merchantId, registry, store }));\n```\n\nIt is one `EVAL` per call — increment and TTL in a single atomic script, and the\nscript repairs a counter that somehow lost its expiry. Redis errors **propagate**\nrather than falling back to local memory: a silent downgrade would reopen the\noverspend race the counter exists to close. `onStoreError` decides what happens\n(`\"closed\"` → `503`, the default; `\"open\"` → serve and flag), and whatever it\ndecides is visible.\n\n**Anything else.** DynamoDB, Postgres, Cloudflare KV — implement `incrBy` and\nprove it before it meters real money:\n\n```js\nimport { assertStoreContract } from \"@aifinpay/gate/testing\";\nawait assertStoreContract(() => myStore(), { equal: assert.equal, ok: assert.ok });\n```\n\nSix cases, each of which maps to a way a merchant loses revenue. Adapter\nskeletons for DynamoDB and Postgres are in the source of\n`@aifinpay/gate/stores`.\n\n---\n\n## 4. What the gate does per request\n\n| # | Condition | Answer |\n|---|---|---|\n| 1 | Resolve the resource and its weight — the registry record for this path, or the mount's `resource`/`tier`. An unregistered path stays **paywalled**, never free. | — |\n| 2 | The resource is registered with `paywall_enabled: false` | `200`, header `AIFP-Paywall: off`, no units spent |\n| 3 | No `AIFP-Receipt` header | `402` + the full challenge |\n| 4 | Receipt expired | `402` — `receipt expired — prepay a new batch` |\n| 4 | Bad signature, issuer, or audience | `403` — `receipt verification failed (signature/issuer/audience)` |\n| 4 | Our JWKS is unreachable and nothing is cached | `503 AIFP-503-METER` — fails **closed** |\n| 5 | Receipt is scoped to another path | `403` — names both the receipt's scope and the path |\n| 6 | Single-use receipt replayed | `403` — `receipt already spent (single-use)` |\n| 7 | `used + weight > unit_quota` | `402` — `quota exhausted — prepay the next batch` |\n| 8 | Otherwise | `200`, header `AIFP-Quota-Remaining`, `req.aifp` populated |\n\nVerification is local and stateless: an Ed25519 signature checked against our\npublished JWKS, in your process, pinned to `EdDSA`. Your latency never depends\non ours. Pass `jwks: { keys: [...] }` to remove even the JWKS fetch (at the cost\nof a redeploy when we rotate keys).\n\n**The 402 an agent sees:**\n\n```json\n{\n  \"error\": \"AIFP-402\",\n  \"detail\": \"Payment Required — prepay a batch of requests and retry with the AIFP-Receipt header\",\n  \"protocol\": \"AIFP-1\",\n  \"merchant_id\": \"mrch_acme\",\n  \"resource\": \"/api/search\",\n  \"tier\": \"complex\",\n  \"unit_weight\": 4,\n  \"unit_price_usd\": \"0.002\",\n  \"min_requests\": 50,\n  \"protocol_fee_bps\": 100,\n  \"no_minimum_fee\": true,\n  \"how_to_pay\": [\n    \"POST https://api.aifinpay.io/v1/quote {\\\"merchant_id\\\":\\\"mrch_acme\\\",\\\"resource\\\":\\\"/api/search\\\",\\\"tier\\\":\\\"complex\\\"}\",\n    \"settle the quoted batch on-chain from your own wallet (order_id = quote_id)\",\n    \"POST https://api.aifinpay.io/v1/pay {quote_id, chain, asset, tx_ref} -> quota receipt\",\n    \"retry this request with header: AIFP-Receipt: <receipt JWT>\"\n  ]\n}\n```\n\n**And what your handler gets on a paid call:**\n\n```js\nreq.aifp\n// { agent: \"agt_…\", receipt_id: \"rcpt_…\", resource: \"/api/search\",\n//   weight: 4, unit_quota: 200, used: 8, remaining: 192, mode: \"paid\" }\n```\n\n### Pricing\n\nThree fixed settings, per call. The displayed/quoted AIFP-1 price is the\n**gross amount paid by the agent**. AiFinPay receives **1% of that gross amount**\nand the merchant receives **99% of gross** before external network or settlement\ncosts. The 1% fee is **not added on top** of the displayed AIFP-1 price.\n\n| Tier | Gross price paid by agent | Merchant 99% | AiFinPay 1% | Billing units per call |\n|---|---:|---:|---:|---:|\n| `standard` | $0.0005 | $0.000495 | $0.000005 | 1 |\n| `complex` | $0.002 | $0.00198 | $0.00002 | 4 |\n| `premium` | $0.005 | $0.00495 | $0.00005 | 10 |\n\nAIFP-2/x402 is a separate route: the provider receives 100% of its\nprovider-defined price, while any AiFinPay AIFP-2 fee is payer-side/on-top. The\ncurrent AIFP-2 fee is 0%; a future non-zero fee requires a versioned AIFP-2\nsettlement profile and must not reduce the provider amount.\n\n> **During the migration (as of 2026-08-23).** The table above is the canonical\n> model and what the v1.3 settlement contract enforces on-chain. Polygon\n> *mainnet* still runs the previous splitter, whose immutable split is\n> 98.99/1.00/0.01, and the backend grosses the total up from the merchant\n> amount to match it — so today an AIFP-1 merchant is made whole and the agent\n> pays slightly more than the displayed price. When v1.3 is deployed to\n> mainnet, the displayed price becomes exactly what the agent pays and the\n> merchant nets 99% of it. If you are integrating now, that is the one number\n> that moves under you; nothing in this package's API changes with it.\n\nWeight is always price ÷ base price. That equality is what lets one prepaid\nbatch be spent across endpoints of different tiers and still drain at each\nendpoint's real rate. Override per route with `unit_weight` when a call is\ngenuinely more expensive than its tier.\n\n### Options worth knowing\n\n| Option | Default | Why you would change it |\n|---|---|---|\n| `store` | `MemoryStore` | Anything beyond one process. See §3. |\n| `registry` | — | Path-matched pricing from your registered endpoints. |\n| `onStoreError` | `\"closed\"` | `\"open\"` trades metering for availability, visibly. |\n| `onEvent` | — | `402` / `serve` / `403` / `meter_error` for your own metrics. |\n| `allow` | — | Your own veto, evaluated **before** any unit is metered, so a refused call costs the agent nothing. |\n| `jwks` | fetched | Pin the key set; removes all runtime network dependency on us. |\n| `requireAgentMatch` | `false` | Compares `AIFP-Agent-Id` to the receipt subject. Anti-accident, not anti-theft — the header is not authenticated. |\n| `refundOnError` | `false` | Give a unit back on a 5xx. Read the warning below first. |\n\n`refundOnError` fires after your response has already gone out. If the agent\nreceived a body, the refunded unit is a unit it got served for free — a slow\ndouble-spend. Enable it only when your upstream fails *before* doing any work,\nand understand that you are trading exact metering for generosity.\n\n---\n\n## 5. What this package does **not** do\n\n- **It does not hold money or keys.** No custody, no funds movement. Agents\n  settle on-chain to your own wallet; this package verifies a receipt and counts.\n- **It does not enforce merchant policies.** Free-unit allowances, per-agent\n  daily caps, blocklists and unlimited-access rules are evaluated by the hosted\n  AiFinPay gateway. A second implementation of a rule you edit in our dashboard\n  would be a second source of truth, and the two would disagree on the day it\n  mattered. Use `allow` for rules that are genuinely yours.\n- **Self-hosted traffic does not populate the panel's funnel, geo and AI-client\n  charts.** Those are written by the hosted gateway from traffic that passes\n  through it. Your registered endpoints still appear; the per-request analytics\n  do not. Use `onEvent` to feed your own metrics.\n- **It cannot bind a receipt to a caller.** A receipt is a bearer token. Anyone\n  who obtains the JWT can spend the batch. The honest guarantee is **bounded\n  loss**: a stolen receipt can spend at most the units the payer prepaid, and\n  the post-increment counter makes overspending impossible. It is not\n  non-repudiation, and `requireAgentMatch` does not make it so.\n\n---\n\n## Related\n\n- [`@aifinpay/agent`](https://www.npmjs.com/package/@aifinpay/agent) — the other\n  side: an SDK for the agent that pays your paywall.\n- [`@aifinpay/mcp`](https://www.npmjs.com/package/@aifinpay/mcp) — MCP server\n  for agents that pay through an MCP host.\n\nMIT © CoinSecurities (SECCO)\n","readmeFilename":"README.md"}