Skip to content

Commit

Permalink
Fixed crypto import and isNodeStream function (#79)
Browse files Browse the repository at this point in the history
* Fixed crypto import and isNodeStream function

* The same version

* fix globalThis.crypto

* return ts-ignore
  • Loading branch information
ivanovSPvirtru authored Aug 25, 2022
1 parent 7f189f0 commit f24b115
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/facade/FileClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ interface FileClientConfig {
}

function isNodeStream(source: InputSource): source is NodeJS.ReadableStream {
return Object.prototype.hasOwnProperty.call(source, 'pipe');
return typeof (source as NodeJS.ReadableStream)?.pipe === 'function';
}

export class FileClient {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/index.node.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { NanoTDFClient, NanoTDFDatasetClient, AuthProviders, version, clientType } from './index';
import fetch from 'node-fetch';
import crypto from 'crypto';
import { webcrypto as crypto } from 'node:crypto';

globalThis.crypto = crypto as unknown as Crypto;
globalThis.fetch = fetch as typeof globalThis.fetch;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/nanotdf-crypto/getCryptoLib.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ export default function getCryptoLib(): SubtleCrypto {
return subtleCrypto;
}

return globalThis.crypto.webcrypto.subtle;
return globalThis.crypto.subtle;
}

0 comments on commit f24b115

Please sign in to comment.