Comments (11)
The problem is that package.json
uses main: build/index.js
, but npm module doesn't have build
Can you try to update webcrypto-liner/package.json
and set main: dist/webcrypto-liner.shim.js
?
There can be problem with https://github.com/PeculiarVentures/webcrypto-liner/blob/master/src/init.ts#L5, you can comment it.
from webcrypto-liner.
webcrypto-liner
is a polyfill. It wraps existing global crypto
object Window.
<script src="src/promise.js"></script> <!-- Adds Promise to IE -->
<script src="src/webcrypto-liner.min.js"></script>
<script src="src/asmcrypto.js"></script> <!-- RSA/AES implementation -->
<script src="src/elliptic.js"></script> <!-- EC implementation -->
You can use crypto
without import/require
window.crypto.subtle.generateKey(alg, true, keyUsage);
// or
crypto.subtle.generateKey(alg, true, keyUsage);
from webcrypto-liner.
You can use crypto without import/require
Is there a path to use import/require if I want to? If not, can you help me to understand what the use case is for npm installing if the src files need copy/moving into some dir to reference directly from HTML?
Thanks for bearing with me on this :)
from webcrypto-liner.
webcrypto-liner
is TS project. NPM version contains compiled JS files only. You don't need to install TypeScript and other dependencies for compiled files getting
from webcrypto-liner.
For example, I'm also using https://github.com/samthor/fast-text-encoding to polypill TextEncoder on ie11/Edge.
Usage of this is simple, I simply do a yarn add -D fast-text-encoder
and then import 'fast-text-encoding';
in my JS and voila - the polyfill is enabled.
I'm trying to figure out if it's possible to have the same experience here...
from webcrypto-liner.
@microshine so you're saying all I need to do is yarn add webcrypto-liner
and my code will be magically polyfilled? no imports necessary etc?
from webcrypto-liner.
Do you use any compiler for JS compilation?
If yes. Do you have fast-text-encoding
code in your bundled file after import 'fast-text-encoding'
using?
from webcrypto-liner.
Yes, my project is built with EmberJS, which builds the app using Broccoli. commonjs modules are made available in my project using ember-auto-import
https://github.com/ef4/ember-auto-import.
Yep, it's bundled and the fast-text-encoding
polyfill is working in production...
from webcrypto-liner.
@microshine that seems to have worked - at least my app is no longer throwing an exception when trying to import 'webcrypto-liner';
Let me check an environment where I was previously getting issues because crypto wasn't available...
from webcrypto-liner.
@lougreenwood I also expected to import the library in TypeScript like so:
import 'webcrypto-liner';
Right now this won't work with the following error:
Module not found: Error: Can't resolve 'crypto' in '(...)\node_modules\webcrypto-liner\build'
@microshine would it be possible for you to change main
in package.json accordingly?
from webcrypto-liner.
@microshine @YuryStrozhevsky The issue pointed out by @mc-suchecki was a problem in my pull request to PKI.js. Please change the main field.
from webcrypto-liner.
Related Issues (20)
- Add 3DES and RC2 HOT 1
- PR HOT 3
- Ed25519 Support HOT 10
- tsc spitting out about 40 type errors
- Exception ‘Only secure origins are allowed’ when load from an insecure site using chrome v40. HOT 5
- Android mobile can't work HOT 2
- Unable to build HOT 2
- if project only use ecdh, how got a smaller webcrypto-liner.js HOT 1
- iphonese ios: 9.3.5 can't worked HOT 9
- Is there breaking changes from 1.0.2 to 1.1.2? HOT 4
- Failed to init in the Web Worker HOT 1
- Can't find elliptic js script HOT 5
- asmcrypto_js is undefined HOT 2
- PBKDF2 on Internet Explorer resorts to native subtle and fails HOT 2
- Method scope 'this' undefined when destructuring methods from SubtleCrypto instance
- nativeCrypto.getRandomValues is not a function in Node HOT 1
- Incompatible with TypeScript 4.4 HOT 3
- How to use with webpack?
- Add detecting "secp256k1" as a crv type for compatibility
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from webcrypto-liner.