passkit 0.8.0 → 0.8.2
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 +4 -4
- data/.env.test +8 -0
- data/.semaphore/release.yml +21 -0
- data/.semaphore/semaphore.yml +42 -0
- data/CHANGELOG.md +9 -0
- data/README.md +8 -2
- data/Rakefile +6 -0
- data/app/controllers/passkit/api/v1/passes_controller.rb +2 -2
- data/app/models/passkit/pass.rb +1 -1
- data/bin/generate_test_certificates +55 -0
- data/bin/setup +1 -1
- data/lib/passkit/base_pass.rb +5 -5
- data/lib/passkit/example_store_card.rb +7 -7
- data/lib/passkit/generator.rb +1 -1
- data/lib/passkit/version.rb +1 -1
- data/lib/passkit.rb +2 -2
- metadata +8 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c3980bb0fab949c93cc8821dd050f784f97f6a20b3ad9b16ac2c0a73a930529f
|
|
4
|
+
data.tar.gz: d0a4be1ab9846f71e4bc7806bb54a110519785c4d2086e33106eb83d5f0e06af
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5b9cd2a244f8e5b7ffb9e14d18a6004080ea55e0b302f25862d2f23bd28ce7277ca062436100f6aeec638f0827bf78674ef63c22d7c82c852e3c32be139461ab
|
|
7
|
+
data.tar.gz: 5acf99ef60dc001f047e89771431bdb46fcf4417e70f76a9859df94520805a6b355109de4cc0eee67601ff5047f4825b6b753865120e25413864ce1480242933
|
data/.env.test
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
PASSKIT_WEB_SERVICE_HOST=https://localhost:3000
|
|
2
|
+
PASSKIT_CERTIFICATE_KEY=passkit
|
|
3
|
+
PASSKIT_PRIVATE_P12_CERTIFICATE=certificates/certificate.p12
|
|
4
|
+
PASSKIT_APPLE_INTERMEDIATE_CERTIFICATE=certificates/intermediate.cer
|
|
5
|
+
PASSKIT_APPLE_TEAM_IDENTIFIER=XXXXXXXXXX
|
|
6
|
+
PASSKIT_PASS_TYPE_IDENTIFIER=pass.com.example.pass
|
|
7
|
+
PASSKIT_DASHBOARD_USERNAME=admin
|
|
8
|
+
PASSKIT_DASHBOARD_PASSWORD=admin
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
version: "v1.0"
|
|
2
|
+
name: Release gem
|
|
3
|
+
agent:
|
|
4
|
+
machine:
|
|
5
|
+
type: f1-standard-2
|
|
6
|
+
os_image: ubuntu2204
|
|
7
|
+
|
|
8
|
+
blocks:
|
|
9
|
+
- name: publish
|
|
10
|
+
execution_time_limit:
|
|
11
|
+
minutes: 10
|
|
12
|
+
task:
|
|
13
|
+
secrets:
|
|
14
|
+
- name: rubygems
|
|
15
|
+
jobs:
|
|
16
|
+
- name: build and push to rubygems.org
|
|
17
|
+
commands:
|
|
18
|
+
- checkout
|
|
19
|
+
- sem-version ruby 3.3
|
|
20
|
+
- gem build passkit.gemspec
|
|
21
|
+
- gem push passkit-*.gem < /dev/null
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
version: "v1.0"
|
|
2
|
+
name: passkit
|
|
3
|
+
agent:
|
|
4
|
+
machine:
|
|
5
|
+
type: f1-standard-2
|
|
6
|
+
os_image: ubuntu2204
|
|
7
|
+
auto_cancel:
|
|
8
|
+
running:
|
|
9
|
+
when: "true"
|
|
10
|
+
|
|
11
|
+
blocks:
|
|
12
|
+
- name: tests
|
|
13
|
+
execution_time_limit:
|
|
14
|
+
minutes: 10
|
|
15
|
+
task:
|
|
16
|
+
env_vars:
|
|
17
|
+
- name: RAILS_ENV
|
|
18
|
+
value: test
|
|
19
|
+
- name: BUNDLE_PATH
|
|
20
|
+
value: vendor/bundle
|
|
21
|
+
prologue:
|
|
22
|
+
commands:
|
|
23
|
+
- checkout --use-cache
|
|
24
|
+
- sem-version ruby 3.3
|
|
25
|
+
- cache restore gems-$(checksum passkit.gemspec)-$(checksum Gemfile)
|
|
26
|
+
- bundle install -j 4
|
|
27
|
+
- cache store gems-$(checksum passkit.gemspec)-$(checksum Gemfile) vendor/bundle
|
|
28
|
+
- bin/generate_test_certificates
|
|
29
|
+
jobs:
|
|
30
|
+
- name: linter
|
|
31
|
+
commands:
|
|
32
|
+
- bundle exec standardrb
|
|
33
|
+
- name: tests
|
|
34
|
+
commands:
|
|
35
|
+
- bundle exec rake test
|
|
36
|
+
- name: system tests
|
|
37
|
+
commands:
|
|
38
|
+
- bundle exec rake test:system
|
|
39
|
+
|
|
40
|
+
promotions:
|
|
41
|
+
- name: Release gem
|
|
42
|
+
pipeline_file: release.yml
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
## [0.8.2]
|
|
2
|
+
- Set up the Semaphore CI pipeline with a manual promotion to release the gem.
|
|
3
|
+
- Self-signed certificates for the test suite, so it runs without an Apple Developer certificate.
|
|
4
|
+
- Code formatting cleanup (standardrb).
|
|
5
|
+
- Relax the `sqlite3` development dependency to `>= 1.4`.
|
|
6
|
+
|
|
7
|
+
## [0.8.1]
|
|
8
|
+
- [#45](https://github.com/coorasse/passkit/pull/45): Fix broken build.
|
|
9
|
+
|
|
1
10
|
## [0.8.0]
|
|
2
11
|
- [#36](https://github.com/coorasse/passkit/pull/36): More flexible configuration parameters.
|
|
3
12
|
- [#44](https://github.com/coorasse/passkit/pull/44): Add `stripColor` option.
|
data/README.md
CHANGED
|
@@ -188,9 +188,15 @@ or the certificate trust chain could not be verified." the certificate (p12) mig
|
|
|
188
188
|
|
|
189
189
|
## Development
|
|
190
190
|
|
|
191
|
-
After checking out the repo, run `bin/setup` to install dependencies
|
|
191
|
+
After checking out the repo, run `bin/setup` to install dependencies and to generate the self-signed certificates
|
|
192
|
+
used to sign the passes in the test suite. Then, run `rake test` to run the tests and `rake test:system` to run the
|
|
193
|
+
system tests (they require Chrome). You can also run `bin/console` for an interactive prompt that will allow you to
|
|
194
|
+
experiment.
|
|
192
195
|
|
|
193
|
-
|
|
196
|
+
The test suite reads its configuration from `.env.test`, so no Apple Developer certificate is needed to run it.
|
|
197
|
+
Values defined in your own `.env` take precedence, in case you want to run the dummy app with real certificates.
|
|
198
|
+
|
|
199
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
|
194
200
|
|
|
195
201
|
## Contributing
|
|
196
202
|
|
data/Rakefile
CHANGED
|
@@ -9,6 +9,12 @@ Rake::TestTask.new(:test) do |t|
|
|
|
9
9
|
t.test_files = FileList["test/**/test_*.rb"]
|
|
10
10
|
end
|
|
11
11
|
|
|
12
|
+
Rake::TestTask.new("test:system") do |t|
|
|
13
|
+
t.libs << "test"
|
|
14
|
+
t.libs << "lib"
|
|
15
|
+
t.test_files = FileList["test/system/**/*_test.rb"]
|
|
16
|
+
end
|
|
17
|
+
|
|
12
18
|
require "standard/rake"
|
|
13
19
|
|
|
14
20
|
task default: %i[test standard]
|
|
@@ -12,10 +12,10 @@ module Passkit
|
|
|
12
12
|
Passkit::Factory.create_pass(@payload[:pass_class], collection_item)
|
|
13
13
|
end
|
|
14
14
|
file = Passkit::Generator.compress_passes_files(files)
|
|
15
|
-
send_file(file, type:
|
|
15
|
+
send_file(file, type: "application/vnd.apple.pkpasses", disposition: "attachment")
|
|
16
16
|
else
|
|
17
17
|
file = Passkit::Factory.create_pass(@payload[:pass_class], @generator)
|
|
18
|
-
send_file(file, type:
|
|
18
|
+
send_file(file, type: "application/vnd.apple.pkpass", disposition: "attachment")
|
|
19
19
|
end
|
|
20
20
|
end
|
|
21
21
|
|
data/app/models/passkit/pass.rb
CHANGED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
# Generates a self-signed pass certificate and a fake "Apple intermediate"
|
|
5
|
+
# certificate, so that the test suite can sign passes without a real Apple
|
|
6
|
+
# Developer certificate.
|
|
7
|
+
|
|
8
|
+
require "openssl"
|
|
9
|
+
require "fileutils"
|
|
10
|
+
|
|
11
|
+
output_directory = File.expand_path("../test/dummy/certificates", __dir__)
|
|
12
|
+
password = ENV.fetch("PASSKIT_CERTIFICATE_KEY", "passkit")
|
|
13
|
+
|
|
14
|
+
FileUtils.mkdir_p(output_directory)
|
|
15
|
+
|
|
16
|
+
intermediate_key = OpenSSL::PKey::RSA.new(2048)
|
|
17
|
+
intermediate_certificate = OpenSSL::X509::Certificate.new
|
|
18
|
+
intermediate_certificate.version = 2
|
|
19
|
+
intermediate_certificate.serial = 1
|
|
20
|
+
intermediate_certificate.subject = OpenSSL::X509::Name.parse("/CN=Passkit Test Intermediate CA")
|
|
21
|
+
intermediate_certificate.issuer = intermediate_certificate.subject
|
|
22
|
+
intermediate_certificate.public_key = intermediate_key.public_key
|
|
23
|
+
intermediate_certificate.not_before = Time.now - 60
|
|
24
|
+
intermediate_certificate.not_after = Time.now + (10 * 365 * 24 * 60 * 60)
|
|
25
|
+
|
|
26
|
+
extension_factory = OpenSSL::X509::ExtensionFactory.new
|
|
27
|
+
extension_factory.subject_certificate = intermediate_certificate
|
|
28
|
+
extension_factory.issuer_certificate = intermediate_certificate
|
|
29
|
+
intermediate_certificate.add_extension(extension_factory.create_extension("basicConstraints", "CA:TRUE", true))
|
|
30
|
+
intermediate_certificate.add_extension(extension_factory.create_extension("keyUsage", "keyCertSign, cRLSign", true))
|
|
31
|
+
intermediate_certificate.sign(intermediate_key, OpenSSL::Digest.new("SHA256"))
|
|
32
|
+
|
|
33
|
+
pass_key = OpenSSL::PKey::RSA.new(2048)
|
|
34
|
+
pass_certificate = OpenSSL::X509::Certificate.new
|
|
35
|
+
pass_certificate.version = 2
|
|
36
|
+
pass_certificate.serial = 2
|
|
37
|
+
pass_certificate.subject = OpenSSL::X509::Name.parse("/CN=#{ENV.fetch("PASSKIT_PASS_TYPE_IDENTIFIER", "pass.com.example.pass")}")
|
|
38
|
+
pass_certificate.issuer = intermediate_certificate.subject
|
|
39
|
+
pass_certificate.public_key = pass_key.public_key
|
|
40
|
+
pass_certificate.not_before = Time.now - 60
|
|
41
|
+
pass_certificate.not_after = Time.now + (10 * 365 * 24 * 60 * 60)
|
|
42
|
+
|
|
43
|
+
extension_factory = OpenSSL::X509::ExtensionFactory.new
|
|
44
|
+
extension_factory.subject_certificate = pass_certificate
|
|
45
|
+
extension_factory.issuer_certificate = intermediate_certificate
|
|
46
|
+
pass_certificate.add_extension(extension_factory.create_extension("basicConstraints", "CA:FALSE", true))
|
|
47
|
+
pass_certificate.add_extension(extension_factory.create_extension("keyUsage", "digitalSignature", true))
|
|
48
|
+
pass_certificate.sign(intermediate_key, OpenSSL::Digest.new("SHA256"))
|
|
49
|
+
|
|
50
|
+
p12 = OpenSSL::PKCS12.create(password, "Passkit Test Certificate", pass_key, pass_certificate)
|
|
51
|
+
|
|
52
|
+
File.binwrite(File.join(output_directory, "intermediate.cer"), intermediate_certificate.to_der)
|
|
53
|
+
File.binwrite(File.join(output_directory, "certificate.p12"), p12.to_der)
|
|
54
|
+
|
|
55
|
+
puts "Certificates written to #{output_directory}"
|
data/bin/setup
CHANGED
data/lib/passkit/base_pass.rb
CHANGED
|
@@ -189,10 +189,10 @@ module Passkit
|
|
|
189
189
|
|
|
190
190
|
# QRCode by default
|
|
191
191
|
def barcode
|
|
192
|
-
{
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
192
|
+
{messageEncoding: "iso-8859-1",
|
|
193
|
+
format: "PKBarcodeFormatQR",
|
|
194
|
+
message: "https://github.com/coorasse/passkit",
|
|
195
|
+
altText: "https://github.com/coorasse/passkit"}
|
|
196
196
|
end
|
|
197
197
|
|
|
198
198
|
# Barcode example
|
|
@@ -231,7 +231,7 @@ module Passkit
|
|
|
231
231
|
false
|
|
232
232
|
end
|
|
233
233
|
|
|
234
|
-
|
|
234
|
+
private
|
|
235
235
|
|
|
236
236
|
def folder_name
|
|
237
237
|
self.class.name.demodulize.underscore
|
|
@@ -39,10 +39,10 @@ module Passkit
|
|
|
39
39
|
# QRCode by default
|
|
40
40
|
def barcodes
|
|
41
41
|
[
|
|
42
|
-
{
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
42
|
+
{messageEncoding: "iso-8859-1",
|
|
43
|
+
format: "PKBarcodeFormatQR",
|
|
44
|
+
message: "https://github.com/coorasse/passkit",
|
|
45
|
+
altText: "https://github.com/coorasse/passkit"}
|
|
46
46
|
]
|
|
47
47
|
end
|
|
48
48
|
|
|
@@ -59,12 +59,12 @@ module Passkit
|
|
|
59
59
|
end
|
|
60
60
|
|
|
61
61
|
def relevant_date
|
|
62
|
-
Time.current.strftime(
|
|
62
|
+
Time.current.strftime("%Y-%m-%dT%H:%M:%S%:z")
|
|
63
63
|
end
|
|
64
64
|
|
|
65
65
|
def expiration_date
|
|
66
66
|
# Expire the pass tomorrow
|
|
67
|
-
(Time.current + 1.day).strftime(
|
|
67
|
+
(Time.current + 1.day).strftime("%Y-%m-%dT%H:%M:%S%:z")
|
|
68
68
|
end
|
|
69
69
|
|
|
70
70
|
def semantics
|
|
@@ -121,7 +121,7 @@ module Passkit
|
|
|
121
121
|
}]
|
|
122
122
|
end
|
|
123
123
|
|
|
124
|
-
|
|
124
|
+
private
|
|
125
125
|
|
|
126
126
|
def folder_name
|
|
127
127
|
self.class.name.demodulize.underscore
|
data/lib/passkit/generator.rb
CHANGED
data/lib/passkit/version.rb
CHANGED
data/lib/passkit.rb
CHANGED
|
@@ -22,7 +22,7 @@ module Passkit
|
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
def self.configured?
|
|
25
|
-
|
|
25
|
+
configuration&.configured?
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
class Configuration
|
|
@@ -68,7 +68,7 @@ module Passkit
|
|
|
68
68
|
# Optional
|
|
69
69
|
@skip_verification = false
|
|
70
70
|
@web_service_host = ENV["PASSKIT_WEB_SERVICE_HOST"] || "https://localhost:3000"
|
|
71
|
-
@available_passes = {
|
|
71
|
+
@available_passes = {"Passkit::ExampleStoreCard" => -> {}}
|
|
72
72
|
@format_version = ENV["PASSKIT_FORMAT_VERSION"] || 1
|
|
73
73
|
@dashboard_username = ENV["PASSKIT_DASHBOARD_USERNAME"]
|
|
74
74
|
@dashboard_password = ENV["PASSKIT_DASHBOARD_PASSWORD"]
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: passkit
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.8.
|
|
4
|
+
version: 0.8.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Alessandro Rodi
|
|
@@ -41,14 +41,14 @@ dependencies:
|
|
|
41
41
|
name: sqlite3
|
|
42
42
|
requirement: !ruby/object:Gem::Requirement
|
|
43
43
|
requirements:
|
|
44
|
-
- - "
|
|
44
|
+
- - ">="
|
|
45
45
|
- !ruby/object:Gem::Version
|
|
46
46
|
version: '1.4'
|
|
47
47
|
type: :development
|
|
48
48
|
prerelease: false
|
|
49
49
|
version_requirements: !ruby/object:Gem::Requirement
|
|
50
50
|
requirements:
|
|
51
|
-
- - "
|
|
51
|
+
- - ">="
|
|
52
52
|
- !ruby/object:Gem::Version
|
|
53
53
|
version: '1.4'
|
|
54
54
|
- !ruby/object:Gem::Dependency
|
|
@@ -143,7 +143,10 @@ executables: []
|
|
|
143
143
|
extensions: []
|
|
144
144
|
extra_rdoc_files: []
|
|
145
145
|
files:
|
|
146
|
+
- ".env.test"
|
|
146
147
|
- ".example.env"
|
|
148
|
+
- ".semaphore/release.yml"
|
|
149
|
+
- ".semaphore/semaphore.yml"
|
|
147
150
|
- ".standard.yml"
|
|
148
151
|
- CHANGELOG.md
|
|
149
152
|
- CODE_OF_CONDUCT.md
|
|
@@ -179,6 +182,7 @@ files:
|
|
|
179
182
|
- app/views/passkit/example_mailer/example_email.html.erb
|
|
180
183
|
- app/views/shared/passkit/_navigation.html.erb
|
|
181
184
|
- bin/console
|
|
185
|
+
- bin/generate_test_certificates
|
|
182
186
|
- bin/setup
|
|
183
187
|
- config/routes.rb
|
|
184
188
|
- docs/membership.png
|
|
@@ -235,7 +239,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
235
239
|
- !ruby/object:Gem::Version
|
|
236
240
|
version: '0'
|
|
237
241
|
requirements: []
|
|
238
|
-
rubygems_version:
|
|
242
|
+
rubygems_version: 4.0.9
|
|
239
243
|
specification_version: 4
|
|
240
244
|
summary: Serve Wallet Passes for iOS and Android directly from your Rails app
|
|
241
245
|
test_files: []
|