Skip to content

Commit a5c841c

Browse files
Linting
1 parent 433f9a4 commit a5c841c

File tree

14 files changed

+706
-699
lines changed

14 files changed

+706
-699
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
11
# NativeScript-HTTPS
2+
3+
[![NPM version][npm-image]][npm-url]
4+
[![Downloads][downloads-image]][npm-url]
5+
[![TotalDownloads][total-downloads-image]][npm-url]
6+
[![Twitter Follow][twitter-image]][twitter-url]
7+
8+
[build-status]:https://travis-ci.org/EddyVerbruggen/nativescript-https.svg?branch=master
9+
[build-url]:https://travis-ci.org/EddyVerbruggen/nativescript-https
10+
[npm-image]:http://img.shields.io/npm/v/nativescript-https.svg
11+
[npm-url]:https://npmjs.org/package/nativescript-https
12+
[downloads-image]:http://img.shields.io/npm/dm/nativescript-https.svg
13+
[total-downloads-image]:http://img.shields.io/npm/dt/nativescript-https.svg?label=total%20downloads
14+
[twitter-image]:https://img.shields.io/twitter/follow/eddyverbruggen.svg?style=social&label=Follow%20me
15+
[twitter-url]:https://twitter.com/eddyverbruggen
16+
217
### The definitive way to hit HTTP based APIs in Nativescript.
318
Easily integrate the most reliable native networking libraries with the latest and greatest HTTPS security features.
19+
420
#### A drop-in replacement for the [default http module](https://docs.nativescript.org/cookbook/http#get-response-status-code).
521

622
## Features

demo/app/App_Resources/Android/app.gradle

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
// compile 'com.android.support:recyclerview-v7:+'
66
//}
77

8-
android {
9-
defaultConfig {
8+
android {
9+
defaultConfig {
1010
generatedDensities = []
11-
applicationId = "org.nativescript.demo"
12-
}
13-
aaptOptions {
14-
additionalParameters "--no-version-vectors"
15-
}
16-
}
11+
applicationId = "org.nativescript.plugindemo.https"
12+
}
13+
aaptOptions {
14+
additionalParameters "--no-version-vectors"
15+
}
16+
}

demo/app/app.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
import * as application from 'tns-core-modules/application';
2-
application.start({ moduleName: "main-page" });
2+
3+
application.start({moduleName: "main-page"});

demo/app/main-page.ts

Lines changed: 54 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,70 @@
1-
import * as Observable from 'tns-core-modules/data/observable'
2-
import * as Page from 'tns-core-modules/ui/page'
3-
import * as fs from 'tns-core-modules/file-system'
4-
import * as dialogs from 'tns-core-modules/ui/dialogs'
5-
import * as Https from 'nativescript-https'
1+
import * as Observable from 'tns-core-modules/data/observable';
2+
import * as Page from 'tns-core-modules/ui/page';
3+
import * as fs from 'tns-core-modules/file-system';
4+
import * as dialogs from 'tns-core-modules/ui/dialogs';
5+
import * as Https from 'nativescript-https';
66

77
export function onNavigatingTo(args: Page.NavigatedData) {
8-
let page = args.object as Page.Page
9-
page.bindingContext = Observable.fromObject({ enabled: false })
8+
let page = args.object as Page.Page;
9+
page.bindingContext = Observable.fromObject({enabled: false});
1010
}
1111

1212
function getRequest(url: string, allowLargeResponse = false) {
13-
Https.request({
14-
url,
15-
method: 'GET',
16-
allowLargeResponse
17-
}).then(function(response) {
18-
console.log('Https.request response', response)
19-
}).catch(function(error) {
20-
console.error('Https.request error', error)
21-
dialogs.alert(error)
22-
})
13+
Https.request(
14+
{
15+
url,
16+
method: 'GET',
17+
allowLargeResponse
18+
})
19+
.then(response => console.log('Https.request response', response))
20+
.catch(error => {
21+
console.error('Https.request error', error);
22+
dialogs.alert(error);
23+
});
2324
}
2425

2526
function postRequest(url: string, body: any) {
26-
Https.request({
27-
url,
28-
method: 'POST',
29-
body
30-
}).then(function(response) {
31-
console.log('Https.request response', response)
32-
}).catch(function(error) {
33-
console.error('Https.request error', error)
34-
dialogs.alert(error)
35-
})
36-
}
37-
38-
export function postHttpbin() { postRequest('https://httpbin.org/post', {"foo": "bar", "baz": undefined, "plaz": null}) }
39-
export function getHttpbin() { getRequest('https://httpbin.org/get') }
40-
export function getHttpbinLargeResponse() { getRequest('https://httpbin.org/bytes/100000', true) }
41-
export function getMockbin() { getRequest('https://mockbin.com/request') }
27+
Https.request(
28+
{
29+
url,
30+
method: 'POST',
31+
body
32+
})
33+
.then(response => console.log('Https.request response', response))
34+
.catch(error => {
35+
console.error('Https.request error', error);
36+
dialogs.alert(error);
37+
});
38+
}
39+
40+
export function postHttpbin() {
41+
postRequest('https://httpbin.org/post', {"foo": "bar", "baz": undefined, "plaz": null});
42+
}
43+
44+
export function getHttpbin() {
45+
getRequest('https://httpbin.org/get');
46+
}
47+
48+
export function getHttpbinLargeResponse() {
49+
getRequest('https://httpbin.org/bytes/100000', true);
50+
}
51+
52+
export function getMockbin() {
53+
getRequest('https://mockbin.com/request');
54+
}
4255

4356
export function enableSSLPinning(args: Observable.EventData) {
44-
let dir = fs.knownFolders.currentApp().getFolder('assets')
45-
let certificate = dir.getFile('httpbin.org.cer').path
46-
Https.enableSSLPinning({ host: 'httpbin.org', certificate })
47-
let context = (args.object as Page.View).bindingContext as Observable.Observable
48-
context.set('enabled', true)
57+
let dir = fs.knownFolders.currentApp().getFolder('assets');
58+
let certificate = dir.getFile('httpbin.org.cer').path;
59+
Https.enableSSLPinning({host: 'httpbin.org', certificate});
60+
let context = (args.object as Page.View).bindingContext as Observable.Observable;
61+
context.set('enabled', true);
4962
}
5063

5164
export function disableSSLPinning(args: Observable.EventData) {
52-
Https.disableSSLPinning()
53-
let context = (args.object as Page.View).bindingContext as Observable.Observable
54-
context.set('enabled', false)
65+
Https.disableSSLPinning();
66+
let context = (args.object as Page.View).bindingContext as Observable.Observable;
67+
context.set('enabled', false);
5568
}
5669

5770

demo/app/main-page.xml

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
<Page class="page" navigatingTo="onNavigatingTo">
2-
<Page.actionBar>
3-
<ActionBar title="HTTPS Playground" class="action-bar"></ActionBar>
4-
</Page.actionBar>
2+
<Page.actionBar>
3+
<ActionBar title="HTTPS Playground" class="action-bar"></ActionBar>
4+
</Page.actionBar>
55

6-
<StackLayout class="p-20">
7-
<Label class="h1 text-center" color="{{ enabled ? 'green' : 'red' }}" text="{{ enabled ? 'Httpbin SSL Pinning Enabled' : 'SSL Pinning Disabled' }}" />
8-
<Button text="GET Mockbin" tap="getMockbin" class="t-20 btn btn-primary btn-active" />
9-
<Button text="GET Httpbin" tap="getHttpbin" class="t-20 btn btn-primary btn-active" />
10-
<Button text="GET Httpbin (large response)" tap="getHttpbinLargeResponse" class="t-20 btn btn-primary btn-active" />
11-
<Button text="POST Httpbin " tap="postHttpbin" class="t-20 btn btn-primary btn-active" />
12-
<Button text="Enable Httpbin SSL Pinning" tap="enableSSLPinning" class="t-20 btn btn-primary btn-active" />
13-
<Button text="Disable SSL Pinning" tap="disableSSLPinning" class="t-20 btn btn-primary btn-active" />
14-
<Label text="Here's a spinner to show the main thread is not blocked by network IO" textWrap="true" class="m-20"/>
15-
<ActivityIndicator busy="true" />
16-
</StackLayout>
6+
<StackLayout class="p-20">
7+
<Label class="h1 text-center" color="{{ enabled ? 'green' : 'red' }}" text="{{ enabled ? 'Httpbin SSL Pinning Enabled' : 'SSL Pinning Disabled' }}"/>
8+
<Button text="GET Mockbin" tap="getMockbin" class="t-20 btn btn-primary btn-active"/>
9+
<Button text="GET Httpbin" tap="getHttpbin" class="t-20 btn btn-primary btn-active"/>
10+
<Button text="GET Httpbin (large response)" tap="getHttpbinLargeResponse" class="t-20 btn btn-primary btn-active"/>
11+
<Button text="POST Httpbin " tap="postHttpbin" class="t-20 btn btn-primary btn-active"/>
12+
<Button text="Enable Httpbin SSL Pinning" tap="enableSSLPinning" class="t-20 btn btn-primary btn-active"/>
13+
<Button text="Disable SSL Pinning" tap="disableSSLPinning" class="t-20 btn btn-primary btn-active"/>
14+
<Label text="Here's a spinner to show the main thread is not blocked by network IO" textWrap="true" class="m-20"/>
15+
<ActivityIndicator busy="true"/>
16+
</StackLayout>
1717

1818
</Page>

demo/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"nativescript": {
3-
"id": "org.nativescript.demo",
3+
"id": "org.nativescript.plugindemo.https",
44
"tns-android": {
55
"version": "5.4.0"
66
},

demo/tsconfig.json

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
11
{
2-
"compilerOptions": {
3-
"target": "es5",
4-
"module": "commonjs",
5-
"declaration": false,
6-
"removeComments": true,
7-
"noLib": false,
8-
"emitDecoratorMetadata": true,
9-
"experimentalDecorators": true,
10-
"lib": [
11-
"es6",
12-
"dom"
13-
],
14-
"pretty": true,
15-
"allowUnreachableCode": false,
16-
"allowUnusedLabels": false,
17-
"noEmitHelpers": true,
18-
"noEmitOnError": false,
19-
"noImplicitAny": false,
20-
"noImplicitReturns": true,
21-
"noImplicitUseStrict": false,
22-
"noFallthroughCasesInSwitch": true,
23-
"baseUrl": ".",
24-
"paths": {
25-
"*": [
26-
"./node_modules/*"
27-
],
28-
"~/*": [
29-
"app/*"
30-
]
31-
}
32-
},
33-
"include": [
34-
"**/*"
2+
"compilerOptions": {
3+
"target": "es5",
4+
"module": "commonjs",
5+
"declaration": false,
6+
"removeComments": true,
7+
"noLib": false,
8+
"emitDecoratorMetadata": true,
9+
"experimentalDecorators": true,
10+
"lib": [
11+
"es6",
12+
"dom"
3513
],
36-
"exclude": [
37-
"node_modules",
38-
"platforms"
39-
],
40-
"compileOnSave": false
14+
"pretty": true,
15+
"allowUnreachableCode": false,
16+
"allowUnusedLabels": false,
17+
"noEmitHelpers": true,
18+
"noEmitOnError": false,
19+
"noImplicitAny": false,
20+
"noImplicitReturns": true,
21+
"noImplicitUseStrict": false,
22+
"noFallthroughCasesInSwitch": true,
23+
"baseUrl": ".",
24+
"paths": {
25+
"*": [
26+
"./node_modules/*"
27+
],
28+
"~/*": [
29+
"app/*"
30+
]
31+
}
32+
},
33+
"include": [
34+
"**/*"
35+
],
36+
"exclude": [
37+
"node_modules",
38+
"platforms"
39+
],
40+
"compileOnSave": false
4141
}

demo/tsconfig.tns.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"extends": "./tsconfig",
3-
"compilerOptions": {
4-
"module": "es2015",
5-
"moduleResolution": "node"
6-
}
2+
"extends": "./tsconfig",
3+
"compilerOptions": {
4+
"module": "es2015",
5+
"moduleResolution": "node"
6+
}
77
}

0 commit comments

Comments
 (0)