PeculiarVentures / webcrypto-core

A input validation layer for WebCrypto polyfills.
MIT License
28 stars 13 forks source link

Installation of 0.1.4 fails #3

Closed dignifiedquire closed 7 years ago

dignifiedquire commented 7 years ago

I was just reinstalling my node_modules with a dependency on webcrypto-ossl, which in turn pulls in webcrypto-core. But this fails now with the following output:

npm i

> webcrypto-core@0.1.4 install /Users/dignifiedquire/opensource/ipfs/js-ipfs-lerna/packages/js-libp2p-ipfs/node_modules/webcrypto-core
> npm run build:es5

> webcrypto-core@0.1.4 build:es5 /Users/dignifiedquire/opensource/ipfs/js-ipfs-lerna/packages/js-libp2p-ipfs/node_modules/webcrypto-core
> tsc --module commonjs --target es5

41         return Promise.resolve()
                  ~~~~~~~~~~~~~~~~~
42             .then(() => {
   ~~~~~~~~~~~~~~~~~~~~~~~~~
43                 this.checkAlgorithm(algorithm);
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
44             });
   ~~~~~~~~~~~~~~

src/pbkdf2/crypto.ts(41,16): error TS2322: Type 'Promise<void>' is not assignable to type 'PromiseLike<CryptoKey | CryptoKeyPair>'.
  Types of property 'then' are incompatible.
    Type '{ (onfulfilled?: ((value: void) => void | PromiseLike<void>) | null | undefined, onrejected?: ((r...' is not assignable to type '{ (onfulfilled?: ((value: CryptoKey | CryptoKeyPair) => CryptoKey | CryptoKeyPair | PromiseLike<C...'.
      Types of parameters 'onfulfilled' and 'onfulfilled' are incompatible.
        Type '((value: CryptoKey | CryptoKeyPair) => CryptoKey | CryptoKeyPair | PromiseLike<CryptoKey | Crypto...' is not assignable to type '((value: void) => void | PromiseLike<void>) | null | undefined'.
          Type '(value: CryptoKey | CryptoKeyPair) => CryptoKey | CryptoKeyPair | PromiseLike<CryptoKey | CryptoK...' is not assignable to type '((value: void) => void | PromiseLike<void>) | null | undefined'.
            Type '(value: CryptoKey | CryptoKeyPair) => CryptoKey | CryptoKeyPair | PromiseLike<CryptoKey | CryptoK...' is not assignable to type '(value: void) => void | PromiseLike<void>'.
              Types of parameters 'value' and 'value' are incompatible.
                Type 'void' is not assignable to type 'CryptoKey | CryptoKeyPair'.

 48         return Promise.resolve()
                   ~~~~~~~~~~~~~~~~~
 49             .then(() => {
    ~~~~~~~~~~~~~~~~~~~~~~~~~
...
 54                 this.checkKeyUsages(keyUsages);
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 55             });
    ~~~~~~~~~~~~~~

src/pbkdf2/crypto.ts(48,16): error TS2322: Type 'Promise<void>' is not assignable to type 'PromiseLike<CryptoKey>'.
  Types of property 'then' are incompatible.
    Type '{ (onfulfilled?: ((value: void) => void | PromiseLike<void>) | null | undefined, onrejected?: ((r...' is not assignable to type '{ (onfulfilled?: ((value: CryptoKey) => CryptoKey | PromiseLike<CryptoKey>) | null | undefined, o...'.
      Types of parameters 'onfulfilled' and 'onfulfilled' are incompatible.
        Type '((value: CryptoKey) => CryptoKey | PromiseLike<CryptoKey>) | null | undefined' is not assignable to type '((value: void) => void | PromiseLike<void>) | null | undefined'.
          Type '(value: CryptoKey) => CryptoKey | PromiseLike<CryptoKey>' is not assignable to type '((value: void) => void | PromiseLike<void>) | null | undefined'.
            Type '(value: CryptoKey) => CryptoKey | PromiseLike<CryptoKey>' is not assignable to type '(value: void) => void | PromiseLike<void>'.
              Types of parameters 'value' and 'value' are incompatible.
                Type 'void' is not assignable to type 'CryptoKey'.

 59         return Promise.resolve()
                   ~~~~~~~~~~~~~~~~~
 60             .then(() => {
    ~~~~~~~~~~~~~~~~~~~~~~~~~
...
 88                 }
    ~~~~~~~~~~~~~~~~~
 89             });
    ~~~~~~~~~~~~~~

src/pbkdf2/crypto.ts(59,16): error TS2322: Type 'Promise<void>' is not assignable to type 'PromiseLike<CryptoKey>'.

 92         return Promise.resolve()
                   ~~~~~~~~~~~~~~~~~
 93             .then(() => {
    ~~~~~~~~~~~~~~~~~~~~~~~~~
...
 97                     throw new WebCryptoError("Parameter 'length' must be Number and more than 0");
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 98             });
    ~~~~~~~~~~~~~~

src/pbkdf2/crypto.ts(92,16): error TS2322: Type 'Promise<void>' is not assignable to type 'PromiseLike<ArrayBuffer>'.
  Types of property 'then' are incompatible.
    Type '{ (onfulfilled?: ((value: void) => void | PromiseLike<void>) | null | undefined, onrejected?: ((r...' is not assignable to type '{ (onfulfilled?: ((value: ArrayBuffer) => ArrayBuffer | PromiseLike<ArrayBuffer>) | null | undefi...'.
      Types of parameters 'onfulfilled' and 'onfulfilled' are incompatible.
        Type '((value: ArrayBuffer) => ArrayBuffer | PromiseLike<ArrayBuffer>) | null | undefined' is not assignable to type '((value: void) => void | PromiseLike<void>) | null | undefined'.
          Type '(value: ArrayBuffer) => ArrayBuffer | PromiseLike<ArrayBuffer>' is not assignable to type '((value: void) => void | PromiseLike<void>) | null | undefined'.
            Type '(value: ArrayBuffer) => ArrayBuffer | PromiseLike<ArrayBuffer>' is not assignable to type '(value: void) => void | PromiseLike<void>'.
              Types of parameters 'value' and 'value' are incompatible.
                Type 'void' is not assignable to type 'ArrayBuffer'.
microshine commented 7 years ago

It's strange. I added new algs to core for node-webcrypto-ossl. My local update was without errors and travis-ci has no errors https://travis-ci.org/PeculiarVentures/webcrypto-core

microshine commented 7 years ago

try to update your typescript. I use v2.1.4

microshine commented 7 years ago

@dignifiedquire I published the newest version v0.1.5. Could you try it? image

dignifiedquire commented 7 years ago

Thanks will try, my typescript is at 2.1.4 already and failing with 0.1.4 (0.1.3 installs fine)

dignifiedquire commented 7 years ago

Another note, is there any chance of changing the setup, such that typescript does not have to be pulled in on every install, but rather the building happens before publishing? I have a lot of people installing this as a dependency who don't use typescript, so it increases the install time for them quite considerably.

dignifiedquire commented 7 years ago

Fixed in 0.1.5 👍

microshine commented 7 years ago

Thank you for issue.

I'll discuss this question with my team. Some developers want to use different versions of JS script (ES5, ES2015), some want to use GIT link. That's why I publish core with source code.

dignifiedquire commented 7 years ago

Thank you, in modules where I had to transpile/compile I used to simply publish the source in src and compiled in another folder. Then point main in package.json to the compiled version, for those wanting the source they could run require('package/src').