Code Monkey home page Code Monkey logo

passcards-swift's Introduction

Passcards

A simple Wallet server that implements the PassKit Web Service requirements. (This is a Swift re-implementation of the original Parse-backed version.)

Building

$ swift build -c release
$ .build/release/App

Required Environment

Key Description
APNS_KEY_ID APNS key ID
APNS_PRIVATE_KEY APNS private key content
APNS_TEAM_ID APNS team ID
APNS_TOPIC APNS (certificate) topic
PG_DBNAME Postgres database name
PG_HOST Postgres host
PG_PASSWORD Postgres password
PG_PORT Postgres port
PG_USER Postgres user
S3_ACCESS_KEY S3 access key
S3_BUCKET S3 bucket name
S3_REGION S3 bucket region
S3_SECRET_KEY S3 access secret key
UPDATE_PASSWORD Update password (unset == unlimited access)

Deployment

  1. Create an app on Heroku

    $ heroku apps:create [NAME]
  2. Set the environment variables (as described above)

    $ heroku config:set X=abc Y=def Z=ghi ...

    If you use the Heroku PostgreSQL plugin, you will need to add the plugin (which sets the DATABASE_URL environment variable) and then set the required PG_* variables.

  3. Install the Container Registry Plugin

    $ heroku plugins:install heroku-container-registry
  4. Build and deploy Docker image to Heroku

    $ heroku container:push web
  5. Open the website (a static single-page site)

    $ heroku open

Usage

Creating a Pass

This is beyond the scope of the project, but recommended reading includes:

You will want to set https://my-heroku-app.herokuapp.com/ as the webServiceURL root key in your pass.json.

Example passes, as well as the source of a command-line tool for signing Pass bundles (signpass), can be found here.

Uploading a Pass

$ curl -X POST \
    -H "Authorization: Bearer MY_UPDATE_PASSWORD" \
    -F "pass=@a_local_file.pkpass" \
    -F "authentication_token=AUTHENTICATION_TOKEN" \
    -F "pass_type_identifier=PASS_TYPE_IDENTIFIER" \
    -F "serial_number=SERIAL_NUMBER" \
    https://my-heroku-app.herokuapp.com/VANITY_URL.pkpass

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.

Updating a Pass

$ curl -X PUT \
    -H "Authorization: Bearer MY_UPDATE_PASSWORD" \
    -F "pass=@a_local_file.pkpass" \
    https://my-heroku-app.herokuapp.com/VANITY_URL.pkpass

a_local_file.pkpass is the new local file to replace on the server. MY_UPDATE_PASSWORD is the same UPDATE_PASSWORD as above.

Sharing a Pass

A Pass recipient can go to https://my-heroku-app.herokuapp.com/VANITY_URL.pkpass to receive your pass.

Author

Alexsander Akers, [email protected]

My Personal Set-up

On my personal website (https://pass.a2.io), I use CloudFlare 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.

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.

Your app service service is only woken...

  1. when someone adds a pass (triggering a pass registration).
  2. when someone deletes a pass (triggering pass de-registration).
  3. when someone triggers a manual refresh of a pass.
  4. when someone toggles "Automatic Updates" on the backside of a pass (shown with the ⓘ button).

License

Passcards is available under the MIT license. See the LICENSE file for more info.

passcards-swift's People

Contributors

a2 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

passcards-swift's Issues

Build error in release/App

Hi,

Upon initial setup, when trying to compile locally before deploying, the error below happens.
Any idea what this could be from?

.build/release/App

/passcards-swift/.build/x86_64-apple-macosx10.10/release/App ; exit;
fatal error: Error raised at top level: Storage.StorageProvider.Error.missingAccessKey: file /Library/Caches/com.apple.xbs/Sources/swiftlang/swiftlang-900.0.65/src/swift/stdlib/public/core/ErrorType.swift, line 187
[1]    60670 illegal hardware instruction  

Thanks

Crash while processing the APNS private key

The app crashes while attempting to read my APNS private key.
What am I doing wrong?

frame #0: 0x000000010020bd46 CLibreSSL`EC_KEY_set_conv_form(key=0x0000000000000000, cform=POINT_CONVERSION_UNCOMPRESSED) at ec_key.c:475
frame #1: 0x000000010000733f App`ECKeys(privateKey="-----BEGIN PRIVATE KEY-----\nSSdtIG5vdCBnb25uYSBnaXZlIHlvdSBteSBwcml2YXRlIGtleS4gSXQncyBwcml2YXRlISBOaWNlIHRyeSB0aG91Z2ggOik=\n-----END PRIVATE KEY-----") -> (privateKey : String, publicKey : String)? at OpenSSLHelper.swift:22
frame #2: 0x00000001000050aa App`Droplet.vaporAPNS(self=0x0000000101c09e00, $error=Error @ 0x00007fff5fbfe2d0) throws -> VaporAPNS at Droplet+VaporAPNS.swift:11
frame #3: 0x000000010000a695 App`VanityCollection.init(droplet=0x0000000101c09e00, $error=Error @ 0x00007fff5fbfe2d0) throws -> VanityCollection at VanityCollection.swift:32
frame #4: 0x000000010000a9df App`VanityCollection.__allocating_init(droplet : Droplet) throws -> VanityCollection at VanityCollection.swift:0
frame #5: 0x000000010000674d App`main at main.swift:14
frame #6: 0x00007fff96c33235 libdyld.dylib`start + 1

How to find APNs topic

Unfortunately I'm not too experienced with APNs - could you please detail how to retrieve the APNs topic to set the env variable?

I have created an App ID with Push (prod) capability, and downloaded that production SSL certificate. However I am unable to extract the topic from this.

Thanks

Better description and APNS updates

Can you provide better description about deployment? I want to see how to test it local, I want to know, how to generate right APNS stuff and so on about each step.

In case of APNS, there is a new way to communicate with apple servers - simple key, can you update the server to support it?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.