{"id":23364475,"url":"https://github.com/fission-codes/one-webcrypto","last_synced_at":"2025-04-10T12:52:27.772Z","repository":{"id":46341647,"uuid":"417444548","full_name":"fission-codes/one-webcrypto","owner":"fission-codes","description":"Import the webcrypto API as a single module in both nodejs and browsers.","archived":false,"fork":false,"pushed_at":"2023-09-09T16:06:37.000Z","size":7,"stargazers_count":4,"open_issues_count":2,"forks_count":5,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-04-03T04:56:18.360Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fission-codes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2021-10-15T09:35:13.000Z","updated_at":"2023-07-31T12:29:29.000Z","dependencies_parsed_at":"2024-03-08T04:46:23.429Z","dependency_job_id":null,"html_url":"https://github.com/fission-codes/one-webcrypto","commit_stats":null,"previous_names":["fission-suite/one-webcrypto"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fission-codes%2Fone-webcrypto","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fission-codes%2Fone-webcrypto/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fission-codes%2Fone-webcrypto/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fission-codes%2Fone-webcrypto/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fission-codes","download_url":"https://codeload.github.com/fission-codes/one-webcrypto/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247909193,"owners_count":21016479,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-21T13:16:27.119Z","updated_at":"2025-04-10T12:52:27.746Z","avatar_url":"https://github.com/fission-codes.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# one-webcrypto\n\nThe [WebCrypto API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API) is available in [most browsers](https://caniuse.com/cryptography), under a global variable:\n\n```js\n// in web pages\nconst webcrypto = window.crypto\n// in web workers, etc.\nconst webcrypto = self.crypto\n// or generally under\nconst webcrypto = globalThis.crypto\n```\n\nIt is also [available in NodeJS](https://nodejs.org/api/webcrypto.html#webcrypto_web_crypto_api) since version 15.\n\nHowever, it is accessed differently:\n\n```js\n// in node with commonjs\nconst webcrypto = require(\"crypto\").webcrypto\n// in node with ES Modules\nimport crypto from \"crypto\"\nconst webcrypto = crypto.webcrypto\n```\n\nThese different ways of getting access to valuable cryptographic primitives (see `webcrypto.subtle`) accross platforms (node \u0026 browsers) are hard to get right.\n\n\n## Usage\n\nWith this package, you can just import the [WebCrypto API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API) like so:\n\n```js\nimport { webcrypto } from \"one-webcrypto\"\n\nwebcrypto.getRandomValues( //...\nawait webcrypto.subtle.generateKey( //...\n```\n\nOr with CommonJS:\n\n```js\nconst { webcrypto } = require(\"one-webcrypto\")\n```\n\n\n## Compatibility Issues\n\nThis package uses a fairly new package.json standard field, the `exports` field.\n\nRead more about it:\n* [\"export maps\" in nodejs documentation](https://nodejs.org/api/packages.html#packages_package_entry_points). \n* [\"package exports\" in webpack documentation](https://webpack.js.org/guides/package-exports/)\n* [original \"pkg exports\" proposal](https://github.com/jkrems/proposal-pkg-exports/)\n\nWe're also making use of webpack's pseudo-standard of the [\"browser\" flag](https://webpack.js.org/guides/package-exports/#target-environment) for imports.\n\nSo if your environment doesn't support that, it _may_ or _may not_ work.\n\nWe know that this setup works (*should work*) with\n* NodeJS 15+ (thus also e.g. mocha)\n* ESBuild\n* Webpack 5\n* Vite\n* SvelteKit\n* Snowpack\n* Parcel 2\n\nWe know that this setup can have issues with\n* Create React App\n\nIf you have **any experience** (whether it supports the claims above or not), **please create an issue**.\nThe idea is to help each other out in these crazy bundler times and document what works and what doesn't. :)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffission-codes%2Fone-webcrypto","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffission-codes%2Fone-webcrypto","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffission-codes%2Fone-webcrypto/lists"}