Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send template updates to Apple Wallet passes (#6) #73

Merged
merged 45 commits into from
Sep 13, 2022

Conversation

aahna-ashina
Copy link
Member

@aahna-ashina aahna-ashina commented Sep 6, 2022

Send an Updated Pass

North Star Metric: Number of Active Citizens

  • Current metric: 12.43% of the 177 citizens voted on the last proposal.
  • Theory: Sending Nation3 updates to a citizen's Apple Pass when a new proposal is published will increase voting activity by at least 20%.

Dework Task

https://app.dework.xyz/nation3/app-2?taskId=fb541897-eb04-4c72-ba7d-838f3da72a3f
https://app.dework.xyz/nation3/app-2?taskId=d63e775a-1f47-4db3-b91e-2e7bd33d1e5a

Related GitHub Issue

#6
closes #33
closes #72

How Has This Been Tested?

  • e61226c Log a Message (integration test)
  • Added automated integration tests
  • Tested manually with iOS device while observing Vercel logs
  • Tested /api/apple/v1/passes/pass.org.passport.nation3/<serialNumber> and opened the .pkpass on an iOS device

    IMG_0037 IMG_0036 IMG_0038

  • Sent request to api.push.apple.com while observing Vercel logs
  • 5af5e57 Added unit tests for .pkpass file generation
  • 5762a0b Added /apple/v1/log for testing Apple request responses

Are There Admin Tasks?

  • Database migration
    • @aahna-ashina Run migration script in 0.7.0.sql (passports-goerli)
    • @aahna-ashina Run migration script in 0.7.0.sql (passports-mainnet)
    • @aahna-ashina Run migration script in 0.8.0.sql (passports-goerli)
    • @aahna-ashina Run migration script in 0.8.0.sql (passports-mainnet)
    • @aahna-ashina Run migration script in 0.9.0.sql (passports-goerli)
    • @aahna-ashina Run migration script in 0.9.0.sql (passports-mainnet)

Are There Documentation Tasks?

  • 4991d07 Add documentation for updating a template

@aahna-ashina aahna-ashina self-assigned this Sep 6, 2022
@vercel
Copy link

vercel bot commented Sep 6, 2022

@aahna-ashina is attempting to deploy a commit to the Nation3 Team on Vercel.

A member of the Team first needs to authorize it.

@aahna-ashina aahna-ashina removed the request for review from johnmark13 September 7, 2022 01:26
@codecov-commenter
Copy link

codecov-commenter commented Sep 7, 2022

Codecov Report

Merging #73 (2e04076) into main (f895969) will increase coverage by 61.35%.
The diff coverage is 81.25%.

@@             Coverage Diff             @@
##             main      #73       +/-   ##
===========================================
+ Coverage   19.65%   81.00%   +61.35%     
===========================================
  Files           5        5               
  Lines         173      179        +6     
  Branches       15       16        +1     
===========================================
+ Hits           34      145      +111     
+ Misses        138       33      -105     
  Partials        1        1               
Impacted Files Coverage Δ
server/utils/Config.ts 90.90% <ø> (ø)
server/utils/Passes.ts 84.68% <81.25%> (+84.68%) ⬆️
server/utils/AppleCryptoUtils.ts 100.00% <0.00%> (+41.46%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

Copy link
Contributor

@johnmark13 johnmark13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great, I think that you are still working through your tasks and moving things around - so I have approved it with some comments.

cache-dependency-path: server/package-lock.json
- run: npm install

- run: cp .env.local.goerli .env.local
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd probably rename these files as .local is not usually checked into a repository, not a big deal though.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -13,5 +13,5 @@ export interface GooglePass extends Pass {

export enum Platform {
Apple,
Google,
Google
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a Prettier change?

Copy link
Member Author

@aahna-ashina aahna-ashina Sep 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@johnmark13 No, haven't added Prettier config yet. Maybe we should? Added it to #76

@@ -4,7 +4,7 @@ module.exports = {
testEnvironment: 'node',
coverageThreshold: {
global: {
lines: 18.55
lines: 80.00
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💪

for (const index in result.data) {
const serialNumber : string = result.data[index]['serial_number']
serialNumbers[Number(index)] = String(serialNumber)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use map instead serialNumbers = result.data.map((sn) => {your code here})?

Copy link
Member Author

@aahna-ashina aahna-ashina Sep 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@johnmark13 Yes, absolutely. I think we should do some refactoring as part of another pull request, and will keep this comment in mind. #76


if (serialNumbers.length == 0) {
// There are no matching passes
res.status(204).end()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not considered a failure to not have a match?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@johnmark13 No, because this endpoint is for getting a list of updatable passes. And if the passes on the device are already up to date, no serial numbers (passport IDs) will be returned (HTTP 204 No Content). At least that's the required HTTP response code used in the Apple documentation: https://developer.apple.com/documentation/walletpasses/get_the_list_of_updatable_passes

// Expected request method: POST
console.log('req.method:', req.method)
if (req.method != 'POST') {
throw new Error('Wrong request method: ' + req.method)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

http response with code 405?

Copy link
Member Author

@aahna-ashina aahna-ashina Sep 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@johnmark13 Yes, should be 405, thank you. Added it to the task list at #76

console.log('authenticationToken:', authenticationToken)
if (!authenticationToken || String(authenticationToken).trim().length == 0) {
throw new Error('Missing/empty header: Authorization')
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will you move all of this to middleware?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@johnmark13 Added this as a refactoring task at #76

@vercel
Copy link

vercel bot commented Sep 12, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
mobile-passport ✅ Ready (Inspect) Visit Preview Sep 12, 2022 at 10:04AM (UTC)

Copy link
Contributor

@luisivan luisivan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing! I was trying to test sending push notifications too, but I realized this PR is for updating the passes themselves. I successfully downloaded an updatable version of my N3 passport :)

@aahna-ashina aahna-ashina mentioned this pull request Sep 13, 2022
6 tasks
@aahna-ashina aahna-ashina merged commit b5aedc3 into nation3:main Sep 13, 2022
@aahna-ashina aahna-ashina deleted the dw-58/send-template-updates-to branch September 29, 2022 09:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Apple Wallet: Log a Message
4 participants