Commit 62159068 authored by Davide De Rosa's avatar Davide De Rosa

Initial commit

parents
# Summary
### Steps to reproduce
(Please provide detail steps).
### What is the current bug behaviour?
(What actually happens).
### What is the expected correct behaviour?
(What you should see instead).
### Relevant logs and/or screenshots
### Possible fixes suggested re-mediation
### Assignees and labels
( please add labels as applicable )
- [ ] Patched
- [ ] Verified patch
A similar PR may already be submitted!
Please search among the Pull requests before creating one.
Thanks for submitting a pull request! Please provide enough information so that others can review your pull request:
For more information, see the [CONTRIBUTING](/.github.com/CONTRIBUTING.md) readme or the contributing [guide](https://pia-oss.github.io/contribute).
**Summary**
<!-- Summary of the PR -->
This PR fixes/implements the following **bugs/features**
* [ ] Bug 1
* [ ] Bug 2
* [ ] Feature 1
* [ ] Feature 2
* [ ] Breaking changes
<!-- You can skip this if you're fixing a typo or adding an app to the Showcase. -->
Explain the **motivation** for making this change. What existing problem does the pull request solve?
<!-- Example: When "Adding a function to do X", explain why it is necessary to have a way to do X. -->
**Test plan (required)**
Demonstrate the code is solid. Example: The exact commands you ran and their output, screenshots / videos if the pull request changes UI.
<!-- Make sure tests pass on both Travis and Circle CI. -->
**Code formatting**
<!-- See the simple style guide. -->
**Closing issues**
<!-- Put `closes #XXXX` in your comment to auto-close the issue that your PR fixes (if such). -->
Fixes #
\ No newline at end of file
.DS_Store
*.swp
*.pbxuser
**/*.xcworkspace/xcuserdata
**/*.xcodeproj/project.xcworkspace
**/*.xcodeproj/xcuserdata
docs
Pods
clean:
module: "PIALibrary"
author: "Davide De Rosa @ London Trust Media, Inc."
author_url: "https://www.privateinternetaccess.com"
theme: fullwidth
xcodebuild_arguments:
- "-workspace"
- "PIALibrary.xcworkspace"
- "-scheme"
- "PIALibrary-iOS"
exclude:
- "**/Sources/Library/Account/**/*.swift"
- "**/Sources/Library/Daemons/**/*.swift"
- "**/Sources/Library/InApp/**/*.swift"
- "**/Sources/Library/Persistence/**/*.swift"
- "**/Sources/Library/Server/**/*.swift"
- "**/Sources/Library/WebServices/**/*.swift"
custom_categories:
- name: Client
children:
- Client
- ClientError
- LibraryCallback
- SuccessLibraryCallback
- Notification
- NotificationKey
- name: Account
children:
- Credentials
- Plan
- AccountInfo
- UserAccount
- LoginRequest
- SignupRequest
- RenewRequest
- UpdateAccountRequest
- AccountProvider
- name: Store
children:
- InAppProduct
- InAppTransaction
- name: Server
children:
- Server
- ServersBundle
- ServerProvider
- ServerError
- name: VPN
children:
- VPNProfile
- VPNConfiguration
- VPNCustomConfiguration
- VPNStatus
- VPNProvider
- VPNAction
- NetworkExtensionProfile
- IPSecProfile
- PIATunnelProfile
- name: Debug
children:
- LogTarget
- DebugLog
- name: Mock
children:
- MockAccountProvider
- MockServerProvider
- MockVPNProvider
- name: Util
children:
- Keychain
- KeychainError
- Macros
- PingerProtocol
- name: UI
children:
- ActivityButton
- AutolayoutViewController
- BorderedTextField
- CircleProgressView
- ModalController
- OptionsViewController
- OptionsViewControllerDelegate
- PIAWelcomeViewController
- PIAWelcomeViewControllerDelegate
- Restylable
- Theme
- ThemeStrategy
- UIAlertController
- Validator
# Contributor agreement
By contributing any improvement, modification, or change to this project, I hereby certify that:
(a) The contribution was authored or created in whole or in part by me and I have the full and unrestricted ownership right and title to submit the contribution under the MIT license; or
(b) The contribution is based upon previously authored work that, to the best of my knowledge, is licensed appropriately under an open source license and I have the full and unrestricted right under that open source license to submit that work with modifications, whether created in whole or in part by me, under the MIT license; or
(c) The contribution was lawfully provided to me by a licensed third-party who certified (a), (b) or (c) and I have not modified the contribution.
I understand and agree that the contents of this project and the contents of this contribution are considered to be part of the public record and that a record of the contribution (including all personal information I submit with it) shall be maintained indefinitely and may be redistributed to third-parties consistent with this terms of this project or the open source license(s) involved.
\ No newline at end of file
# Contribution Guidelines
Private Internet Access welcomes community contributions, and are always looking for ways in which to improve. Please take a look at our contribution guidelines, and get involved with the PIA community.
## Bugs and Issues
Have you found a bug? Is our software behaving in an unexpected way? Please check the open issues for duplicates -- perhaps a fix is already in development, or maybe a solution has already been published.
If not then please submit a bug report using our [template](/.github/ISSUE_TEMPLATE.md)
## Feature Requests
Feature requests can also be submitted as issues. We’d be grateful if you checked for duplicates also before submitting a feature request.
## Working with our Code
* Fork the repository. Make sure to keep your repository synced with the source repo.
* When you are ready to start working on a new feature, cut a new branch from `develop` with the prefix `feature/` (e.g. `feature/name-of-feature`).
* Refer to the [README](/README.md) for instructions on how to install and build.
## Making Pull Requests
* Sync the `develop` branch in your fork with the `develop` branch in the source repo.
* Merge your feature branch into `develop`.
* Make your pull request from `develop` in your fork to `develop` in the source.
* Use short and concise commit messages.
* Lint your code before committing and making a pull request.
* Write unit tests for new features and make sure all tests are passing.
* If your pull request contains multiple commits or commits that are not meaningful, consider squashing them.
.DS_Store
*.swp
*.pbxuser
**/*.xcworkspace/xcuserdata
**/*.xcodeproj/project.xcworkspace
**/*.xcodeproj/xcuserdata
Pods
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "group:Demo.xcodeproj">
</FileRef>
<FileRef
location = "group:Pods/Pods.xcodeproj">
</FileRef>
</Workspace>
source 'https://github.com/CocoaPods/Specs.git'
use_frameworks!
abstract_target 'iOS' do
platform :ios, '9.0'
target 'Welcome-iOS' do
pod 'PIALibrary/UI', :path => '..'
end
end
abstract_target 'macOS' do
platform :osx, '10.11'
end
PODS:
- Alamofire (4.6.0)
- Gloss (2.0.0)
- PIALibrary/Core (1.0)
- PIALibrary/Library (1.0):
- Alamofire (~> 4)
- Gloss (~> 2)
- PIALibrary/Core
- PIALibrary/Util
- ReachabilitySwift
- SwiftyBeaver
- PIALibrary/UI (1.0):
- PIALibrary/Library
- SwiftyBeaver
- TPKeyboardAvoiding
- PIALibrary/Util (1.0):
- PIALibrary/Core
- ReachabilitySwift (4.1.0)
- SwiftyBeaver (1.5.1)
- TPKeyboardAvoiding (1.3.2)
DEPENDENCIES:
- PIALibrary/UI (from `..`)
EXTERNAL SOURCES:
PIALibrary:
:path: ..
SPEC CHECKSUMS:
Alamofire: f41a599bd63041760b26d393ec1069d9d7b917f4
Gloss: b67617f327406adfd47adf20172d00680a3a31bd
PIALibrary: 006e84122b0c5b819d3afb9fe93ad710556ef631
ReachabilitySwift: 6849231cd4e06559f3b9ef4a97a0a0f96d41e09f
SwiftyBeaver: 4f74563624b2c1e821c522c54142b5dd5ebb0f30
TPKeyboardAvoiding: cb69d5ddbe90ce0170e4bc2db1e5e41d4a3ad9a4
PODFILE CHECKSUM: 8d181ca45bd9ae991a455b564a98f428cf31931b
COCOAPODS: 1.4.0
//
// AppDelegate.swift
// Welcome-iOS
//
// Created by Davide De Rosa on 10/20/17.
// Copyright © 2017 London Trust Media. All rights reserved.
//
import UIKit
import SwiftyBeaver
import PIALibrary
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
SwiftyBeaver.addDestination(ConsoleDestination())
Client.environment = .staging
Client.configuration.setPlan(.monthly, forProductIdentifier: "com.privateinternetaccess.ios.iap.1month")
Client.configuration.setPlan(.yearly, forProductIdentifier: "com.privateinternetaccess.ios.iap.1year")
Client.bootstrap()
Theme.current.palette.accent1 = .blue
Theme.current.palette.emphasis = .orange
Theme.current.applyAppearance()
return true
}
func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
}
func applicationDidEnterBackground(_ application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}
func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
}
{
"images" : [
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "20x20",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "20x20",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "1x"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "2x"
},
{
"idiom" : "ipad",
"size" : "83.5x83.5",
"scale" : "2x"
},
{
"idiom" : "ios-marketing",
"size" : "1024x1024",
"scale" : "1x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" systemVersion="17A277" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
</scene>
</scenes>
</document>
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.2</string>
<key>CFBundleVersion</key>
<string>500</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
<string>Main</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
//
// ViewController.swift
// Welcome-iOS
//
// Created by Davide De Rosa on 10/20/17.
// Copyright © 2017 London Trust Media. All rights reserved.
//
import UIKit
import PIALibrary
class ViewController: UIViewController, PIAWelcomeViewControllerDelegate {
@IBOutlet private weak var buttonLogin: UIButton!
@IBOutlet private weak var buttonLogout: UIButton!
@IBOutlet private weak var labelUsername: UILabel!
@IBOutlet private weak var labelPassword: UILabel!
@IBOutlet private weak var labelExpiration: UILabel!
@IBOutlet private weak var buttonExtend: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
_ = Client.preferences.editable().reset()
refresh(user: nil)
}
@IBAction private func logIn() {
var preset = PIAWelcomeViewController.Preset()
preset.pages = .all
preset.allowsCancel = true
preset.loginUsername = "p0000000"
preset.loginPassword = "foobarbogus"
preset.purchaseEmail = "foo@bar.com"
let vc = PIAWelcomeViewController.with(preset: preset, delegate: self)
present(vc, animated: true, completion: nil)
}
@IBAction private func logOut() {
Client.providers.accountProvider.logout { (error) in
self.refresh(user: nil)
}
}
@IBAction private func extendSubscription() {
let business = Client.providers.accountProvider
business.purchase(plan: business.currentUser!.info!.plan) { (transaction, error) in
business.renew(with: RenewRequest(transaction: transaction)) { (user, error) in
guard let expirationDate = user?.info?.expirationDate else {
return
}
self.labelExpiration.text = expirationDate.description
}
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
// MARK: PIAWelcomeViewControllerDelegate
func welcomeController(_ welcomeController: PIAWelcomeViewController, didLoginWith user: UserAccount, topViewController: UIViewController) {
let business = Client.providers.accountProvider
refresh(user: user)
print(">>> Logged in as: \(business.currentUser!)")
dismiss(animated: true, completion: nil)
}
func welcomeController(_ welcomeController: PIAWelcomeViewController, didSignupWith user: UserAccount, topViewController: UIViewController) {
let business = Client.providers.accountProvider
print(">>> Signed up as: \(business.currentUser!)")
business.logout(nil)
dismiss(animated