miscreant / meta

Meta-repository for Miscreant: misuse-resistant symmetric encryption library with AES-SIV (RFC 5297) and AES-PMAC-SIV support
https://miscreant.io
Other
474 stars 27 forks source link

js: node-webcrypto-ossl 1.0.26 incompatible with typescript 2.6.2 #154

Closed aegarbutt closed 6 years ago

aegarbutt commented 6 years ago

Hey,

When trying to install miscrants dev-dependencies today, the node-webcrypto-ossl install failed with an error in build:e5 tsc.

just running the following:

$ npm install

...SNIP...

> node-webcrypto-ossl@1.0.26 postinstall /Users/aegarbutt/src/miscreant/js/node_modules/node-webcrypto-ossl
> npm run build

> node-webcrypto-ossl@1.0.26 build /Users/aegarbutt/src/miscreant/js/node_modules/node-webcrypto-ossl
> npm run build:es5

> node-webcrypto-ossl@1.0.26 build:es5 /Users/aegarbutt/src/miscreant/js/node_modules/node-webcrypto-ossl
> tsc

lib/crypto/aes.ts(94,13): error TS2322: Type 'Promise<{}>' is not assignable to type 'PromiseLike<ArrayBuffer>'.
  Types of property 'then' are incompatible.
    Type '<TResult1 = {}, TResult2 = never>(onfulfilled?: ((value: {}) => TResult1 | PromiseLike<TResult1>)...' is not assignable to type '<TResult1 = ArrayBuffer, TResult2 = never>(onfulfilled?: ((value: ArrayBuffer) => TResult1 | Prom...'.
      Types of parameters 'onfulfilled' and 'onfulfilled' are incompatible.
        Types of parameters 'value' and 'value' are incompatible.
          Type '{}' is not assignable to type 'ArrayBuffer'.
            Property 'byteLength' is missing in type '{}'.
lib/crypto/aes.ts(102,13): error TS2322: Type 'Promise<{}>' is not assignable to type 'PromiseLike<ArrayBuffer>'.
lib/crypto/hmac.ts(26,29): error TS2345: Argument of type 'CryptoKey' is not assignable to parameter of type 'CryptoKeyPair | PromiseLike<CryptoKeyPair> | undefined'.
  Type 'CryptoKey' is not assignable to type 'PromiseLike<CryptoKeyPair>'.
    Property 'then' is missing in type 'CryptoKey'.
lib/crypto/pbkdf2.ts(44,9): error TS2322: Type 'Promise<CryptoKey>' is not assignable to type 'PromiseLike<CryptoKey>'.
  Types of property 'then' are incompatible.
    Type '<TResult1 = CryptoKey, TResult2 = never>(onfulfilled?: ((value: CryptoKey) => TResult1 | PromiseL...' is not assignable to type '<TResult1 = CryptoKey, TResult2 = never>(onfulfilled?: ((value: CryptoKey) => TResult1 | PromiseL...'. Two different types with this name exist, but they are unrelated.
      Types of parameters 'onfulfilled' and 'onfulfilled' are incompatible.
        Types of parameters 'value' and 'value' are incompatible.
          Type 'CryptoKey' is not assignable to type 'CryptoKey'. Two different types with this name exist, but they are unrelated.
            Property 'native_' is missing in type 'CryptoKey'.

However, if I drop the typescript version to @2.3.4 (as found in this issue: https://github.com/PeculiarVentures/node-webcrypto-ossl/issues/107)

$ npm install

...SNIP...

z
> node-webcrypto-ossl@1.0.26 postinstall /Users/aegarbutt/src/miscreant/js/node_modules/node-webcrypto-ossl
> npm run build

> node-webcrypto-ossl@1.0.26 build /Users/aegarbutt/src/miscreant/js/node_modules/node-webcrypto-ossl
> npm run build:es5

> node-webcrypto-ossl@1.0.26 build:es5 /Users/aegarbutt/src/miscreant/js/node_modules/node-webcrypto-ossl
> tsc

added 487 packages in 53.381s

Thanks!

rmhrisk commented 6 years ago

Latest version of node-webcrypto-ossl is 1.0.34, it uses Typescript 2.6.2.

aegarbutt commented 6 years ago

I've tracked down why node-webcrypto-ossl couldn't previously be upgraded > 1.0.31.

(See: https://github.com/PeculiarVentures/node-webcrypto-ossl/issues/116).

If and when that lands (or something like it), then node-webcrypto-ossl could be updated.

In the meantime, it can be upgraded to == 1.0.31 right now if so desired.

tarcieri commented 6 years ago

Thanks for the sleuthing... I was curious what was happening there.

microshine commented 6 years ago

@aegarbutt thank you for your PR. I published new version of node-webcrypto-ossl and used it in miscreant tests. All tests were passed