{"name":"webcrypto-core","version":"0.1.6","description":"Common layer to be used by crypto libraries based on WebCrypto API for input validation.","main":"build/index.js","types":"index.d.ts","directories":{"test":"test"},"scripts":{"prepublish":"npm test","pretest":"npm run build:test","build":"npm run build:es2015 && rollup -c","build:es5":"tsc --module commonjs --target es5","build:es2015":"tsc --module es2015 --target es2015","build:test":"tsc --module commonjs --target es5 --sourcemap","build:source":"tsc --declaration --declarationDir types","test":"mocha test","install":"npm run build:es5","pub":"npm version patch && npm publish && git push","coverage":"nyc npm test","precoveragehtml":"npm run coverage","coveragehtml":"nyc report -r html","watch":"watch 'npm run coveragehtml' lib/ test/","live":"live-server -q --port=4005 --ignorePattern='(js|css|png)$' coverage","predev":"if [ ! -f coverage/index.html ]; then mkdir coverage; cp .waiting.html coverage/index.html; fi","dev":"npm-run-all -p --silent watch live","coveralls":"nyc report --reporter=text-lcov | coveralls"},"repository":{"type":"git","url":"git+https://github.com/PeculiarVentures/webcrypto-core.git"},"keywords":["webcrypto","crypto","polyfill","aes","rsa","sha","ec"],"dependencies":{"@types/node":"^6","typescript":"^2"},"devDependencies":{"babel-preset-es2015":"^6.18.0","live-server":"^1","npm-run-all":"^3","nyc":"^8","watch":"^0"},"author":{"name":"PeculiarVentures"},"license":"MIT","bugs":{"url":"https://github.com/PeculiarVentures/webcrypto-core/issues"},"homepage":"https://github.com/PeculiarVentures/webcrypto-core#readme","gitHead":"1d533fc5f76f48a7168882d7310a70a3b6bbada4","_id":"webcrypto-core@0.1.6","_shasum":"9134a32c788e822babcb18943bc0651c4f341d68","_from":".","_npmVersion":"3.10.9","_nodeVersion":"6.9.2","_npmUser":{"name":"microshine","email":"microshine@mail.ru"},"dist":{"shasum":"9134a32c788e822babcb18943bc0651c4f341d68","tarball":"http://registry-npm.ywwl.com/webcrypto-core/download/webcrypto-core-0.1.6.tgz","integrity":"sha512-ts14pacxlT5ANmAqXnWYBxIOJhXo1gDu4lCgF6YeAUSBHsWATj4Oi7TnQfgM8/C4vS3MAEpzwB7OwrzfzGEF8g==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHm/vRuS7s7tdm/ZWW7gC3zreXYbl+1nc1hgKJOqh2QdAiEAnwkkXVpQfLnFxF0i4yN35kFBaP2yYhMyfEexlsEQv/Q="}],"size":23299,"noattachment":false,"key":"/webcrypto-core/-/webcrypto-core-0.1.6.tgz"},"maintainers":[{"name":"microshine","email":"microshine@mail.ru"},{"name":"peculiarventures","email":"info@peculiarventures.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/webcrypto-core-0.1.6.tgz_1482861495946_0.7011914127506316"},"readme":"[![License](https://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://raw.githubusercontent.com/PeculiarVentures/webcrypto-core/master/LICENSE)\n[![test](https://github.com/PeculiarVentures/webcrypto-core/actions/workflows/test.yml/badge.svg)](https://github.com/PeculiarVentures/webcrypto-core/actions/workflows/test.yml)\n[![Coverage Status](https://coveralls.io/repos/github/PeculiarVentures/webcrypto-core/badge.svg?branch=master)](https://coveralls.io/github/PeculiarVentures/webcrypto-core?branch=master)\n[![npm version](https://badge.fury.io/js/webcrypto-core.svg)](https://badge.fury.io/js/webcrypto-core)\n\n[![NPM](https://nodei.co/npm/webcrypto-core.png)](https://nodei.co/npm/webcrypto-core/)\n\n# webcrypto-core\n\nWe have created a number of WebCrypto polyfills including: [node-webcrypto-ossl](https://github.com/PeculiarVentures/node-webcrypto-ossl), [node-webcrypto-p11](https://github.com/PeculiarVentures/node-webcrypto-p11), and [webcrypto-liner](https://github.com/PeculiarVentures/webcrypto-liner).  `webcrypto-core` was designed to be a common layer to be used by all of these libraries for input validation.\n\nUnless you intend to create a WebCrypto polyfill this library is probably not useful to you.\n\n## Installing\n\n```\nnpm install webcrypto-core\n```\n\n## Example\n\nCurrent examples shows how you can implement your own WebCrypt interface\n\n```js\nconst core = require(\".\");\nconst crypto = require(\"crypto\");\n\nclass Sha1Provider extends core.ProviderCrypto {\n\n  constructor() {\n    super();\n\n    this.name = \"SHA-1\";\n    this.usages = [];\n  }\n\n  async onDigest(algorithm, data) {\n    const hash = crypto.createHash(\"SHA1\").update(Buffer.from(data)).digest();\n    return new Uint8Array(hash).buffer;\n  }\n\n}\n\nclass SubtleCrypto extends core.SubtleCrypto {\n  constructor() {\n    super();\n\n    // Add SHA1 provider to SubtleCrypto\n    this.providers.set(new Sha1Provider());\n  }\n}\n\nclass Crypto extends core.Crypto {\n\n  constructor() {\n    this.subtle = new SubtleCrypto();\n  }\n\n  getRandomValues(array) {\n    const buffer = Buffer.from(array.buffer);\n    crypto.randomFillSync(buffer);\n    return array;\n  }\n\n}\n\nconst webcrypto = new Crypto();\nwebcrypto.subtle.digest(\"SHA-1\", Buffer.from(\"TEST MESSAGE\"))\n  .then((hash) => {\n    console.log(Buffer.from(hash).toString(\"hex\")); // dbca505deb07e1612d944a69c0c851f79f3a4a60\n  })\n  .catch((err) => {\n    console.error(err);\n  });\n```","publish_time":1482861496575,"_cnpm_publish_time":1482861496575,"dist-tags":{"latest":"2.0.0","next":"1.0.19-next.0"}}