first_direct_latest_download 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: fe94ab23c031d050d51852a86677c26161d90623
4
+ data.tar.gz: 28aa7f3946e7f30f21cca6da5d1a630c2e0c2eda
5
+ SHA512:
6
+ metadata.gz: dc6470c4614239a6fd2f18f1a2bd3ab4676dd31a0fcddcfa3a43bf50454d7cdf2b4b641fb639e45563eebdbf4718581a181b4718775d564775098eb941af12f0
7
+ data.tar.gz: e090571c08fb932910f53d7a7604440c47808146d1242ea08f2280c0a42487a9503926955e698525e224617d7a5c6eb8caa859622841b66b4d2e552155da66f7
checksums.yaml.gz.sig ADDED
@@ -0,0 +1 @@
1
+ V�b6����nvY|���V��� �/Re?���M�YG ^�o˴��
data.tar.gz.sig ADDED
@@ -0,0 +1,2 @@
1
+ ]A�K���2E(׌�����&�#8�|�zO/f(��?���Xd\�8.p��:��)�_���T�Q; .�r���&�����g�悩��_y�^V\4="��A�S�W���V0��?'�*IQ��$��}<��U���DƜ��`zy�F��;�
2
+ @�5j�`�T��wvX����J���|!�O�޻� <�|��$�|���
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in first_direct_latest_download.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Matt Fawcett
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # FirstDirectLatestDownload
2
+
3
+ A selenium script written in ruby to download latest transactional data as CSV from First Direct personal online banking.
4
+
5
+ Use at own risk.
6
+
7
+ ## Installation
8
+
9
+ ### Basic installation
10
+
11
+ gem install first_direct_latest_download
12
+
13
+ ### To install with signature checks to ensure that the gem has not been tampered with
14
+
15
+ gem cert --add <(curl -Ls https://raw.githubusercontent.com/mattfawcett/first_direct_latest_download/master/certs/mattfawcett.pem)
16
+
17
+ gem install first_direct_latest_download -P MediumSecurity
18
+
19
+ ## Usage
20
+ Example. Run with no arguments and you will be promted for username, memorable word, and password
21
+
22
+ first_direct_latest_download
23
+
24
+ Example. Passing credentials like this is insecure. At minimum use [HISTCONTROL](http://www.linuxjournal.com/content/using-bash-history-more-efficiently-histcontrol)
25
+
26
+ first_direct_latest_download -u username -m memorableword -p password [-a optionalaccountname]
27
+
28
+ Example using [password manager](https://www.passwordstore.org/)
29
+
30
+ first_direct_latest_download -u IB1234567890 -m `pass firstdirect.co.uk.memorable` -p `pass firstdirect.co.uk.password`
31
+
32
+ ## License
33
+
34
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
35
+
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "first_direct_latest_download"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,22 @@
1
+ -----BEGIN CERTIFICATE-----
2
+ MIIDsDCCApigAwIBAgIBATANBgkqhkiG9w0BAQUFADBXMQ0wCwYDVQQDDARtYWls
3
+ MR4wHAYKCZImiZPyLGQBGRYObWF0dGhld2Zhd2NldHQxEjAQBgoJkiaJk/IsZAEZ
4
+ FgJjbzESMBAGCgmSJomT8ixkARkWAnVrMB4XDTE2MDczMTA5MTMyMloXDTE3MDcz
5
+ MTA5MTMyMlowVzENMAsGA1UEAwwEbWFpbDEeMBwGCgmSJomT8ixkARkWDm1hdHRo
6
+ ZXdmYXdjZXR0MRIwEAYKCZImiZPyLGQBGRYCY28xEjAQBgoJkiaJk/IsZAEZFgJ1
7
+ azCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMD79gWa1lNLhS4uyQdu
8
+ W0a0wB7ovDJxVMbVWhXm086S9yi7Sb71NmpWZmaWB54eXS/IfBRFLiiJl9+7LEJ+
9
+ xlpDXbOfQmHFHyt21ED0y5m9ixDBSpZux0HnWPEo3yDWwvg4jehuk7VpOsKCSpf9
10
+ uX0GNDr4GsVZDp7KpVGVE5FjLdq+Scg0zCOY1kut5DOBw1sxbZC6xW7JjAlB8Rka
11
+ NkMsFBA98sBAl1Pz+tn2e1Du7hV6OX72v3AncC5uchvLXO2SQxlhOxQxjqOaqogy
12
+ yP8WLCN///eepc6ISpLemIUT4KHdRz9L8jKHErpuzaBiNtWIhcyv7MB7ZaMcrb8U
13
+ Oh8CAwEAAaOBhjCBgzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQU
14
+ ScxklEbsSKSeOy+I+86Ccis1ggMwJAYDVR0RBB0wG4EZbWFpbEBtYXR0aGV3ZmF3
15
+ Y2V0dC5jby51azAkBgNVHRIEHTAbgRltYWlsQG1hdHRoZXdmYXdjZXR0LmNvLnVr
16
+ MA0GCSqGSIb3DQEBBQUAA4IBAQCipFpXBV8hjLb4dzeheyhQTooWL76WOXiUjipj
17
+ ekBR82RzUlXx+YBJ3A+s9/lTsn70ravEK9tfpkDXGXIg/fF6aaVCX085PIaghAzJ
18
+ gz8uuzaUp/kGrbhzYvyC5r3e8iugTylHkiftYF5w2Xn02l21yK/AubKYDUU/KinL
19
+ w3lz0KwTmsyupgzc6y7yHW3jdCAFe8iXlPwhbfbqID2iSm8wuQwO6RzJn07Ejtus
20
+ yJIQ7BnT75VQEqtWMfkSjOW64AVlWuD/LU/4NQykWZrh6sAaxKvhYBU/PiujaXyL
21
+ rUw5QSvC1QClur/I5qvjk8o8/hbxgQuoy5zjq8/vPBuaVDJY
22
+ -----END CERTIFICATE-----
@@ -0,0 +1,46 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "optparse"
4
+ require "bundler/setup"
5
+ require "first_direct_latest_download/download"
6
+
7
+ options = {account_name: '1st Account'}
8
+
9
+ OptionParser.new do |opts|
10
+ opts.banner = "Usage: first_direct_latest_download options"
11
+
12
+ opts.on("-u", "--username USERNAME", "Username. Eg IB123456789") do |u|
13
+ options[:username] = u
14
+ end
15
+
16
+ opts.on("-p", "--password PASSWORD", "Password") do |p|
17
+ options[:password] = p
18
+ end
19
+
20
+ opts.on("-m", "--memorable-answer MEMORABLE", "Memorable Phrase") do |m|
21
+ options[:memorable_answer] = m
22
+ end
23
+
24
+ opts.on("-a", "--account-name ACCOUNT_NAME", "Account name: Default '1st Account'") do |a|
25
+ options[:account_name] = a
26
+ end
27
+ end.parse!
28
+
29
+ unless options[:username]
30
+ puts "Enter Username:"
31
+ options[:username] = gets.chomp
32
+ end
33
+
34
+ unless options[:password]
35
+ puts "Enter Password"
36
+ options[:password] = gets.chomp
37
+ end
38
+
39
+ unless options[:memorable_answer]
40
+ puts "Enter Memorable Answer"
41
+ options[:memorable_answer] = gets.chomp
42
+ end
43
+
44
+
45
+ download = FirstDirectLatestDownload::Download.new(options)
46
+ download.run!
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'first_direct_latest_download/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "first_direct_latest_download"
8
+ spec.version = FirstDirectLatestDownload::VERSION
9
+ spec.authors = ["Matt Fawcett"]
10
+ spec.email = ["mail@matthewfawcett.co.uk"]
11
+
12
+ spec.summary = %q{Download latest First Direct transactions as OFX}
13
+ spec.description = %q{Download latest First Direct transactions as OFX}
14
+ spec.homepage = "https://github.com/mattfawcett/first_direct_latest_download"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.cert_chain = ['certs/mattfawcett.pem']
23
+ spec.signing_key = File.expand_path("~/.ssh/gem-private_key.pem") if $0 =~ /gem\z/
24
+
25
+ spec.add_dependency "selenium-webdriver", "~> 2.53"
26
+
27
+ spec.add_development_dependency "bundler", "~> 1.12"
28
+ spec.add_development_dependency "rake", "~> 10.0"
29
+ end
@@ -0,0 +1,4 @@
1
+ require "first_direct_latest_download/version"
2
+
3
+ module FirstDirectLatestDownload
4
+ end
@@ -0,0 +1,70 @@
1
+ require "selenium-webdriver"
2
+
3
+ module FirstDirectLatestDownload
4
+ class Download
5
+ FIRST_DIRECT_URL = 'https://www1.firstdirect.com/1/2/pib-service'
6
+
7
+ def initialize(options)
8
+ @options = options
9
+ end
10
+
11
+ def run!
12
+ driver = Selenium::WebDriver.for :chrome
13
+ driver.navigate.to FIRST_DIRECT_URL
14
+
15
+ element = driver.find_element(:name, 'userid')
16
+ element.send_keys @options[:username]
17
+ element.submit
18
+
19
+ wait = Selenium::WebDriver::Wait.new(:timeout => 10)
20
+ wait.until { driver.find_element(:partial_link_text => 'Log on without your Secure Key') }
21
+
22
+ driver.find_element(partial_link_text: 'Log on without your Secure Key').click
23
+
24
+ driver.find_element(name: 'memorableAnswer').send_keys(@options[:memorable_answer])
25
+
26
+ (1..3).each { |n| fill_out_password_character(driver, n) }
27
+
28
+ driver.find_element(xpath: "//*[@type='submit']").click
29
+
30
+ wait.until { driver.find_element(:link_text => @options[:account_name]) }
31
+
32
+
33
+ driver.find_element(:link_text, @options[:account_name]).click
34
+ driver.find_element(:link_text, 'download').click
35
+
36
+ wait.until { driver.find_element(:name => 'DownloadFormat') }
37
+
38
+ file_type = driver.find_element(:name, 'DownloadFormat')
39
+ file_type.find_elements(:tag_name => "option").find do |option|
40
+ option.text == ' Microsoft Excel '
41
+ end.click
42
+
43
+ driver.find_element(:link_text, 'download').click
44
+
45
+ sleep 10
46
+
47
+ driver.find_element(partial_link_text: 'log off').click
48
+ driver.find_element(partial_link_text: 'confirm').click
49
+ driver.quit
50
+ end
51
+
52
+ # field_number should be 1, 2 or 3
53
+ def fill_out_password_character(driver, field_number)
54
+ label = driver.find_element(id: "hiddenpasswordcharacterposition_#{field_number}-label")
55
+
56
+ character_number = label.attribute('innerText').scan(/\d|penultimate/).first
57
+
58
+ character = case character_number
59
+ when "penultimate"
60
+ @options[:password][@options[:password].length-2, 1]
61
+ else
62
+ @options[:password][character_number.to_i-1, 1]
63
+ end
64
+
65
+ field_id = label.attribute('for')
66
+
67
+ driver.find_element(:id, field_id).send_keys(character)
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,3 @@
1
+ module FirstDirectLatestDownload
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,123 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: first_direct_latest_download
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Matt Fawcett
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIDsDCCApigAwIBAgIBATANBgkqhkiG9w0BAQUFADBXMQ0wCwYDVQQDDARtYWls
14
+ MR4wHAYKCZImiZPyLGQBGRYObWF0dGhld2Zhd2NldHQxEjAQBgoJkiaJk/IsZAEZ
15
+ FgJjbzESMBAGCgmSJomT8ixkARkWAnVrMB4XDTE2MDczMTA5MTMyMloXDTE3MDcz
16
+ MTA5MTMyMlowVzENMAsGA1UEAwwEbWFpbDEeMBwGCgmSJomT8ixkARkWDm1hdHRo
17
+ ZXdmYXdjZXR0MRIwEAYKCZImiZPyLGQBGRYCY28xEjAQBgoJkiaJk/IsZAEZFgJ1
18
+ azCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMD79gWa1lNLhS4uyQdu
19
+ W0a0wB7ovDJxVMbVWhXm086S9yi7Sb71NmpWZmaWB54eXS/IfBRFLiiJl9+7LEJ+
20
+ xlpDXbOfQmHFHyt21ED0y5m9ixDBSpZux0HnWPEo3yDWwvg4jehuk7VpOsKCSpf9
21
+ uX0GNDr4GsVZDp7KpVGVE5FjLdq+Scg0zCOY1kut5DOBw1sxbZC6xW7JjAlB8Rka
22
+ NkMsFBA98sBAl1Pz+tn2e1Du7hV6OX72v3AncC5uchvLXO2SQxlhOxQxjqOaqogy
23
+ yP8WLCN///eepc6ISpLemIUT4KHdRz9L8jKHErpuzaBiNtWIhcyv7MB7ZaMcrb8U
24
+ Oh8CAwEAAaOBhjCBgzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQU
25
+ ScxklEbsSKSeOy+I+86Ccis1ggMwJAYDVR0RBB0wG4EZbWFpbEBtYXR0aGV3ZmF3
26
+ Y2V0dC5jby51azAkBgNVHRIEHTAbgRltYWlsQG1hdHRoZXdmYXdjZXR0LmNvLnVr
27
+ MA0GCSqGSIb3DQEBBQUAA4IBAQCipFpXBV8hjLb4dzeheyhQTooWL76WOXiUjipj
28
+ ekBR82RzUlXx+YBJ3A+s9/lTsn70ravEK9tfpkDXGXIg/fF6aaVCX085PIaghAzJ
29
+ gz8uuzaUp/kGrbhzYvyC5r3e8iugTylHkiftYF5w2Xn02l21yK/AubKYDUU/KinL
30
+ w3lz0KwTmsyupgzc6y7yHW3jdCAFe8iXlPwhbfbqID2iSm8wuQwO6RzJn07Ejtus
31
+ yJIQ7BnT75VQEqtWMfkSjOW64AVlWuD/LU/4NQykWZrh6sAaxKvhYBU/PiujaXyL
32
+ rUw5QSvC1QClur/I5qvjk8o8/hbxgQuoy5zjq8/vPBuaVDJY
33
+ -----END CERTIFICATE-----
34
+ date: 2016-08-30 00:00:00.000000000 Z
35
+ dependencies:
36
+ - !ruby/object:Gem::Dependency
37
+ name: selenium-webdriver
38
+ requirement: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - "~>"
41
+ - !ruby/object:Gem::Version
42
+ version: '2.53'
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - "~>"
48
+ - !ruby/object:Gem::Version
49
+ version: '2.53'
50
+ - !ruby/object:Gem::Dependency
51
+ name: bundler
52
+ requirement: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - "~>"
55
+ - !ruby/object:Gem::Version
56
+ version: '1.12'
57
+ type: :development
58
+ prerelease: false
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - "~>"
62
+ - !ruby/object:Gem::Version
63
+ version: '1.12'
64
+ - !ruby/object:Gem::Dependency
65
+ name: rake
66
+ requirement: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - "~>"
69
+ - !ruby/object:Gem::Version
70
+ version: '10.0'
71
+ type: :development
72
+ prerelease: false
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - "~>"
76
+ - !ruby/object:Gem::Version
77
+ version: '10.0'
78
+ description: Download latest First Direct transactions as OFX
79
+ email:
80
+ - mail@matthewfawcett.co.uk
81
+ executables:
82
+ - first_direct_latest_download
83
+ extensions: []
84
+ extra_rdoc_files: []
85
+ files:
86
+ - ".gitignore"
87
+ - Gemfile
88
+ - LICENSE.txt
89
+ - README.md
90
+ - Rakefile
91
+ - bin/console
92
+ - bin/setup
93
+ - certs/mattfawcett.pem
94
+ - exe/first_direct_latest_download
95
+ - first_direct_latest_download.gemspec
96
+ - lib/first_direct_latest_download.rb
97
+ - lib/first_direct_latest_download/download.rb
98
+ - lib/first_direct_latest_download/version.rb
99
+ homepage: https://github.com/mattfawcett/first_direct_latest_download
100
+ licenses:
101
+ - MIT
102
+ metadata: {}
103
+ post_install_message:
104
+ rdoc_options: []
105
+ require_paths:
106
+ - lib
107
+ required_ruby_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ required_rubygems_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ requirements: []
118
+ rubyforge_project:
119
+ rubygems_version: 2.5.1
120
+ signing_key:
121
+ specification_version: 4
122
+ summary: Download latest First Direct transactions as OFX
123
+ test_files: []
metadata.gz.sig ADDED
Binary file