Skip to content
This repository was archived by the owner on Jul 30, 2023. It is now read-only.

Commit e326369

Browse files
committed
chore(remove unused code), chore(fix build error)
1 parent 04d4a79 commit e326369

File tree

11 files changed

+53
-239
lines changed

11 files changed

+53
-239
lines changed

AFNetworking.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
declare class AFAutoPurgingImageCache extends NSObject implements AFImageRequestCache {
32

43
static alloc(): AFAutoPurgingImageCache; // inherited from NSObject

com.squareup.okhttp3.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
declare module okhttp3 {
32
export class Address extends java.lang.Object {
43
public proxy(): java.net.Proxy;

https.android.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

https.android.ts

Lines changed: 8 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,8 @@
1-
//
2-
3-
4-
import * as application from 'application'
5-
import { HttpRequestOptions, Headers, HttpResponse } from 'http'
6-
import { isDefined, isNullOrUndefined } from 'utils/types'
1+
import * as application from 'tns-core-modules/application'
2+
import { HttpRequestOptions, Headers, HttpResponse } from 'tns-core-modules/http'
3+
import { isDefined, isNullOrUndefined } from 'tns-core-modules/utils/types'
74
import * as Https from './https.common'
85

9-
10-
11-
// declare var java: any
12-
// declare var javax: any
13-
// java.security.cert.Certificate as any
14-
// declare module java {
15-
// export module security {
16-
// export module cert {
17-
// export interface Certificate { }
18-
// }
19-
// }
20-
// export module io {
21-
// export interface FileInputStream { }
22-
// }
23-
// }
24-
25-
26-
276
interface Ipeer {
287
enabled: boolean
298
allowInvalidCertificates: boolean
@@ -39,7 +18,6 @@ let peer: Ipeer = {
3918
}
4019

4120
export function enableSSLPinning(options: Https.HttpsSSLPinningOptions) {
42-
// console.log('options', options)
4321
if (!peer.host && !peer.certificate) {
4422
let certificate: string
4523
let inputStream: java.io.FileInputStream
@@ -79,24 +57,14 @@ export function disableSSLPinning() {
7957
}
8058
console.info('nativescript-https > Disabled SSL pinning by default')
8159

82-
83-
8460
let Client: okhttp3.OkHttpClient
8561
function getClient(reload: boolean = false): okhttp3.OkHttpClient {
86-
// if (!Client) {
87-
// Client = new okhttp3.OkHttpClient()
88-
// }
89-
// if (Client) {
90-
// Client.connectionPool().evictAll()
91-
// Client = null
92-
// }
9362
if (Client && reload == false) {
9463
return Client
9564
}
9665

9766
let client = new okhttp3.OkHttpClient.Builder()
9867
if (peer.enabled == true) {
99-
// console.log('peer', peer)
10068
if (peer.host || peer.certificate) {
10169
let spec = okhttp3.ConnectionSpec.MODERN_TLS
10270
client.connectionSpecs(java.util.Collections.singletonList(spec))
@@ -139,7 +107,7 @@ function getClient(reload: boolean = false): okhttp3.OkHttpClient {
139107
if (peer.validatesDomainName == true) {
140108
try {
141109
client.hostnameVerifier(new javax.net.ssl.HostnameVerifier({
142-
verify: function(hostname: string, session: javax.net.ssl.ISSLSession): boolean {
110+
verify: function (hostname: string, session: javax.net.ssl.ISSLSession): boolean {
143111
let pp = session.getPeerPrincipal().getName()
144112
let hv = javax.net.ssl.HttpsURLConnection.getDefaultHostnameVerifier()
145113
return (
@@ -169,15 +137,15 @@ function getClient(reload: boolean = false): okhttp3.OkHttpClient {
169137
const strictModeThreadPolicyPermitAll = new android.os.StrictMode.ThreadPolicy.Builder().permitAll().build()
170138

171139
export function request(opts: Https.HttpsRequestOptions): Promise<Https.HttpsResponse> {
172-
return new Promise(function(resolve, reject) {
140+
return new Promise(function (resolve, reject) {
173141
try {
174142
let client = getClient()
175143

176144
let request = new okhttp3.Request.Builder()
177145
request.url(opts.url)
178146

179147
if (opts.headers) {
180-
Object.keys(opts.headers).forEach(function(key) {
148+
Object.keys(opts.headers).forEach(function (key) {
181149
request.addHeader(key, opts.headers[key] as any)
182150
})
183151
}
@@ -214,28 +182,7 @@ export function request(opts: Https.HttpsRequestOptions): Promise<Https.HttpsRes
214182
android.os.StrictMode.setThreadPolicy(strictModeThreadPolicyPermitAll)
215183

216184
client.newCall(request.build()).enqueue(new okhttp3.Callback({
217-
onResponse: function(task, response) {
218-
// console.log('onResponse')
219-
// console.keys('response', response)
220-
// console.log('onResponse > response.isSuccessful()', response.isSuccessful())
221-
222-
// let body = response.body()//.bytes()
223-
// console.keys('body', body)
224-
// console.log('body.contentType()', body.contentType())
225-
// console.log('body.contentType().toString()', body.contentType().toString())
226-
// console.log('body.bytes()', body.bytes())
227-
// console.dump('wtf', wtf)
228-
// console.log('opts.url', opts.url)
229-
// console.log('body.string()', body.string())
230-
231-
// let content: any = response.body().string()
232-
// console.log('content', content)
233-
// try {
234-
// content = JSON.parse(response.body().string())
235-
// } catch (error) {
236-
// return reject(error)
237-
// }
238-
185+
onResponse: function (task, response) {
239186
let content = response.body().string()
240187
try {
241188
content = JSON.parse(content)
@@ -255,7 +202,7 @@ export function request(opts: Https.HttpsRequestOptions): Promise<Https.HttpsRes
255202
resolve({ content, statusCode, headers })
256203

257204
},
258-
onFailure: function(task, error) {
205+
onFailure: function (task, error) {
259206
reject(error)
260207
},
261208
}))
@@ -265,36 +212,6 @@ export function request(opts: Https.HttpsRequestOptions): Promise<Https.HttpsRes
265212
}
266213

267214
})
268-
269-
// {
270-
// "content": {
271-
// "code": "PreconditionFailed",
272-
// "message": "!x-uuid"
273-
// },
274-
// "statusCode": 412,
275-
// "headers": {
276-
// "Content-Length": "49",
277-
// "Server": "nginx/1.10.1",
278-
// "Content-Type": "application/json",
279-
// "Connection": "keep-alive",
280-
// "Date": "Mon, 26 Dec 2016 03:31:42 GMT"
281-
// }
282-
// }
283-
284215
}
285216

286-
287-
288217
export * from './https.common'
289-
290-
291-
292-
293-
294-
295-
296-
297-
298-
299-
300-

https.common.d.ts

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
//
2-
31
import { HttpRequestOptions, Headers } from 'http'
42

5-
6-
73
export interface HttpsSSLPinningOptions {
84
host: string
95
certificate: string
@@ -30,15 +26,3 @@ export interface HttpsResponse {
3026
reason?: string
3127
reject?: boolean
3228
}
33-
34-
35-
36-
37-
38-
39-
40-
41-
42-
43-
44-

https.d.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
1-
//
2-
31
import { HttpRequestOptions, Headers, HttpResponse } from 'http'
42
import * as Https from './https.common'
53

6-
7-
84
export declare function enableSSLPinning(options: Https.HttpsSSLPinningOptions);
95
export declare function disableSSLPinning();
106
export declare function request(options: Https.HttpsRequestOptions): Promise<Https.HttpsResponse>;
117

12-
13-
148
export * from './https.common'

https.ios.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)