passbook 0.4.1 → 0.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 13dcfa4609494b74e55a93ccb7112fd7eb0db940
4
- data.tar.gz: 39ca932277b88c4e867fdb243cb59425d2a0636a
3
+ metadata.gz: 9cbc86e695bdad78634e5ef6ca96bd2dd541e6b2
4
+ data.tar.gz: 9c8c6fd550bb913acd37630085854759550e2943
5
5
  SHA512:
6
- metadata.gz: e47891da09c51646de304691bd678b9db7d0a5ac486c3264bb209c2a2496eee105078881fd43ec6eb6363f5c8f454c2b526cf2fc1456a8c2d770c392eec5d77b
7
- data.tar.gz: c05ce20890f7b0de157590b681e84cc4f334df65983420eca0fcd7f88d460cecfabead0c19c485fc4268fb72d816c35251d4a8f4078311088f887139c7f8f982
6
+ metadata.gz: ac675f8951033f88c41d1cd35d1fd222688beb2cfe5556b1b4e3297cff8d5d39d6b06028dcfbdf26f20168f501c63d0722ed4feb98af4932d5863f21eb8260d3
7
+ data.tar.gz: 0e366333bdb8907eea0afabe38d5052a0613bd4db2364e762213d63f038f85e46f9cac458d70276b812995104a5ed858cb0379aa7fdab7e9ab40f858666a91fe
data/README.md CHANGED
@@ -27,7 +27,7 @@ Then go to a directory that you want to generate your pass under and use the "pk
27
27
  pk generate your_pass_name
28
28
  ```
29
29
 
30
- This will generate a directory called your_pass_name. Edit your pass.json file in the your_pass_directory to have a valid team identifier and passTypeIdentifier and create your certificates if you haven't yet. [See this article for information on how to do this.](http://www.raywenderlich.com/20734/beginning-passbook-part-1#more-20734)
30
+ This will generate a directory called your_pass_name. Edit your pass.json file in the your_pass_directory to have a valid team identifier and passTypeIdentifier and create your certificates if you haven't yet. [See this article for information on how to do this.](http://www.raywenderlich.com/20734/beginning-passbook-part-1#more-20734)
31
31
 
32
32
  Assuming that you have put your certificate files etc. in your working directory.
33
33
 
@@ -40,7 +40,7 @@ If you are not building your passes on a mac or just prefer to use the pass cert
40
40
 
41
41
  ```
42
42
  pk build passbook_gem_name -w ./wwdc.pem -c ./your_pass_name_certificate.pem -k your_pass_name_key.pem -p '12345'
43
- ```
43
+ ```
44
44
 
45
45
  Now you can drag the file over to a simulator or send it to your iPhone via e-mail to view your pass.
46
46
 
@@ -79,6 +79,7 @@ If You are doing push notifications then you will need to add some extra configu
79
79
  Passbook.configure do |passbook|
80
80
  .....other settings.....
81
81
  passbook.notification_gateway = 'gateway.push.apple.com'
82
+ passbook.notification_passphrase = 'my_hard_password' (optional)
82
83
  passbook.notification_cert = 'lib/assets/my_notification_cert.pem'
83
84
  end
84
85
  ```
@@ -232,7 +233,7 @@ module Passbook
232
233
  # you will want to return
233
234
  my_pass = PkPass.new 'your pass json'
234
235
  # you will want to return the string from the stream of your PkPass object.
235
- mypass.stream.string
236
+ {:status => 200, :latest_pass => mypass.stream.string, :last_modified => '1442120893'}
236
237
  end
237
238
 
238
239
  # This is called whenever there is something from the update process that is a warning
@@ -247,10 +248,10 @@ end
247
248
 
248
249
  ```
249
250
 
250
- To send a push notification for a updated pass simply call Passbook::PassbookPushNotification.send_notifications_for_promotion with the push token for the pass you are updating
251
+ To send a push notification for a updated pass simply call Passbook::PushNotification.send_notification with the push token for the device you are updating
251
252
 
252
253
  ```
253
- Passbook::PassbookPushNotification.send_notifications_for_promotion the_pass_push_token
254
+ Passbook::PushNotification.send_notification the_device_push_token
254
255
 
255
256
  ```
256
257
 
@@ -260,7 +261,7 @@ Apple will send out a notification to your phone (usually within 15 minutes or l
260
261
 
261
262
  To launch tests :
262
263
  ```
263
- bundle exec rake spec
264
+ bundle exec rake spec
264
265
  ```
265
266
 
266
267
  ## Contributing
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.1
1
+ 0.4.2
@@ -9,22 +9,22 @@ module Passbook
9
9
 
10
10
  TYPES = ['boarding-pass', 'coupon', 'event-ticket', 'store-card', 'generic']
11
11
 
12
- def initialize pass, init_signer = nil
12
+ def initialize(pass, init_signer = nil)
13
13
  @pass = pass
14
14
  @manifest_files = []
15
15
  @signer = init_signer || Passbook::Signer.new
16
16
  end
17
17
 
18
- def addFile file
18
+ def addFile(file)
19
19
  @manifest_files << file
20
20
  end
21
21
 
22
- def addFiles files
22
+ def addFiles(files)
23
23
  @manifest_files += files
24
24
  end
25
25
 
26
26
  # for backwards compatibility
27
- def json= json
27
+ def json=(json)
28
28
  @pass = json
29
29
  end
30
30
 
@@ -37,7 +37,7 @@ module Passbook
37
37
  # Create pass signature
38
38
  signature = @signer.sign manifest
39
39
 
40
- return [manifest, signature]
40
+ [manifest, signature]
41
41
  end
42
42
 
43
43
  # Backward compatibility
@@ -65,7 +65,7 @@ module Passbook
65
65
 
66
66
  private
67
67
 
68
- def checkPass manifest
68
+ def checkPass(manifest)
69
69
  # Check for default images
70
70
  raise 'Icon missing' unless manifest.include?('icon.png')
71
71
  raise 'Icon@2x missing' unless manifest.include?('icon@2x.png')
@@ -92,10 +92,10 @@ module Passbook
92
92
  end
93
93
  end
94
94
 
95
- return sha1s.to_json
95
+ sha1s.to_json
96
96
  end
97
97
 
98
- def outputZip manifest, signature
98
+ def outputZip(manifest, signature)
99
99
 
100
100
  Zip::OutputStream.write_buffer do |zip|
101
101
  zip.put_next_entry 'pass.json'
@@ -1,7 +1,7 @@
1
1
  module Passbook
2
2
  class PushNotification
3
3
  def self.send_notification(device_token)
4
- pusher = Grocer.pusher({:certificate => Passbook.notification_cert, :gateway => Passbook.notification_gateway})
4
+ pusher = Grocer.pusher({:certificate => Passbook.notification_cert, :passphrase => Passbook.notification_passphrase || "", :gateway => Passbook.notification_gateway})
5
5
  notification = Grocer::PassbookNotification.new(:device_token => device_token)
6
6
 
7
7
  pusher.push notification
@@ -5,7 +5,7 @@ module Passbook
5
5
  class Signer
6
6
  attr_accessor :certificate, :password, :key, :wwdc_cert, :key_hash, :p12_cert
7
7
 
8
- def initialize params = {}
8
+ def initialize(params = {})
9
9
  @certificate = params[:certificate] || Passbook.p12_certificate
10
10
  @password = params[:password] || Passbook.p12_password
11
11
  @key = params[:key] || (params.empty? ? Passbook.p12_key : nil)
@@ -13,17 +13,17 @@ module Passbook
13
13
  compute_cert
14
14
  end
15
15
 
16
- def sign data
16
+ def sign(data)
17
17
  wwdc = OpenSSL::X509::Certificate.new File.read(wwdc_cert)
18
18
  pk7 = OpenSSL::PKCS7.sign key_hash[:cert], key_hash[:key], data.to_s, [wwdc], OpenSSL::PKCS7::BINARY | OpenSSL::PKCS7::DETACHED
19
19
  data = OpenSSL::PKCS7.write_smime pk7
20
20
 
21
21
  str_debut = "filename=\"smime.p7s\"\n\n"
22
- data = data[data.index(str_debut)+str_debut.length..data.length-1]
23
- str_end = "\n\n------"
24
- data = data[0..data.index(str_end)-1]
22
+ data = data[data.index(str_debut)+str_debut.length..data.length-1]
23
+ str_end = "\n\n------"
24
+ data = data[0..data.index(str_end)-1]
25
25
 
26
- return Base64.decode64(data)
26
+ Base64.decode64(data)
27
27
  end
28
28
 
29
29
  def compute_cert
@@ -1,3 +1,3 @@
1
1
  module Passbook
2
- VERSION = "0.0.4"
2
+ VERSION = "0.4.2"
3
3
  end
data/lib/passbook.rb CHANGED
@@ -7,7 +7,7 @@ require 'grocer/passbook_notification'
7
7
  require 'rack/passbook_rack'
8
8
 
9
9
  module Passbook
10
- mattr_accessor :p12_certificate, :p12_password, :wwdc_cert, :p12_key, :notification_cert, :notification_gateway
10
+ mattr_accessor :p12_certificate, :p12_password, :wwdc_cert, :p12_key, :notification_cert, :notification_gateway, :notification_passphrase
11
11
 
12
12
  def self.configure
13
13
  yield self
@@ -15,7 +15,7 @@ module Rack
15
15
  when 'device_register_delete'
16
16
  if env['REQUEST_METHOD'] == 'POST'
17
17
  [Passbook::PassbookNotification.
18
- register_pass(method_and_params[:params].merge! JSON.parse(env['rack.input'].read 1000))[:status],
18
+ register_pass(method_and_params[:params].merge! JSON.parse(env['rack.input'].read 1000))[:status],
19
19
  {}, ['']]
20
20
  elsif env['REQUEST_METHOD'] == 'DELETE'
21
21
  [Passbook::PassbookNotification.unregister_pass(method_and_params[:params])[:status], {}, {}]
@@ -25,12 +25,12 @@ module Rack
25
25
  [response ? 200 : 204, {}, [response.to_json]]
26
26
  when 'latest_pass'
27
27
  response = Passbook::PassbookNotification.latest_pass(method_and_params[:params])
28
- if response
29
- [200, {'Content-Type' => 'application/vnd.apple.pkpass',
30
- 'Content-Disposition' => 'attachment',
31
- 'filename' => "#{method_and_params[:params]['serialNumber']}.pkpass"}, [response]]
28
+ if response[:status] == 200
29
+ [200, {'Content-Type' => 'application/vnd.apple.pkpass',
30
+ 'Content-Disposition' => 'attachment',
31
+ 'filename' => "#{method_and_params[:params]['serialNumber']}.pkpass","last-modified" => response[:last_modified]}, [response[:latest_pass]]]
32
32
  else
33
- [204, {}, {}]
33
+ [response[:status], {}, {}]
34
34
  end
35
35
  when 'log'
36
36
  Passbook::PassbookNotification.passbook_log JSON.parse(env['rack.input'].read 10000)
@@ -69,10 +69,10 @@ module Rack
69
69
  end
70
70
  end
71
71
 
72
- return nil
72
+ return nil
73
73
  end
74
74
 
75
- private
75
+ private
76
76
 
77
77
  def method_and_params_hash(method, path)
78
78
  parsed_path = path.split '/'
@@ -6,7 +6,7 @@ Passbook.configure do |passbook|
6
6
  passbook.wwdc_cert = '<%= wwdc_cert_path %>'
7
7
 
8
8
  # Path to your cert.p12 file
9
- passbook.p12_cert = '<%= p12_cert_path %>'
9
+ passbook.p12_certificate = '<%= p12_cert_path %>'
10
10
 
11
11
  # Password for your certificate
12
12
  passbook.p12_password = '<%= p12_password %>'
data/passbook.gemspec CHANGED
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: passbook 0.4.1 ruby lib
5
+ # stub: passbook 0.4.2 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "passbook"
9
- s.version = "0.4.1"
9
+ s.version = "0.4.2"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["Thomas Lauro", "Lance Gleason"]
14
- s.date = "2014-12-08"
14
+ s.date = "2016-02-04"
15
15
  s.description = "This gem allows you to create IOS Passbooks. Unlike some, this works with Rails but does not require it."
16
16
  s.email = ["thomas@lauro.fr", "lgleason@polyglotprogramminginc.com"]
17
17
  s.executables = ["pk"]
@@ -62,7 +62,7 @@ Gem::Specification.new do |s|
62
62
  ]
63
63
  s.homepage = "http://github.com/frozon/passbook"
64
64
  s.licenses = ["MIT"]
65
- s.rubygems_version = "2.2.2"
65
+ s.rubygems_version = "2.4.8"
66
66
  s.summary = "A IOS Passbook generator."
67
67
 
68
68
  if s.respond_to? :specification_version then
@@ -5,15 +5,16 @@ describe Passbook::PushNotification do
5
5
 
6
6
  context 'send notification' do
7
7
  let(:grocer_pusher) {double 'Grocer'}
8
- let(:notification) {double 'Grocer::Notification'}
9
- let(:notification_settings) {{:certificate => './notification_cert.pem', :gateway => 'honeybadger.apple.com'}}
8
+ let(:notification) {double 'Grocer::Notification'}
9
+ let(:notification_settings) {{:certificate => './notification_cert.pem', :gateway => 'honeybadger.apple.com', :passphrase => 'ah@rdvintAge'}}
10
10
 
11
11
  before :each do
12
12
  Passbook.should_receive(:notification_cert).and_return './notification_cert.pem'
13
- Grocer::PassbookNotification.should_receive(:new).with(:device_token => 'my token').and_return notification
13
+ Grocer::PassbookNotification.should_receive(:new).with(:device_token => 'my token').and_return notification
14
14
  grocer_pusher.should_receive(:push).with(notification).and_return 55
15
15
  Grocer.should_receive(:pusher).with(notification_settings).and_return grocer_pusher
16
16
  Passbook.should_receive(:notification_gateway).and_return 'honeybadger.apple.com'
17
+ Passbook.should_receive(:notification_passphrase).and_return 'ah@rdvintAge'
17
18
  end
18
19
 
19
20
  subject {Passbook::PushNotification.send_notification('my token')}
@@ -48,7 +48,7 @@ describe Rack::PassbookRack do
48
48
  its([:params]) {should eq(register_delete_params) }
49
49
  end
50
50
 
51
- it_behaves_like 'a method that can handle non passbook urls'
51
+ it_behaves_like 'a method that can handle non passbook urls'
52
52
 
53
53
  end
54
54
 
@@ -144,7 +144,7 @@ describe Rack::PassbookRack do
144
144
 
145
145
  context 'get latest pass' do
146
146
  context 'valid pass' do
147
- let(:raw_pass) {'some url encoded text'}
147
+ let(:raw_pass) {{:status => 200, :latest_pass => 'some url encoded text', :last_modified => '1442401010'}}
148
148
 
149
149
  before do
150
150
  Passbook::PassbookNotification.should_receive(:latest_pass).with(latest_pass_params).
@@ -154,15 +154,15 @@ describe Rack::PassbookRack do
154
154
 
155
155
  subject {last_response}
156
156
  its(:status) {should eq 200}
157
- its(:header) {should eq({'Content-Type' => 'application/vnd.apple.pkpass',
158
- 'Content-Disposition' => 'attachment', 'filename' => '27-1.pkpass', 'Content-Length' => '21'})}
159
- its(:body) {should eq raw_pass}
157
+ its(:header) {should eq({'Content-Type' => 'application/vnd.apple.pkpass',
158
+ 'Content-Disposition' => 'attachment', 'filename' => '27-1.pkpass', 'last-modified' => '1442401010', 'Content-Length' => '21'})}
159
+ its(:body) {should eq raw_pass[:latest_pass]}
160
160
  end
161
161
 
162
162
  context 'no pass' do
163
163
  before do
164
164
  Passbook::PassbookNotification.should_receive(:latest_pass).with(latest_pass_params).
165
- and_return(nil)
165
+ and_return({:status => 204, :latest_pass => nil})
166
166
  get latest_pass_path
167
167
  end
168
168
 
@@ -213,7 +213,7 @@ describe Rack::PassbookRack do
213
213
  subject {last_response}
214
214
  its(:status) {should eq 200}
215
215
  its(:body) {should eq 'test app'}
216
- end
216
+ end
217
217
  end
218
218
 
219
219
  end
@@ -224,7 +224,7 @@ include Rack::Test::Methods
224
224
  def app
225
225
  test_app = lambda do |env|
226
226
  [200, {}, 'test app']
227
- end
227
+ end
228
228
 
229
229
  Rack::PassbookRack.new test_app
230
230
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: passbook
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Lauro
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-12-08 00:00:00.000000000 Z
12
+ date: 2016-02-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rubyzip
@@ -236,7 +236,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
236
236
  version: '0'
237
237
  requirements: []
238
238
  rubyforge_project:
239
- rubygems_version: 2.2.2
239
+ rubygems_version: 2.4.8
240
240
  signing_key:
241
241
  specification_version: 4
242
242
  summary: A IOS Passbook generator.