nativescript-community / https

Secure HTTP client with SSL pinning for Nativescript - iOS/Android
https://nativescript-community.github.io/https/
Other
51 stars 42 forks source link

Cannot read https of undefined #69

Closed leocrawf closed 3 years ago

leocrawf commented 3 years ago

When I was uisng version 2.1.0 I had no issues. Now with 2.2.1, I get Cannot read https of undefined.

ghinazi commented 3 years ago

getting the same error

hrebeniuk commented 3 years ago

getting the same error

farfromrefug commented 3 years ago

Can you share the error callstack

aribghilas commented 3 years ago

getting the same error

jamescodesthings commented 3 years ago

@farfromrefug

Stack from the same error here, android only issue for me, ios works a charm using the latest packages:

TypeError: Cannot read property 'https' of undefined
JS:     at getClient (file: node_modules/@nativescript-community/https/https.android.js:265:0)
JS:     at createRequest (file: node_modules/@nativescript-community/https/https.android.js:370:0)
JS:     at file: node_modules/@nativescript-community/https/https.android.js:512:0
JS:     at new ZoneAwarePromise (file: node_modules/@nativescript/zone-js/zone-nativescript.js:902:0)
JS:     at Object.request (file: node_modules/@nativescript-community/https/https.android.js:510:0)
JS:     at ApiService.request (file: src/app/shared/services/api.service.ts:110:34)
JS:     at ApiService.post (file: src/app/shared/services/api.service.ts:51:20)
JS:     at AuthService.auth (file: src/app/shared/services/auth.service.ts:212:32)
JS:     at file: src/app/shared/services/auth.service.ts:61:17
JS:     at new ZoneAwarePromise (file: node_modules/@nativescript/zone-js/zone-nativescript.js:902:0)
JS:     at AuthService.signIn (file://...
JS: Error message: Cannot read property 'https' of undefined

looks like it's this line:

cookieJar = new com.nativescript.https.QuotePreservingCookieJar(cookieManager);

Using @nstudio/nativescript-https@3 as suggested by https://nativescript.org/blog/nativescript-7-compatible-plugins/ does not have this issue but has loads more for me on android.

Env for me is:

ns info
✔ Getting NativeScript components versions information...
✔ Component nativescript has 7.0.3 version and is up to date.
✔ Component @nativescript/core has 7.0.0 version and is up to date.
✔ Component @nativescript/ios has 7.0.0 version and is up to date.
✔ Component @nativescript/android has 7.0.0 version and is up to date.

node@latest & npm@latest on osx via nvm.
project is loosely based on  tns-template-drawer-navigation-ng

running on a Pixel 3a AVD @ api level 30 w/Play services

For anyone updating to nativescript@7, what I've tried: @nstudio/nativescript-https@3.0.0:

nativescript-https@2.2.1: This error. nativescript-https@2.1.0: works.

My webpack resolve/alias are:

alias: {
        "utils/utils": "@nativescript/core/utils",
        "tns-core-modules/ui/core/view/view": "@nativescript/core/ui/core/view",
        "tns-core-modules/file-system/file-system": "@nativescript/core/file-system",
        '~/package.json': resolve(projectRoot, 'package.json'),
        '~': appFullPath,
        "tns-core-modules": "@nativescript/core",
        "nativescript-angular": "@nativescript/angular",
      },

I forget if any of those were due to nativescript-https@2.1.0 on nativescript@7 but worth mentioning in case anyone's here with similar issues to me.

farfromrefug commented 3 years ago

@jamescodesthings awesome that s what i need to fix this! So what s happening is that it is not finding a native library, or more precisely not building it. So you understand QuotePreservingCookieJar comes as java source with this plugin. For some reason it is not picked up by your app. There might be multiple reasons to that:

PS: i dont know about the nstudio version. It is a direct fork of this so it dont know. PS2: 2.1.0 is working because it was not supporting cookis and thus was not needing that native class

jamescodesthings commented 3 years ago

Makes sense to me, just jumping into a meeting I'll get back to your questions after =]

jamescodesthings commented 3 years ago

We're not doing any metadata filtering and there are no errors in the gradle build/ns build.

I'm not seeing it being built at all.

Checked out the node_modules folder for the package and found no java/aar files in there. If I copy the contents of java/com/nativescript/https (downloaded from github) to my node_modules folder and rebuild I get a Built aar for nativescript-https during prepare and then things work again.

Checking out the .npmignore the java files in the repo are ignored https://github.com/EddyVerbruggen/nativescript-https/blob/master/src/.npmignore

Not sure if there's meant to be an aar being packaged during the publish step to npm or if it's just meant to be the java files in the plugin?

farfromrefug commented 3 years ago

Awesome thanks ! and I know now why it worked here. I will release in a few hours! Sorry for the trouble Edit: no aar packaged. Npmignore is the issue here! My fault

farfromrefug commented 3 years ago

@jamescodesthings should be fixed in 2.2.2! Let me know

aribghilas commented 3 years ago

for me i just add the "httpbin.org.cer" (demo/app/asstets) to the Android Emulator and that's worked . to add the file to an adroid Emulator see https://medium.com/@noumaan/ssl-app-dev-a2923d5113c6 at " Android Emulator"

jamescodesthings commented 3 years ago

Hey @farfromrefug sorry for the delay, had to refactor our use of the plugin to test. It works now at version 2.2.2. Cracking job, cheers =]