{"_id":"@blackcube/aurelia2-powshield","_rev":"6-d52da5249d4a98978b5666603242bdb4","name":"@blackcube/aurelia2-powshield","dist-tags":{"latest":"2.3.1"},"versions":{"2.0.0":{"name":"@blackcube/aurelia2-powshield","version":"2.0.0","author":{"name":"Gaultier Philippe","email":"pgaultier@gmail.com"},"license":"BSD-3-Clause","_id":"@blackcube/aurelia2-powshield@2.0.0","maintainers":[{"name":"pgaultier","email":"pgaultier@gmail.com"}],"homepage":"https://github.com/blackcubeio/blackcube-aurelia2#readme","bugs":{"url":"https://github.com/blackcubeio/blackcube-aurelia2/issues"},"dist":{"shasum":"69d3bd29de289f9b6dbc1a0c06d5636d0d36ae72","tarball":"https://registry.npmjs.org/@blackcube/aurelia2-powshield/-/aurelia2-powshield-2.0.0.tgz","fileCount":33,"integrity":"sha512-2TImgxoF5cLpDNQHk8wx/7jr/tc8CG3UqUWJP8NvKdA+mz2TD5poM6MlZ39vPAsEksMWwf3WN3M/7Jp+6GkCig==","signatures":[{"sig":"MEUCIB335PUMca51IkpP2tmpxBVJJyOPkGQ2yNDvNxIO4jc3AiEA26nYJee1GNy9E4zjzKybBBuZ1nskqyivpEZCk4pMrYo=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":119725},"main":"./dist/index.js","type":"module","types":"./dist/types/index.d.ts","module":"./dist/index.es.js","gitHead":"074799d58f78df662cba47fdc2da168519d10e6e","scripts":{"build":"rimraf dist && rollup -c && rimraf .rollup.cache","clean":"rimraf dist && rimraf .rollup.cache","deploy":"npm publish --access public"},"_npmUser":{"name":"pgaultier","email":"pgaultier@gmail.com"},"repository":{"url":"git+https://github.com/blackcubeio/blackcube-aurelia2.git","type":"git"},"_npmVersion":"10.5.0","description":"Blackcube Aurelia 2 Powshield","directories":{},"_nodeVersion":"21.7.1","dependencies":{"aurelia":"^2.0.0-beta.15","@aurelia/fetch-client":"^2.0.0-beta.15"},"_hasShrinkwrap":false,"devDependencies":{"tslib":"^2.6.3","rimraf":"^5.0.7","rollup":"^4.18.0","@rollup/plugin-typescript":"^11.1.6"},"_npmOperationalInternal":{"tmp":"tmp/aurelia2-powshield_2.0.0_1718799896021_0.1909939758940138","host":"s3://npm-registry-packages"}},"2.0.1":{"name":"@blackcube/aurelia2-powshield","version":"2.0.1","author":{"name":"Gaultier Philippe","email":"pgaultier@gmail.com"},"license":"BSD-3-Clause","_id":"@blackcube/aurelia2-powshield@2.0.1","maintainers":[{"name":"pgaultier","email":"pgaultier@gmail.com"}],"homepage":"https://github.com/blackcubeio/blackcube-aurelia2#readme","bugs":{"url":"https://github.com/blackcubeio/blackcube-aurelia2/issues"},"dist":{"shasum":"0fc53330943c5387d37071e0a17597f6f78c1824","tarball":"https://registry.npmjs.org/@blackcube/aurelia2-powshield/-/aurelia2-powshield-2.0.1.tgz","fileCount":39,"integrity":"sha512-Fv7b5UkrjUdwQQdPjp8btgd+ikjI9AGaJdKkXQdnj/B+2Ec+xKQtxNhJTl9I2oDtn0qrOSHfbdm01VrmYZHmdA==","signatures":[{"sig":"MEQCIAI9CRYklqBMqVnNbtUJZQlszK2pvUkN3uA0DMbzhsl2AiBTdG5Nbq5cFo8kHRKIPGGOgFIIN+iRedOnZ8Z0Kt0nMg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":177368},"main":"./dist/index.js","type":"module","types":"./dist/types/index.d.ts","module":"./dist/index.es.js","gitHead":"e23f38e37ed50be7865a211f08f1c4e1e0cdf371","scripts":{"build":"rimraf dist && rollup -c && rimraf .rollup.cache","clean":"rimraf dist && rimraf .rollup.cache","deploy":"npm publish --access public"},"_npmUser":{"name":"pgaultier","email":"pgaultier@gmail.com"},"repository":{"url":"git+https://github.com/blackcubeio/blackcube-aurelia2.git","type":"git"},"_npmVersion":"10.5.0","description":"Blackcube Aurelia 2 Powshield","directories":{},"_nodeVersion":"21.7.1","dependencies":{"aurelia":"^2.0.0-beta.15","@aurelia/fetch-client":"^2.0.0-beta.15"},"_hasShrinkwrap":false,"devDependencies":{"tslib":"^2.6.3","rimraf":"^5.0.7","rollup":"^4.18.0","@rollup/plugin-typescript":"^11.1.6"},"_npmOperationalInternal":{"tmp":"tmp/aurelia2-powshield_2.0.1_1720623390994_0.48065228287996375","host":"s3://npm-registry-packages"}},"2.1.0":{"name":"@blackcube/aurelia2-powshield","version":"2.1.0","author":{"name":"Gaultier Philippe","email":"pgaultier@gmail.com"},"license":"BSD-3-Clause","_id":"@blackcube/aurelia2-powshield@2.1.0","maintainers":[{"name":"pgaultier","email":"pgaultier@gmail.com"}],"homepage":"https://github.com/blackcubeio/blackcube-aurelia2#readme","bugs":{"url":"https://github.com/blackcubeio/blackcube-aurelia2/issues"},"dist":{"shasum":"b30ef8cf8248622de820e66290d35a2e643b218c","tarball":"https://registry.npmjs.org/@blackcube/aurelia2-powshield/-/aurelia2-powshield-2.1.0.tgz","fileCount":39,"integrity":"sha512-vzrl9iwoCpIrdY5VXAeFEVdWylTbTeGdt1flx0gfkjz0uA7HGn9lQEhlX+Azs2vrI+enBZ5MzCrPSzDdsabQFA==","signatures":[{"sig":"MEUCIQChV5u602oX/JlutKyXCjMVKxHH3lj3bKMLcOH4GmR59gIgSK+fPE/RxdOLZHv+GE4+gxtCe3MQWIDR8X5D334AZjs=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":177778},"main":"./dist/index.js","type":"module","types":"./dist/types/index.d.ts","module":"./dist/index.es.js","gitHead":"27652893bfc70141b262954de6ec1783068062dd","scripts":{"build":"rimraf dist && rollup -c && rimraf .rollup.cache","clean":"rimraf dist && rimraf .rollup.cache","deploy":"npm publish --access public"},"_npmUser":{"name":"pgaultier","email":"pgaultier@gmail.com"},"repository":{"url":"git+https://github.com/blackcubeio/blackcube-aurelia2.git","type":"git"},"_npmVersion":"10.8.2","description":"Blackcube Aurelia 2 Powshield","directories":{},"_nodeVersion":"20.17.0","dependencies":{"aurelia":"^2.0.0-beta.21","@aurelia/fetch-client":"^2.0.0-beta.21"},"_hasShrinkwrap":false,"devDependencies":{"tslib":"^2.6.3","rimraf":"^5.0.7","rollup":"^4.18.0","@rollup/plugin-typescript":"^11.1.6"},"_npmOperationalInternal":{"tmp":"tmp/aurelia2-powshield_2.1.0_1727076674782_0.02714101510975464","host":"s3://npm-registry-packages"}},"2.1.1":{"name":"@blackcube/aurelia2-powshield","version":"2.1.1","author":{"name":"Gaultier Philippe","email":"pgaultier@gmail.com"},"license":"BSD-3-Clause","_id":"@blackcube/aurelia2-powshield@2.1.1","maintainers":[{"name":"pgaultier","email":"pgaultier@gmail.com"}],"homepage":"https://github.com/blackcubeio/blackcube-aurelia2#readme","bugs":{"url":"https://github.com/blackcubeio/blackcube-aurelia2/issues"},"dist":{"shasum":"5d5e052115f9b1170e33d52925ea631ad538fe87","tarball":"https://registry.npmjs.org/@blackcube/aurelia2-powshield/-/aurelia2-powshield-2.1.1.tgz","fileCount":39,"integrity":"sha512-Oq1QLNKWQBct+P04utIfXQQ5fzRFcNysPRWfJgU/iUgTos0lNqkeRKtgRXEAchZi2uX3sZXrURixg9N8s6wo6A==","signatures":[{"sig":"MEUCIQDr/rmwjcs4iTrtJWgbjTg11EDeevzt8JCOc6+k2bKNzgIgWt1/gFwfKRjdjEGCfaOclue5m1zkiQSVuA/ka4mTDHw=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":177802},"main":"./dist/index.js","type":"module","types":"./dist/types/index.d.ts","module":"./dist/index.es.js","gitHead":"8ee733081bdcebc45f736b2442e077e4fb662d22","scripts":{"build":"rimraf dist && rollup -c && rimraf .rollup.cache","clean":"rimraf dist && rimraf .rollup.cache","deploy":"npm publish --access public"},"_npmUser":{"name":"pgaultier","email":"pgaultier@gmail.com"},"repository":{"url":"git+https://github.com/blackcubeio/blackcube-aurelia2.git","type":"git"},"_npmVersion":"10.8.3","description":"Blackcube Aurelia 2 Powshield","directories":{},"_nodeVersion":"22.9.0","dependencies":{"aurelia":"latest","@aurelia/fetch-client":"latest"},"_hasShrinkwrap":false,"devDependencies":{"tslib":"^2.6.3","rimraf":"^5.0.7","rollup":"^4.18.0","@rollup/plugin-typescript":"^11.1.6"},"_npmOperationalInternal":{"tmp":"tmp/aurelia2-powshield_2.1.1_1727888880210_0.19763561799660923","host":"s3://npm-registry-packages"}},"2.2.2":{"name":"@blackcube/aurelia2-powshield","version":"2.2.2","author":{"name":"Gaultier Philippe","email":"pgaultier@gmail.com"},"license":"BSD-3-Clause","_id":"@blackcube/aurelia2-powshield@2.2.2","maintainers":[{"name":"pgaultier","email":"pgaultier@gmail.com"}],"homepage":"https://github.com/blackcubeio/blackcube-aurelia2#readme","bugs":{"url":"https://github.com/blackcubeio/blackcube-aurelia2/issues"},"dist":{"shasum":"ff51422b2daafe7e9fd6e1eaa7bfb14232ee47ee","tarball":"https://registry.npmjs.org/@blackcube/aurelia2-powshield/-/aurelia2-powshield-2.2.2.tgz","fileCount":39,"integrity":"sha512-8watC5107XJEjcqYgrdcPGVRWLr54xLdr9hPNAN8ug4t1e0vTeJtFqQKccvCOocm1y0KFq8gBSJup8xuJHaUgw==","signatures":[{"sig":"MEQCIBdcPFBWd49WpAxTE2KU31EFmbtJ+byDq9MddAqO3JNJAiB0trOWsbeOGFG+0JPGKcODwWyn/Mnd+dCABsJXFvLMYg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":180766},"main":"./dist/index.js","type":"module","types":"./dist/types/index.d.ts","module":"./dist/index.es.js","gitHead":"69d922919770c813532ef80e41a2555c50c26743","scripts":{"build":"rimraf dist && rollup -c && rimraf .rollup.cache","clean":"rimraf dist && rimraf .rollup.cache","deploy":"npm publish --access public"},"_npmUser":{"name":"pgaultier","email":"pgaultier@gmail.com"},"repository":{"url":"git+https://github.com/blackcubeio/blackcube-aurelia2.git","type":"git"},"_npmVersion":"10.8.3","description":"Blackcube Aurelia 2 Powshield","directories":{},"_nodeVersion":"22.9.0","dependencies":{"aurelia":"latest","@aurelia/fetch-client":"latest"},"_hasShrinkwrap":false,"devDependencies":{"tslib":"^2.6.3","rimraf":"^5.0.7","rollup":"^4.24.0","@rollup/plugin-typescript":"^11.1.6"},"_npmOperationalInternal":{"tmp":"tmp/aurelia2-powshield_2.2.2_1729789008703_0.9229252160217685","host":"s3://npm-registry-packages"}},"2.3.0":{"name":"@blackcube/aurelia2-powshield","version":"2.3.0","author":{"name":"Gaultier Philippe","email":"pgaultier@gmail.com"},"license":"BSD-3-Clause","_id":"@blackcube/aurelia2-powshield@2.3.0","maintainers":[{"name":"pgaultier","email":"pgaultier@gmail.com"}],"homepage":"https://github.com/blackcubeio/blackcube-aurelia2#readme","bugs":{"url":"https://github.com/blackcubeio/blackcube-aurelia2/issues"},"dist":{"shasum":"3f81af8b56251a270dcb015b91c551d878309185","tarball":"https://registry.npmjs.org/@blackcube/aurelia2-powshield/-/aurelia2-powshield-2.3.0.tgz","fileCount":39,"integrity":"sha512-LxiUDTWR0pJcGFxnHYxR28K892nyGO/I2lmlMbZfwryvKFXglLIOFfexNNmrvF06Yzd6r7Nanfx76g62nN1eaA==","signatures":[{"sig":"MEYCIQDxStJLlZ5+DZZlWRmsmE8yAfKVXl3cyfMzTkLLjzs4kwIhAPQ/FASRsWpSp+52jqkqYtrauIku0lyigguow1rhikoi","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":180766},"main":"./dist/index.js","type":"module","types":"./dist/types/index.d.ts","module":"./dist/index.es.js","gitHead":"14577e38fb4d179a269f97d4f02d39bba4fa89c8","scripts":{"build":"rimraf dist && rollup -c && rimraf .rollup.cache","clean":"rimraf dist && rimraf .rollup.cache","deploy":"npm publish --access public"},"_npmUser":{"name":"pgaultier","email":"pgaultier@gmail.com"},"repository":{"url":"git+https://github.com/blackcubeio/blackcube-aurelia2.git","type":"git"},"_npmVersion":"10.8.3","description":"Blackcube Aurelia 2 Powshield","directories":{},"_nodeVersion":"22.9.0","dependencies":{"aurelia":"latest","@aurelia/fetch-client":"latest"},"_hasShrinkwrap":false,"devDependencies":{"tslib":"^2.6.3","rimraf":"^5.0.7","rollup":"^4.24.0","@rollup/plugin-typescript":"^11.1.6"},"_npmOperationalInternal":{"tmp":"tmp/aurelia2-powshield_2.3.0_1729896086007_0.8917813492705855","host":"s3://npm-registry-packages"}},"2.3.1":{"name":"@blackcube/aurelia2-powshield","version":"2.3.1","description":"Blackcube Aurelia 2 Powshield","repository":{"type":"git","url":"git+https://github.com/blackcubeio/blackcube-aurelia2.git"},"author":{"name":"Gaultier Philippe","email":"pgaultier@gmail.com"},"license":"BSD-3-Clause","type":"module","module":"./dist/index.es.js","main":"./dist/index.js","types":"./dist/types/index.d.ts","scripts":{"build":"rimraf dist && rollup -c && rimraf .rollup.cache","deploy":"npm publish --access public","clean":"rimraf dist && rimraf .rollup.cache"},"dependencies":{"@aurelia/fetch-client":"latest","aurelia":"latest"},"devDependencies":{"@rollup/plugin-typescript":"^11.1.6","rimraf":"^5.0.7","rollup":"^4.24.0","tslib":"^2.6.3"},"_id":"@blackcube/aurelia2-powshield@2.3.1","gitHead":"83fa718d0ee10acc1ba21729689c218287ebd48c","bugs":{"url":"https://github.com/blackcubeio/blackcube-aurelia2/issues"},"homepage":"https://github.com/blackcubeio/blackcube-aurelia2#readme","_nodeVersion":"22.9.0","_npmVersion":"10.8.3","dist":{"integrity":"sha512-m4yKbV7EF7m1UIC6leOr2LfQ8As7CmIExd61W4w4fIYdpYgJauJJZhJBJiiIv3zNNwRn5PT7gYxR/wp60nD/SA==","shasum":"7df3f53811bcfa88ab32f8a356771449a52e8999","tarball":"https://registry.npmjs.org/@blackcube/aurelia2-powshield/-/aurelia2-powshield-2.3.1.tgz","fileCount":39,"unpackedSize":177652,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDqkU1AL0/S7K2BCUqqmhfJmkxBWAsf+GbTSdTdIr8TrAiBIG5/AiJ7XjF3OjLKp1tUqrzvE5w4WOrYnHC//K2vgDw=="}]},"_npmUser":{"name":"pgaultier","email":"pgaultier@gmail.com"},"directories":{},"maintainers":[{"name":"pgaultier","email":"pgaultier@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/aurelia2-powshield_2.3.1_1730026980523_0.9035137908054642"},"_hasShrinkwrap":false}},"time":{"created":"2024-06-19T12:24:55.914Z","modified":"2024-10-27T11:03:00.919Z","2.0.0":"2024-06-19T12:24:56.212Z","2.0.1":"2024-07-10T14:56:31.172Z","2.1.0":"2024-09-23T07:31:14.947Z","2.1.1":"2024-10-02T17:08:00.410Z","2.2.2":"2024-10-24T16:56:48.906Z","2.3.0":"2024-10-25T22:41:26.223Z","2.3.1":"2024-10-27T11:03:00.744Z"},"bugs":{"url":"https://github.com/blackcubeio/blackcube-aurelia2/issues"},"author":{"name":"Gaultier Philippe","email":"pgaultier@gmail.com"},"license":"BSD-3-Clause","homepage":"https://github.com/blackcubeio/blackcube-aurelia2#readme","repository":{"type":"git","url":"git+https://github.com/blackcubeio/blackcube-aurelia2.git"},"description":"Blackcube Aurelia 2 Powshield","maintainers":[{"name":"pgaultier","email":"pgaultier@gmail.com"}],"readme":"# Blackcube Aurelia 2 powshield toolkit\n\nThis toolkit allows easy setup of Powshield.\n\n## Install\n\nPackage is available on npm\n\nThen you can install the package:\n\n```shell\nnpm install @blackcube/aurelia2-powshield\n```\n\n### Howto\n\nProcess is simple:\n\n1. Fetch a new challenge from the API\n2. Solve the challenge to get a solution\n3. Verify the solution with the API\n4. If the solution is correct, you can submit your form\n5. Check the solution serverside to avoid any issue\n\n## API\n\nIn order to be mst robust, you should limit the use of a challenge\nFor example, you can limit the use of a challenge to 2 times:\n- First time to allow validation by the JS (frontend)\n- Second time to allow validation by the server (backend)\n\nencrypt and decrypt functions should be symmetric to allow the server\nto encrypt/decrypt the timestamp and validate the challenge\n\n### PseudoCode to generate a challenge\n\n```\n// app constants\nkey = 'your-secret'\n\n// generate a random string of 12 characters\nsalt = generateRandomString(12)\n\n// generate a random number between 0 and 50000\n// values 0 and 50000 can be tuned to your needs\nsecretNumber = random_int(0, 50000)\n\nalgorithm = 'SHA-256'\n// algorithm can be SHA-1, SHA-256, SHA-512\n\ntimestamp = time()\ncypheredTimestamp = base64_encode(encrypt(timestamp, key))\n\nchallenge = hash(algorithm, concat(salt, secretNumber, cypheredTimestamp)\nsignature = hash_hmac(algorithm, challenge, key);\n\n\nresult = base64_encode(json_encode({\n    'algorithm': algorithm,\n    'timestamp': cypheredTimestamp,\n    'challenge': challenge,\n    'salt': salt,\n    'signature': $signature,\n    'start': 0,\n    'max': maxIterations,\n}));\n// return the result as a base64 encoded JSON object\n``` \n\n### PseudoCode to verify a solution\n\n```\n// app constants\nkey = 'your-secret'\ntimeValidity = 300 // 5 minutes\n\n// received payload\npayload = json_decode(base64_decode($payload))\n\nalgorithm = payload.algorithm\ncypheredTimestamp = base64_decode(payload.timestamp)\nchallenge = payload.challenge\nnumber = payload.number\nsalt = payload.salt\nsignature = payload.signature\n\ncheckChallenge = hash(algorithm, concat(salt, secretNumber, cypheredTimestamp)\ncheckSignature = hash_hmac(algorithm, challenge, key)\n\ntimestamp = decrypt(base64_decode(cypheredTimestamp), key)\n\nvalidityOk = time < timestamp + timeValidity\nchallengeOk = hash_equals(checkChallenge, challenge)\nsignatureOk = hash_equals(checkSignature, signature)\n\nverfied = challengeOk and signatureOk;\n```\n\n## Registering it in app\n\n```typescript\nimport Aurelia, { ConsoleSink, LoggerConfiguration, LogLevel} from 'aurelia';\nimport { PowshieldConfiguration } from \"@blackcube/aurelia2-powshield\";\nimport { MyApp } from './my-app';\nAurelia\n    .register(PowshieldConfiguration)\n    .register(LoggerConfiguration.create({\n        level: LogLevel.trace,\n        colorOptions: 'colors',\n        sinks: [ConsoleSink]\n    }))\n    .app(MyApp)\n    .start();\n```\n\n## Additional configuration if needed\n\nYou can configure the toolkit by passing a configuration object to the configure method:\n\n```typescript\nimport Aurelia, { ConsoleSink, LoggerConfiguration, LogLevel} from 'aurelia';\nimport { PowshieldConfiguration } from \"@blackcube/aurelia2-powshield\";\nimport { MyApp } from './my-app';\nAurelia\n    .register(PowshieldConfiguration.configure({\n        generateChallengeUrl: '/powshield/generate-challenge',\n        verifySolutionUrl: '/powshield/verify-solution',\n        solutionInputSelector: '#powshieldSolution'\n    }))\n    .register(LoggerConfiguration.create({\n        level: LogLevel.trace,\n        colorOptions: 'colors',\n        sinks: [ConsoleSink]\n    }))\n    .app(MyApp)\n    .start();\n```\n\nDefault values are:\n\n- generateChallengeUrl: '/powshield/generate-challenge',\n- verifySolutionUrl: '/powshield/verify-solution',\n- solutionInputSelector: '#powshieldSolution'\n\n- **generateChallengeUrl** URL used to generate a new challenge\n- **verifySolutionUrl** URL used to verify a solution\n- **solutionInputSelector** selector used to get the solution input element which will be used to send the solution to the server\n\n## Usage in HTML\n\n```html\n<template>\n    <form bc-powshield=\"#powshieldSolution\">\n\n        <input type=\"hidden\" id=\"powshieldSolution\" name=\"powshieldSolution\" />\n        <div>\n            <label for=\"email\">EMail</label>\n            <input type=\"email\" id=\"email\" name=\"email\" />\n        </div>\n        <div>\n            <button type=\"submit\">Submit</button>\n        </div>\n    </form>\n</template>\n```\n\nForm will be protected by Powshield. When the form is submitted, the toolkit will generate a new challenge, and will add the solution to the hidden input field. \nThe form will be submitted with the solution. The server will be able to verify the solution.","readmeFilename":"README.md"}