{"_id":"@durbin2022/durbin-app-webhook","_rev":"3-ced4c9b4d7d6d83b2e9b88100aebfc01","name":"@durbin2022/durbin-app-webhook","dist-tags":{"latest":"0.10.21"},"versions":{"0.10.19":{"name":"@durbin2022/durbin-app-webhook","version":"0.10.19","description":"Internal API used for Accounts-app mapping for @durbin2022 Apps","repository":{"type":"git","url":"git+https://github.com/TeamDurbin/durbin_app_webhook.git"},"license":"MIT","devDependencies":{"@types/cookie-parser":"^1.4.2","@types/express":"^4.17.9","@types/jsonwebtoken":"^8.5.0","@types/ms":"^0.7.31","@types/node":"^8.0.29","ts-node":"3.3.0","typescript":"3.3.3333"},"dependencies":{"cookie-parser":"^1.4.5","express":"^4.17.1","joi":"^17.3.0","jsonwebtoken":"^8.5.1","ms":"^2.1.3","mysql":"^2.14.1","pg":"^8.5.1","reflect-metadata":"^0.1.13","typeorm":"0.2.28"},"main":"build/index.js","types":"build/index.d.ts","scripts":{"build":"tsc","prepare":"tsc","start":"ts-node ./src/test.ts"},"gitHead":"ea3a83e0cdcc60e253ff54851f22326d74084a2c","bugs":{"url":"https://github.com/TeamDurbin/durbin_app_webhook/issues"},"homepage":"https://github.com/TeamDurbin/durbin_app_webhook#readme","_id":"@durbin2022/durbin-app-webhook@0.10.19","_nodeVersion":"14.18.1","_npmVersion":"6.14.15","dist":{"integrity":"sha512-wt+ayuJSgG92/NnVQ0BDfVr0NpKE7UQAWZsUkil8frjEJKhDCWKGXCLMCRM/eZ67Ode6jaIW7+6+lOb4k6HfOg==","shasum":"5dc29aefee9ac90b4d492db81344674ceda38175","tarball":"https://registry.npmjs.org/@durbin2022/durbin-app-webhook/-/durbin-app-webhook-0.10.19.tgz","fileCount":280,"unpackedSize":348808,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh3ucxCRA9TVsSAnZWagAAWlkP/iopjU/XnDt3k0+uloHR\nfNAPKmRe+syhpu3NVgfVx6g//QBNKAPGEj0SAjHMPflpG274z+A+01A4A62C\nh85NndtYz7FnoswZkg1DWdIKnWnN9kak2THrtErXtr46FpXh6QZtj0qGgx/X\npthTaortmEGL4itCKFvSDqwuxsklZGzBkIdPT8vm98B02wLZYYfSkUEur7cB\n7hbBCHKQXoIir/OBEXnP2wNN0JsOFCN0YRwJ2Eo3sqM0rNG57x89HFx33dNf\ngcMvIZnDTFIpnZckgsbylngzAGUPeH9sgznGlILGfNnwRhIY9ZxUdIFWd2aC\n+jJBQ1VJF/zkAqrY3Geiikwvg1vnbdaMwpN4+YmIIu/vsy7e2IZwb05PZgy1\nXUwlmWGoM/F4uJwzWrqYwWSxW+LsbrKeo3O5sE/ZiuLTBi0JLlITX3MA51+R\n5I83wM/hIabWXh1s5/x06molevYyr1KY0mNv5579KQRBSjKvOLX+P5AVoXw8\nutT2fSNBDo1nE/G7wwu1xizfmUxmEXvDxoxyC1txx5wiCgW3SyDbSxnzZocg\nkudpgGVErsdWz3849EwmNxT1k00F7czkmAj1ZuoNH+N0bqqIn4OLVeGfsWPp\nLPGQkJ6pdSbQ7pLGqqAhZSgeGoOokCRwg5LL+QC6lhHuXr835ETkReL/P9Cn\nc3Qj\r\n=7sMi\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDCsl+1MiJOw2UyI7YvDd/Ah4o5v6INHXyJZHkbOsUQiQIhAMAtFKJykVG78Nfgxuf75I8MUMKGwxQRsGwHwevDudwA"}]},"_npmUser":{"name":"durbin2022","email":"durbintechnologies@gmail.com"},"directories":{},"maintainers":[{"name":"durbin2022","email":"durbintechnologies@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/durbin-app-webhook_0.10.19_1641998128885_0.1586894398034584"},"_hasShrinkwrap":false},"0.10.20":{"name":"@durbin2022/durbin-app-webhook","version":"0.10.20","description":"Internal API used for Accounts-app mapping for @durbin2022 Apps","repository":{"type":"git","url":"git+https://github.com/TeamDurbin/durbin_app_webhook.git"},"license":"MIT","devDependencies":{"@types/cookie-parser":"^1.4.2","@types/express":"^4.17.9","@types/jsonwebtoken":"^8.5.0","@types/ms":"^0.7.31","@types/node":"^8.0.29","ts-node":"3.3.0","typescript":"3.3.3333"},"dependencies":{"cookie-parser":"^1.4.5","express":"^4.17.1","joi":"^17.3.0","jsonwebtoken":"^8.5.1","ms":"^2.1.3","mysql":"^2.14.1","pg":"^8.5.1","reflect-metadata":"^0.1.13","typeorm":"0.2.28"},"main":"build/index.js","types":"build/index.d.ts","scripts":{"build":"tsc","prepare":"tsc","start":"ts-node ./src/test.ts"},"gitHead":"3dcbf714a97ec498f0b806ca1c22288f9e8bb49c","bugs":{"url":"https://github.com/TeamDurbin/durbin_app_webhook/issues"},"homepage":"https://github.com/TeamDurbin/durbin_app_webhook#readme","_id":"@durbin2022/durbin-app-webhook@0.10.20","_nodeVersion":"14.19.2","_npmVersion":"6.14.17","dist":{"integrity":"sha512-nhaBoPW/8H1mgFhVKWvU1uBMeo3YZDCo+3ZjO1Yhb16HB8UxEomKCHNizt+yQMKZ8bx+axdn6QwdbNtjc410CA==","shasum":"518813dab8769e309ffe3399fa779d5286ce024e","tarball":"https://registry.npmjs.org/@durbin2022/durbin-app-webhook/-/durbin-app-webhook-0.10.20.tgz","fileCount":277,"unpackedSize":337137,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIGBn47vmxIxV00W8ge8hOUW/mJsyeKOdJwnd5GSFH1YKAiEArmGqoex7000nqSxRrKD7taVgaZKFqEM53RcHE3WIpkg="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJisie/ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqxBQ/+JO1qwjLrh3ohKeBtXLphvbxtHdHhL50tQF4TemuNjt49/gj0\r\nuB22CE7ZeE3Afipq7RERQAVMkYFkW4tN8akh8nHxdHM0mkzaKjlJMo/1VABj\r\nPwJ9uNMu10mpdwO3h0RnRD/MkumEQV0YKZ9u1IXLzb9aoqg8rFWOxxljvwZD\r\n9V747DCJZFTh9kpaMGbz3u68uKcAFygw8gy6Lyiiv7PBtbNQUlF31AGL2zUZ\r\nSKy2kAi5M8rXw6Nd6u4qLKEwmuIfNIOMAXu0wXnbNLiREzIDeJ2D+gctp3cx\r\nIdmdjNX5uSdnSlQSokjU0XwT+F6oYi/SbeCZg5Ww7MrkkzJ1ew2ZSdgUeX4H\r\nJn8/hTQEyxtsdCk+5iLUnQDZbbuuRP91OO28AxOdTgLkPbKvSa8fruG/inmd\r\nyJm2Lpioz/Slcq35PJ9YFGytNIIUdMgkRveeg5O9kTrXaWzlbpyuIExXAu9G\r\n6CEpUh5ZL0Ee+wnIKLdKI/6XNb3u/jBafcNw2Mxeb8nV+H2GbvngEcMcJSy3\r\nKPdxHkV/8rMvP4kVYyyfrWyp1WjywAH74CbvR5vFw7mgF/8vNpb/tPwBLTX9\r\n10Ztml6HikVHbUlRZ4SHhdeM3yhr4oUAx+Q11gVagZf0K9awws1/e0rv/oyQ\r\nWoego6iTyvF4gkE/9YJDUOJX5hn+e8OUhC4=\r\n=7fdx\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"durbin2022","email":"durbintechnologies@gmail.com"},"directories":{},"maintainers":[{"name":"durbin2022","email":"durbintechnologies@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/durbin-app-webhook_0.10.20_1655842751329_0.05326802958604415"},"_hasShrinkwrap":false},"0.10.21":{"name":"@durbin2022/durbin-app-webhook","version":"0.10.21","description":"Internal API used for Accounts-app mapping for @durbin2022 Apps","repository":{"type":"git","url":"git+https://github.com/TeamDurbin/durbin_app_webhook.git"},"license":"MIT","devDependencies":{"@types/cookie-parser":"^1.4.2","@types/express":"^4.17.9","@types/jsonwebtoken":"^8.5.0","@types/ms":"^0.7.31","@types/node":"^8.0.29","ts-node":"3.3.0","typescript":"3.3.3333"},"dependencies":{"cookie-parser":"^1.4.5","express":"^4.17.1","joi":"^17.3.0","jsonwebtoken":"^8.5.1","ms":"^2.1.3","mysql":"^2.14.1","pg":"^8.5.1","reflect-metadata":"^0.1.13","typeorm":"0.2.28"},"main":"build/index.js","types":"build/index.d.ts","scripts":{"build":"tsc","prepare":"tsc","start":"ts-node ./src/test.ts"},"gitHead":"b712e390fa644092ac3d3da08153c746682905a6","bugs":{"url":"https://github.com/TeamDurbin/durbin_app_webhook/issues"},"homepage":"https://github.com/TeamDurbin/durbin_app_webhook#readme","_id":"@durbin2022/durbin-app-webhook@0.10.21","_nodeVersion":"16.17.1","_npmVersion":"8.19.3","dist":{"integrity":"sha512-99U7NO/r3sEqQ5GaOpdN9NB19bIsAMfvMND6LAeZQCr/ghx0JGbjRA90WuMZfqJBUXFlDTfYYiSmvmQR/zFfLA==","shasum":"3e14e5b46387dd59bbe471f272383acaf336cd64","tarball":"https://registry.npmjs.org/@durbin2022/durbin-app-webhook/-/durbin-app-webhook-0.10.21.tgz","fileCount":277,"unpackedSize":337117,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIC1Pi5TY3lzKhIAzCtU8D8alF+cGZ4bwNTDn4vCN+CQQAiBEvEwbru/tufZunlg5TPEWWCc5SJYSeFAdkPF/DXjyEw=="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjdA8DACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqXvw/7Bsv52wTGN3n7r/zY1ERosU66vZW4Z2xZpbqvGqWmJImUc+gL\r\n2/59ALCb8YCcHx+Qz2ucjsuWqcw8jkRmTCQTvKffylOHBfqIO7YbmHr5VcnM\r\n39I6lF13ecISPibIqIbgmfn9xvtde0M8sHjQGCo6YGSpQsScg+f0AbIe+zIC\r\npICA+nosfbWR1Wyku7/ZP0g+gWMrdMhvGaxdtNYk608cAw/UDvwZ5s1KQYT/\r\ncp3OcYz6U/bGtjwpvHkZQ4CH0bLKWyql77yfek+8aftJ6EjbPlq9qb0xW2tR\r\neJXPhO4JU3GOhdQvR1a2sSlVoToR1lGj+Cq48tCbU4m4U+tO8UxVIwbwCy4s\r\nhp4PPsrW/G4c4mogc9o48d3cF78Sm/LLPaF39/F5cFRocgkKUONF3rPuv5fm\r\n+YMbI/0COSp3eoXg8InBaPLlyjcdPV7hYpAcAr56qUVml56kSTkmL7UclZkR\r\ndSbA7Mwy4E5bIcTAvve/wVhbSD5uSRmfOm2NdV45a0kZ7qE/nQoZG9g05Ll1\r\nkhn9cmAW85z2onMKCyt6zx/pVmQqQcC7WwZU+Vz4JtAG1l6i+P8NnxQlwgZF\r\npUf6tpBW/yQp4GMSPBtyAs5WtOL23qhzXxN9oKmAA+qKOuu/RdhlWPv8SbTt\r\nZql6bfSKv9G5S232KN3XAFc9HktbYLA2HCk=\r\n=xidH\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"durbin2022","email":"durbintechnologies@gmail.com"},"directories":{},"maintainers":[{"name":"durbin2022","email":"durbintechnologies@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/durbin-app-webhook_0.10.21_1668550403755_0.46544837058532496"},"_hasShrinkwrap":false}},"time":{"created":"2022-01-12T14:35:28.755Z","0.10.19":"2022-01-12T14:35:29.040Z","modified":"2022-11-15T22:13:24.047Z","0.10.20":"2022-06-21T20:19:11.502Z","0.10.21":"2022-11-15T22:13:23.938Z"},"maintainers":[{"name":"durbin2022","email":"durbintechnologies@gmail.com"}],"description":"Internal API used for Accounts-app mapping for @durbin2022 Apps","homepage":"https://github.com/TeamDurbin/durbin_app_webhook#readme","repository":{"type":"git","url":"git+https://github.com/TeamDurbin/durbin_app_webhook.git"},"bugs":{"url":"https://github.com/TeamDurbin/durbin_app_webhook/issues"},"license":"MIT","readme":"# Durbin Technologies - App Webhooks\n\nDo `yarn add @durbin2022/durbin-app-webhook` and use!\n\n## API Docs\n\n```ts\n/* It all starts with this import */\nimport hooks from \"@durbin2022/durbin-app-webhook\";\n\n/* For the API endpoints and Middlewares */\nimport express from \"express\";\nconst app = express();\n\n/* Which kind of database you are planning to use?\n * Currently we support only `typeorm` which in turn can use postgres, sql and even mongodb!\n */\nhooks.use(\"typeorm\");\n\n/* There are certain parameters which are required for the proper functioning\n * of the webhooks. You can use `.set(param, value)` for the same\n */\n\n/* This express app will be finally used in turn with the webhooks.\n * The `POST /authenticate` endpoint will be served via this express instance.\n */\nhooks.set(\"express-app\", app);\n\n/* You need to set the billable units with which this app will work.\n * These billable units will be required and accounts will read and give proper pricing amount for the same.\n * The names need to unique.\n */\nhooks.set(\"billable-units\", [\n  { name: \"unit-name\", description: \"What is this unit about?\" },\n]);\n\n/* When creating an app on the Admin Panel of Accounts, you will get a Client ID and\n * Client Secret. The app needs to know them for proper internal functioning.\n */\nhooks.set(\"client-id\", process.env.CLIENT_ID);\nhooks.set(\"client-secret\", process.env.CLIENT_SECRET);\n\n/* Optional: Webhook Path. This should match with accounts' knowledge else it won't work.\n * Default is `/webhook`. It can be changed with this set parameter.\n */\nhooks.set(\"webhook-path\", \"/hookmeup\");\n\n/* Bomb has been planted! Fills up Coke on Database and gets ready to serve!\n */\nawait hooks.arm();\n\n/* Middlewares that durbin-app-webhook provides you\n */\n\n/* `hooks.authenticated()` middleware will set the req.authenticated property on Request.\n * It will now either be `false` or will have the `uuid` of the user using the app\n */\napp.use(hooks.authenticated());\n\n/* `hooks.limitOrUse(\"unit\")` will use (by default) 1 unit of the user and will set it in the\n * billing cycle for them. [Pre-requisite: hooks.authenticated() must run before this]\n * If they have reached their limit, it will return a 400 response with \"MONTHLY_QUOTA_REACHED\" in the body.\n */\napp.get(\"/use-unit\", hooks.limitOrUse(\"unit-name\"));\n\napp.get(\"/custom-path\", (req) => {\n  if (req.authenticated)\n    /* Used up (by default) 1 unit of user from their billing table\n     * If they have reached their limit, it will return `false`, else it will use the 1 unit and return `true`\n     */\n    hooks.addTransaction(req.authenticated, \"unit-name\");\n});\n```\n\n## Webhook Paths for Accounts Integration\n\n1. For inserting/updating max credits of an account\n\n```http\nPOST /webhook/upsert-credits\nAuthorization: Bearer <token>\n\n{\n    \"uuid\": \"blah-blah-blah\",\n    \"max\": [\n        { \"unit\": \"understandable-unit\", \"value\": 180 },\n        { \"unit\": \"understandable-unit\", \"value\": 200 }\n    ]\n}\n```\n\n2. Every Billing Cycle - Get user's usage for Billing\n\n```http\nPOST /webhook/billing-cycle\nAuthorization: Bearer <token>\n\n{\n    \"uuid\": \"blah-blah-blah\"\n}\n```\n\nReturns the user's usage before resetting it to 0.\n\n```json\n[\n  { \"unit\": \"understandable-unit\", \"value\": 180 },\n  { \"unit\": \"understandable-unit\", \"value\": 200 }\n]\n```\n\n3. Delete an User - Remove their Permission to use the app\n\n```http\nPOST /webhook/remove-user\nAuthorization: Bearer <token>\n\n{\n    \"uuid\": \"blah-blah-blah\"\n}\n```\n\nReturns the user's usage before deleting the records.\n\n```json\n[\n  { \"unit\": \"understandable-unit\", \"value\": 180 },\n  { \"unit\": \"understandable-unit\", \"value\": 200 }\n]\n```\n","readmeFilename":"README.md"}