diff --git a/README.md b/README.md index c6504a2..2216d66 100644 --- a/README.md +++ b/README.md @@ -1388,6 +1388,12 @@ export const testMyFirstTest = tc => { +### React-Native support + +```sh +npm i isomorphic-webcrypto +``` + ### License [The MIT License](./LICENSE) © Kevin Jahns diff --git a/package.json b/package.json index 985e145..c98fd35 100644 --- a/package.json +++ b/package.json @@ -441,6 +441,7 @@ "types": "./webcrypto.d.ts", "deno": "./webcrypto.deno.js", "bun": "./webcrypto.js", + "react-native": "./dist/webcrypto.react-native.cjs", "browser": { "module": "./webcrypto.js", "require": "./dist/webcrypto.cjs", diff --git a/rollup.config.js b/rollup.config.js index 6dea38c..51a1036 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -14,5 +14,5 @@ export default [{ entryFileNames: '[name].cjs', chunkFileNames: '[name]-[hash].cjs' }, - external: ['isomorphic.js', 'node:crypto', 'lib0/webcrypto', 'lib0/performance', 'perf_hooks'] + external: ['isomorphic.js', 'node:crypto', 'lib0/webcrypto', 'lib0/performance', 'perf_hooks', 'isomorphic-webcrypto', 'node:perf_hooks', 'lib0/logging'] }] diff --git a/webcrypto.react-native.js b/webcrypto.react-native.js new file mode 100644 index 0000000..ca4f597 --- /dev/null +++ b/webcrypto.react-native.js @@ -0,0 +1,6 @@ +import webcrypto from 'isomorphic-webcrypto' + +webcrypto.ensureSecure() + +export const subtle = webcrypto.subtle +export const getRandomValues = webcrypto.getRandomValues.bind(webcrypto)