Skip to content

Commit 1df198c

Browse files
committed
Initial commit
0 parents  commit 1df198c

File tree

127 files changed

+2552
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+2552
-0
lines changed

.example.env

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
PASSKIT_WEB_SERVICE_HOST=https://localhost:3000
2+
PASSKIT_CERTIFICATE_KEY=path/to/certificate.key
3+
PASSKIT_PRIVATE_P12_CERTIFICATE=path/to/certificate.p12
4+
PASSKIT_APPLE_INTERMEDIATE_CERTIFICATE=path/to/AppleWWDRCA.cer
5+
PASSKIT_APPLE_TEAM_IDENTIFIER=XXXXXXXXXX
6+
PASSKIT_PASS_TYPE_IDENTIFIER=pass.com.example.pass

.gitignore

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/.bundle/
2+
/.yardoc
3+
/_yardoc/
4+
/coverage/
5+
/doc/
6+
/pkg/
7+
/spec/reports/
8+
/tmp/
9+
Gemfile.lock
10+
.env
11+
test/dummy/db/*.sqlite3
12+
test/dummy/log/*.log
13+
test/dummy/tmp/
14+

.standard.yml

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# For available configuration options, see:
2+
# https://github.com/testdouble/standard

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## [Unreleased]
2+
3+
## [0.1.0] - 2022-09-21
4+
5+
- Initial release

CODE_OF_CONDUCT.md

+84
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6+
7+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8+
9+
## Our Standards
10+
11+
Examples of behavior that contributes to a positive environment for our community include:
12+
13+
* Demonstrating empathy and kindness toward other people
14+
* Being respectful of differing opinions, viewpoints, and experiences
15+
* Giving and gracefully accepting constructive feedback
16+
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17+
* Focusing on what is best not just for us as individuals, but for the overall community
18+
19+
Examples of unacceptable behavior include:
20+
21+
* The use of sexualized language or imagery, and sexual attention or
22+
advances of any kind
23+
* Trolling, insulting or derogatory comments, and personal or political attacks
24+
* Public or private harassment
25+
* Publishing others' private information, such as a physical or email
26+
address, without their explicit permission
27+
* Other conduct which could reasonably be considered inappropriate in a
28+
professional setting
29+
30+
## Enforcement Responsibilities
31+
32+
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33+
34+
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35+
36+
## Scope
37+
38+
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39+
40+
## Enforcement
41+
42+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at [email protected]. All complaints will be reviewed and investigated promptly and fairly.
43+
44+
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45+
46+
## Enforcement Guidelines
47+
48+
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49+
50+
### 1. Correction
51+
52+
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53+
54+
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55+
56+
### 2. Warning
57+
58+
**Community Impact**: A violation through a single incident or series of actions.
59+
60+
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61+
62+
### 3. Temporary Ban
63+
64+
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65+
66+
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67+
68+
### 4. Permanent Ban
69+
70+
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71+
72+
**Consequence**: A permanent ban from any sort of public interaction within the community.
73+
74+
## Attribution
75+
76+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77+
available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78+
79+
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80+
81+
[homepage]: https://www.contributor-covenant.org
82+
83+
For answers to common questions about this code of conduct, see the FAQ at
84+
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.

Gemfile

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# frozen_string_literal: true
2+
3+
source "https://rubygems.org"
4+
5+
# Specify your gem's dependencies in passkit.gemspec
6+
gemspec
7+
8+
gem "rake", "~> 13.0"
9+
10+
gem "minitest", "~> 5.0"
11+
12+
gem "standard", "~> 1.3"

LICENSE.txt

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2022 Alessandro Rodi
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.

README.md

+160
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
# <img src="./docs/wallet.png" alt="Goboony" height="50"/> Passkit
2+
3+
Your out-of-the-box solution to start serving Wallet Passes in your Ruby On Rails application.
4+
5+
Do you have a QRCode or a Barcode anywhere in your app that you want to distribute as Wallet Pass, compatible for iOS and Android? Look no further!
6+
7+
This gem provides everything necessary to distribute Wallet Passes in pkpass format, and gives you all the steps to follow for what we cannot provide.
8+
9+
**We provide:**
10+
11+
* A (not yet) fancy dashboard to manage your passes, registered devices and logs.
12+
* All API endpoints to serve your passes: create, register, update, unregister, etc...
13+
* All necessary ActiveRecord models.
14+
* A BasePass model that you can extend to create your own passes.
15+
* Some helpers to generate the necessary URLs, so that you can include them in the emails.
16+
* Examples for everything.
17+
18+
**We don't provide (yet):**
19+
20+
* Full tests coverage: we are working on it!
21+
* A fancy dashboard: our dashboard is really really simple right now. Pull requests are welcome!
22+
* Push notifications: this is the most wanted feature I believe. Pull requests are welcome!
23+
* Google Wallet integration: we use https://walletpasses.io/ on Android to read .pkpass format.
24+
25+
## Apple documentation
26+
27+
* [Apple Wallet Passes](https://developer.apple.com/documentation/walletpasses)
28+
* [Send Push Notifications](https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/sending_notification_requests_to_apns)
29+
30+
## Installation
31+
32+
Add this line to your application's Gemfile:
33+
34+
```ruby
35+
gem 'passkit'
36+
```
37+
38+
And then execute:
39+
40+
$ bundle install
41+
42+
Or install it yourself as:
43+
44+
$ gem install passkit
45+
46+
Run the initializer:
47+
48+
$ rails g passkit:install
49+
50+
that will generate the migrations and the initializer file.
51+
52+
Mount the engine in your `config/routes.rb`:
53+
54+
```ruby
55+
mount Passkit::Engine => '/passkit', as: 'passkit'
56+
```
57+
58+
and run `bin/rails db:migrate`.
59+
60+
### Setup environment variables
61+
62+
If you followed the installation steps, you already saw that Passkit provides
63+
you the tables and ActiveRecord models, and also an engine with the necessary APIs already implemented.
64+
65+
Now is your turn. Before proceeding, you need to set these ENV variables:
66+
* `PASSKIT_WEB_SERVICE_HOST`
67+
* `PASSKIT_CERTIFICATE_KEY`
68+
* `PASSKIT_PRIVATE_P12_CERTIFICATE`
69+
* `PASSKIT_APPLE_INTERMEDIATE_CERTIFICATE`
70+
* `PASSKIT_APPLE_TEAM_IDENTIFIER`
71+
* `PASSKIT_PASS_TYPE_IDENTIFIER`
72+
73+
We have a [specific guide on how to get all these](docs/passkit_environment_variables.md), please follow it.
74+
You cannot start using this library without these variables set, and we cannot do the work for you.
75+
76+
## Usage
77+
78+
If you followed the installation steps and you have the ENV variables set, we can start looking at what is provided for you.
79+
80+
### Dashboard
81+
82+
Head to `http://localhost:3000/passkit/previews` and you will see a first `ExampleStoreCard` available for download.
83+
You can click on the button and you will obtain a `.pkpass` file that you can simply open or install on your phone.
84+
The dashboard has also a view for logs, and a view for emitted passes.
85+
86+
### Mailer Helpers
87+
88+
If you use mailer previews, you can create the following file in `spec/mailers/previews/passkit/example_mailer_preview.rb`:
89+
90+
```ruby
91+
module Passkit
92+
class ExampleMailerPreview < ActionMailer::Preview
93+
def example_email
94+
Passkit::ExampleMailer.example_email
95+
end
96+
end
97+
end
98+
```
99+
100+
and head to `http://localhost:3000/rails/mailers/` to see an example of email with links to download the Wallet Pass.
101+
Please check the source code of [ExampleMailer](app/mailers/passkit/example_mailer.rb) to see how to distribute your own Wallet Passes.
102+
103+
### Example Passes
104+
105+
Please check the source code of the [ExampleStoreCard](lib/passkit/example_store_card.rb) to see how to create your own Wallet Passes.
106+
107+
Again, looking at these examples, is the easiest way to get started.
108+
109+
### Create your own Wallet Pass
110+
111+
You can create your own Wallet Passes by creating a new class that inherits from `Passkit::BasePass` and
112+
defining the methods that you want to override.
113+
114+
You can define colors, fields and texts. You can also define the logo and the background image.
115+
116+
You should place the images in a 'private/passkit/<your_downcased_passname>' folder.
117+
There is a [dummy app in the gem](test/dummy) that you can use to check how to create your own Wallet Passes.
118+
119+
### Serve your Wallet Pass
120+
121+
Use the [Passkit::UrlGenerator](lib/passkit/url_generator.rb) to generate the URL to serve your Wallet Pass.
122+
You can initialize it with:
123+
124+
```ruby
125+
Passkit::UrlGenerator.new(pass_class: Passkit::MyPass, generator: User.find(1))
126+
```
127+
128+
and then use `.android` or `.ios` to get the URL to serve the Wallet Pass.
129+
Again, check the example mailer included in the gem to see how to use it.
130+
131+
## Debug issues
132+
133+
* On Mac, open the `Console.app` to view the errors.
134+
* Check the logs on http://localhost:3000/passkit/logs
135+
* In case of error "The passTypeIdentifier or teamIdentifier provided may not match your certificate,
136+
or the certificate trust chain could not be verified." the certificate (p12) might be expired.
137+
138+
## Development
139+
140+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
141+
142+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
143+
144+
## Contributing
145+
146+
Bug reports and pull requests are welcome on GitHub at https://github.com/coorasse/passkit. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/coorasse/passkit/blob/master/CODE_OF_CONDUCT.md).
147+
148+
## License
149+
150+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
151+
152+
## Code of Conduct
153+
154+
Everyone interacting in the Passkit project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/coorasse/passkit/blob/master/CODE_OF_CONDUCT.md).
155+
156+
## Credits
157+
158+
* <a href="https://www.flaticon.com/free-icons/credit-card" title="credit card icons">Credit card icons created by Iconfromus - Flaticon</a>
159+
160+
* https://www.sitepoint.com/whats-in-your-wallet-handling-ios-passbook-with-ruby/

Rakefile

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# frozen_string_literal: true
2+
3+
require "bundler/gem_tasks"
4+
require "rake/testtask"
5+
6+
Rake::TestTask.new(:test) do |t|
7+
t.libs << "test"
8+
t.libs << "lib"
9+
t.test_files = FileList["test/**/test_*.rb"]
10+
end
11+
12+
require "standard/rake"
13+
14+
task default: %i[test standard]
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module Passkit
2+
module Api
3+
module V1
4+
class LogsController < ActionController::API
5+
def create
6+
params[:logs].each do |message|
7+
Log.create!(content: message)
8+
end
9+
render json: {}, status: :ok
10+
end
11+
end
12+
end
13+
end
14+
end

0 commit comments

Comments
 (0)