diff --git a/CHANGELOG.md b/CHANGELOG.md index 277badc..e87202e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [3.3.5](https://github.com/farfromrefug/nativescript-https/compare/v3.3.4...v3.3.5) (2022-01-14) + +**Note:** Version bump only for package @nativescript-community/https + + + + + ## [3.3.4](https://github.com/farfromrefug/nativescript-https/compare/v3.3.3...v3.3.4) (2022-01-14) diff --git a/lerna.json b/lerna.json index ee62259..5d36e71 100644 --- a/lerna.json +++ b/lerna.json @@ -2,7 +2,7 @@ "packages": [ "plugin" ], - "version": "3.3.4", + "version": "3.3.5", "command": { "publish": { "conventionalCommits": true diff --git a/plugin/CHANGELOG.md b/plugin/CHANGELOG.md index 81c7cec..1e0cd6a 100644 --- a/plugin/CHANGELOG.md +++ b/plugin/CHANGELOG.md @@ -3,6 +3,14 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [3.3.5](https://github.com/farfromrefug/nativescript-https/compare/v3.3.4...v3.3.5) (2022-01-14) + +**Note:** Version bump only for package @nativescript-community/https + + + + + ## [3.3.4](https://github.com/farfromrefug/nativescript-https/compare/v3.3.3...v3.3.4) (2022-01-14) diff --git a/plugin/package.json b/plugin/package.json index 1bb33b0..7983328 100644 --- a/plugin/package.json +++ b/plugin/package.json @@ -1,6 +1,6 @@ { "name": "@nativescript-community/https", - "version": "3.3.4", + "version": "3.3.5", "description": "Nativescript plugin for gestures", "main": "https", "sideEffects": false, diff --git a/src/https.android.ts b/src/https.android.ts index ec0238b..f129536 100644 --- a/src/https.android.ts +++ b/src/https.android.ts @@ -267,17 +267,17 @@ function getClient(reload: boolean = false, timeout: number = 10): okhttp3.OkHtt cookieJar = new com.nativescript.https.QuotePreservingCookieJar(cookieManager); } - const client = new okhttp3.OkHttpClient.Builder(); - Https.interceptors.forEach((interceptor) => client.addInterceptor(interceptor)); - Https.networkInterceptors.forEach((interceptor) => client.addNetworkInterceptor(interceptor)); + const builder = new okhttp3.OkHttpClient.Builder(); + Https.interceptors.forEach((interceptor) => builder.addInterceptor(interceptor)); + Https.networkInterceptors.forEach((interceptor) => builder.addNetworkInterceptor(interceptor)); if (peer.enabled === true) { if (peer.host || peer.certificate) { const spec = okhttp3.ConnectionSpec.MODERN_TLS; - client.connectionSpecs(java.util.Collections.singletonList(spec)); + builder.connectionSpecs(java.util.Collections.singletonList(spec)); const pinner = new okhttp3.CertificatePinner.Builder(); pinner.add(peer.host, [peer.certificate]); - client.certificatePinner(pinner.build()); + builder.certificatePinner(pinner.build()); if (peer.allowInvalidCertificates === false) { try { @@ -299,7 +299,7 @@ function getClient(reload: boolean = false, timeout: number = 10): okhttp3.OkHtt const sslContext = javax.net.ssl.SSLContext.getInstance('TLS'); sslContext.init(keyManagers, trustManagerFactory.getTrustManagers(), new java.security.SecureRandom()); - client.sslSocketFactory(sslContext.getSocketFactory()); + builder.sslSocketFactory(sslContext.getSocketFactory()); } catch (error) { console.error('@nativescript-community/https > client.allowInvalidCertificates error', error); } @@ -307,7 +307,7 @@ function getClient(reload: boolean = false, timeout: number = 10): okhttp3.OkHtt if (peer.validatesDomainName === true) { try { - client.hostnameVerifier( + builder.hostnameVerifier( new javax.net.ssl.HostnameVerifier({ verify: (hostname: string, session: javax.net.ssl.SSLSession): boolean => { const pp = session.getPeerPrincipal().getName(); @@ -330,19 +330,19 @@ function getClient(reload: boolean = false, timeout: number = 10): okhttp3.OkHtt } _timeout = timeout; - client.connectTimeout(timeout, java.util.concurrent.TimeUnit.SECONDS).writeTimeout(timeout, java.util.concurrent.TimeUnit.SECONDS).readTimeout(timeout, java.util.concurrent.TimeUnit.SECONDS); + builder.connectTimeout(timeout, java.util.concurrent.TimeUnit.SECONDS).writeTimeout(timeout, java.util.concurrent.TimeUnit.SECONDS).readTimeout(timeout, java.util.concurrent.TimeUnit.SECONDS); if (cache) { - client.cache(cache); + builder.cache(cache); if (forceCache) { - client.addInterceptor(new com.nativescript.https.CacheInterceptor()); + builder.addInterceptor(new com.nativescript.https.CacheInterceptor()); } } if (cookieJar) { - client.cookieJar(cookieJar); + builder.cookieJar(cookieJar); } - Client = client.build(); + Client = builder.build(); return Client; } diff --git a/src/https.common.ts b/src/https.common.ts index 296c325..d5aa975 100644 --- a/src/https.common.ts +++ b/src/https.common.ts @@ -54,10 +54,10 @@ export interface HttpsRequestOptions extends HttpRequestOptions { useLegacy?: boolean; } -export interface HttpsResponse { +export interface HttpsResponse { headers?: Headers; statusCode?: number; - content?: any; + content?: T; reason?: string; description?: string; url?: string; diff --git a/src/https.d.ts b/src/https.d.ts index a304251..8f46418 100644 --- a/src/https.d.ts +++ b/src/https.d.ts @@ -4,7 +4,7 @@ export function enableSSLPinning(options: Https.HttpsSSLPinningOptions); export function disableSSLPinning(); -export function request(options: Https.HttpsRequestOptions): Promise; +export function request(options: Https.HttpsRequestOptions): Promise>; export function setCache(options?: Https.CacheOptions); export function clearCache(); export function createRequest(opts: Https.HttpsRequestOptions): Https.HttpsRequest;