Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ demo/report/stats.json
/src/pnpm-lock.yaml
package-lock.json
/package
*.tgz
3 changes: 2 additions & 1 deletion src/.npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ platforms/ios/typings
platforms/android/*
!platforms/android/include.gradle
!platforms/android/*.aar
!platforms/android/*.jar
!platforms/android/*.jar
*.tgz
9 changes: 3 additions & 6 deletions src/https.android.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { isDefined } from "@nativescript/core/utils/types";
import { HttpResponseEncoding } from "@nativescript/core/http";
import { ImageSource } from "@nativescript/core/image-source";
import { Utils, HttpResponseEncoding, ImageSource, File } from "@nativescript/core";
import * as Https from "./https.common";
import { File } from "@nativescript/core/file-system";

interface Ipeer {
enabled: boolean;
Expand Down Expand Up @@ -491,8 +488,8 @@ export function createRequest(
if (
["GET", "HEAD"].indexOf(opts.method) !== -1 ||
(opts.method === "DELETE" &&
!isDefined(opts.body) &&
!isDefined(opts.content))
!Utils.isDefined(opts.body) &&
!Utils.isDefined(opts.content))
) {
request[methods[opts.method]]();
} else {
Expand Down
4 changes: 1 addition & 3 deletions src/https.common.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { Headers, HttpRequestOptions } from "@nativescript/core/http";
import { ImageSource } from "@nativescript/core/image-source";
import { File } from "@nativescript/core/file-system";
import { Headers, HttpRequestOptions, ImageSource, File } from "@nativescript/core";
export interface HttpsSSLPinningOptions {
host: string;
certificate: string;
Expand Down
4 changes: 1 addition & 3 deletions src/https.common.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { Headers, HttpRequestOptions } from "@nativescript/core/http";
import { ImageSource } from "@nativescript/core/image-source";
import { File, knownFolders, path } from "@nativescript/core/file-system";
import { Headers, HttpRequestOptions, ImageSource, File, knownFolders, path } from "@nativescript/core";

export interface HttpsSSLPinningOptions {
host: string;
Expand Down
22 changes: 10 additions & 12 deletions src/https.ios.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import {
isDefined,
isNullOrUndefined,
isObject,
} from "@nativescript/core/utils/types";
Utils,
File,
ImageSource
} from "@nativescript/core";
import * as Https from "./https.common";
import { File } from "@nativescript/core/file-system";
import { ImageSource } from "@nativescript/core/image-source";

let cache: NSURLCache;

Expand Down Expand Up @@ -44,12 +42,12 @@ export function enableSSLPinning(options: Https.HttpsSSLPinningOptions) {
policies.secure = AFSecurityPolicy.policyWithPinningMode(
AFSSLPinningMode.PublicKey
);
policies.secure.allowInvalidCertificates = isDefined(
policies.secure.allowInvalidCertificates = Utils.isDefined(
options.allowInvalidCertificates
)
? options.allowInvalidCertificates
: false;
policies.secure.validatesDomainName = isDefined(
policies.secure.validatesDomainName = Utils.isDefined(
options.validatesDomainName
)
? options.validatesDomainName
Expand Down Expand Up @@ -371,7 +369,7 @@ function AFFailure(
let response = error.userInfo.valueForKey(
AFNetworkingOperationFailingURLResponseErrorKey
) as NSHTTPURLResponse;
if (!isNullOrUndefined(response)) {
if (!Utils.isNullOrUndefined(response)) {
sendi.statusCode = response.statusCode;
getHeaders = function () {
let dict = response.allHeaderFields;
Expand Down Expand Up @@ -434,7 +432,7 @@ function bodyToNative(cont) {
// cont.forEach(function(item, idx) {
// dict.addObject(bodyToNative(item));
// });
} else if (isObject(cont)) {
} else if (Utils.isObject(cont)) {
dict = NSMutableDictionary.new<string, any>();
Object.keys(cont).forEach((key) =>
dict.setValueForKey(bodyToNative(cont[key]), key)
Expand Down Expand Up @@ -511,7 +509,7 @@ export function createRequest(
? opts.timeout
: 10;

const useLegacy = isDefined(opts.useLegacy) ? opts.useLegacy : false;
const useLegacy = Utils.isDefined(opts.useLegacy) ? opts.useLegacy : false;

const progress = opts.onProgress
? (progress: NSProgress) => {
Expand Down Expand Up @@ -543,7 +541,7 @@ export function createRequest(
};

let response = task.response as NSHTTPURLResponse;
if (!isNullOrUndefined(response)) {
if (!Utils.isNullOrUndefined(response)) {
sendi.statusCode = response.statusCode;
getHeaders = function () {
let dict = response.allHeaderFields;
Expand Down
8 changes: 4 additions & 4 deletions src/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nativescript-https",
"version": "2.1.0",
"version": "3.0.0",
"description": "Secure HTTP client with SSL pinning for Nativescript - iOS/Android.",
"main": "https",
"typings": "index.d.ts",
Expand Down Expand Up @@ -29,9 +29,9 @@
},
"dependencies": {},
"devDependencies": {
"@nativescript/core": "~6.5.1",
"tns-platform-declarations": "~6.5.1",
"typescript": "3.8.3",
"@nativescript/core": "rc",
"@nativescript/types": "rc",
"typescript": "~3.9.0",
"prompt": "^1.0.0",
"rimraf": "^3.0.2",
"tslint": "^6.1.1",
Expand Down
4 changes: 2 additions & 2 deletions src/references.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// <reference path="./node_modules/tns-platform-declarations/ios.d.ts" />
/// <reference path="./node_modules/tns-platform-declarations/android.d.ts" />
/// <reference path="./node_modules/@nativescript/types/ios.d.ts" />
/// <reference path="./node_modules/@nativescript/types/android.d.ts" />

/// <reference path="./platforms/android/typings/okio.d.ts" />
/// <reference path="./platforms/android/typings/okhttp3.d.ts" />
Expand Down
5 changes: 3 additions & 2 deletions src/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"target": "es2017",
"module": "esnext",
"moduleResolution": "node",
"declaration": true,
"removeComments": true,
"noLib": false,
Expand Down