Skip to content

Commit f341917

Browse files
committed
Update README
1 parent 73de21a commit f341917

File tree

1 file changed

+92
-3
lines changed

1 file changed

+92
-3
lines changed

README.md

+92-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# Passcards
22

3-
A simple Wallet (née Passbook) server. This is a Swift re-implementation of the original [Parse-backed version](https://github.com/a2/passcards-parse).
3+
A simple [Wallet](https://developer.apple.com/wallet/) server that implements the [PassKit Web Service](https://developer.apple.com/library/content/documentation/PassKit/Reference/PassKit_WebService/WebService.html) requirements. (This is a Swift re-implementation of the original [Parse-backed version](https://github.com/a2/passcards-parse).)
44

5-
## Usage
5+
## Building
66

77
```sh
88
$ swift build -c release
99
$ .build/release/App
1010
```
1111

12-
**Environment:**
12+
## Required Environment
1313

1414
| Key | Description |
1515
| --- | ----------- |
@@ -28,10 +28,99 @@ $ .build/release/App
2828
| S3_SECRET_KEY | S3 access secret key |
2929
| UPDATE_PASSWORD | Update password *(unset == unlimited access)* |
3030

31+
## Deployment
32+
33+
1. Create an app on Heroku
34+
35+
```sh
36+
$ heroku apps:create [NAME]
37+
```
38+
39+
2. Set the environment variables (as described above)
40+
41+
```sh
42+
$ heroku config:set X=abc Y=def Z=ghi ...
43+
```
44+
45+
If you use the [Heroku PostgreSQL](https://devcenter.heroku.com/articles/heroku-postgresql) plugin, you will need to add the plugin (which sets the `DATABASE_URL` environment variable) and then set the required `PG_*` variables.
46+
47+
3. Install the [Container Registry Plugin](https://devcenter.heroku.com/articles/container-registry-and-runtime)
48+
49+
```sh
50+
$ heroku plugins:install heroku-container-registry
51+
```
52+
53+
4. Build and deploy Docker image to Heroku
54+
55+
```sh
56+
$ heroku container:push web
57+
```
58+
59+
5. Open the website (a static single-page site)
60+
61+
```sh
62+
$ heroku open
63+
```
64+
65+
## Usage
66+
67+
### Creating a Pass
68+
69+
This is beyond the scope of the project, but recommended reading includes:
70+
71+
- Wallet Developer Guide: [Building Your First Pass](https://developer.apple.com/library/content/documentation/UserExperience/Conceptual/PassKit_PG/YourFirst.html#//apple_ref/doc/uid/TP40012195-CH2-SW1), [Pass Design and Creation](https://developer.apple.com/library/content/documentation/UserExperience/Conceptual/PassKit_PG/Creating.html#//apple_ref/doc/uid/TP40012195-CH4-SW1)
72+
- [PassKit Package Format Reference](https://developer.apple.com/library/content/documentation/UserExperience/Reference/PassKit_Bundle/Chapters/Introduction.html)
73+
74+
You will want to set _https://my-heroku-app.herokuapp.com/_ as the `webServiceURL` root key in your _pass.json_.
75+
76+
Example passes, as well as the source of a command-line tool for signing Pass bundles (_signpass_), can be found [here](https://developer.apple.com/services-account/download?path=/iOS/Wallet_Support_Materials/WalletCompanionFiles.zip).
77+
78+
### Uploading a Pass
79+
80+
```sh
81+
$ curl -X POST \
82+
-H "Authorization: Bearer MY_UPDATE_PASSWORD" \
83+
-F "pass=@a_local_file.pkpass" \
84+
-F "authentication_token=AUTHENTICATION_TOKEN" \
85+
-F "pass_type_identifier=PASS_TYPE_IDENTIFIER" \
86+
-F "serial_number=SERIAL_NUMBER" \
87+
https://my-heroku-app.herokuapp.com/VANITY_URL.pkpass
88+
```
89+
90+
In the above cURL command, _a_local_file.pkpass_ is a file in the current working directory. Set the `authentication_token`, `pass_type_identifier`, and `serial_number` fields to their corresponding values from the pass's _pass.json_. _MY_UPDATE_PASSWORD_ is the `UPDATE_PASSWORD` environment variable set in your app.
91+
92+
### Updating a Pass
93+
94+
```sh
95+
$ curl -X PUT \
96+
-H "Authorization: Bearer MY_UPDATE_PASSWORD" \
97+
-F "pass=@a_local_file.pkpass" \
98+
https://my-heroku-app.herokuapp.com/VANITY_URL.pkpass
99+
```
100+
101+
_a_local_file.pkpass_ is the new local file to replace on the server. _MY_UPDATE_PASSWORD_ is the same `UPDATE_PASSWORD` as above.
102+
103+
### Sharing a Pass
104+
105+
A Pass recipient can go to *https://my-heroku-app.herokuapp.com/VANITY_URL.pkpass* to receive your pass.
106+
31107
## Author
32108
33109
Alexsander Akers, [email protected]
34110
111+
### My Personal Set-up
112+
113+
On my personal website (*https://pass.a2.io*), I use [CloudFlare](https://www.cloudflare.com) to secure the website subdomain that points to Heroku because then I get TLS / HTTPS (which is required for PassKit in production) for free, because I'm cheap. To that extent, I also use Heroku's free PostgreSQL plan and the [free dyno hours](https://devcenter.heroku.com/articles/free-dyno-hours).
114+
115+
A sleeping-when-idle Heroku app is *perfect* for Wallet services because an iOS device will call your service endpoints in the background and retry upon timeout.
116+
117+
Your app service service is only woken...
118+
119+
1. when someone adds a pass (triggering a pass registration).
120+
2. when someone deletes a pass (triggering pass de-registration).
121+
3. when someone triggers a manual refresh of a pass.
122+
4. when someone toggles "Automatic Updates" on the backside of a pass (shown with the ⓘ button).
123+
35124
## License
36125
37126
Passcards is available under the MIT license. See the LICENSE file for more info.

0 commit comments

Comments
 (0)