-
Notifications
You must be signed in to change notification settings - Fork 7
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
Send template updates to Apple Wallet passes (#6) #73
Conversation
@aahna-ashina is attempting to deploy a commit to the Nation3 Team on Vercel. A member of the Team first needs to authorize it. |
Return `serialNumbers`
…ahna-ashina/mobile-passport into dw-58/send-template-updates-to
Codecov Report
@@ 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
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
There was a problem hiding this 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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@johnmark13 The Goerli environment variables are needed for running unit tests and integration tests.
@@ -13,5 +13,5 @@ export interface GooglePass extends Pass { | |||
|
|||
export enum Platform { | |||
Apple, | |||
Google, | |||
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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) | ||
} |
There was a problem hiding this comment.
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})
?
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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') | ||
} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
Populate the pass template with details stored in the `downloads` table
- Add `latest_updates` table to database - Use timestamp of latest update in `Last-Modified` header when downloading .pkpass - Use timestamp of latest update as `lastUpdated` when getting the list of updatable passes
Return `lastUpdated` as string instead of number, adhering to the Apple documentation: https://developer.apple.com/documentation/walletpasses/serialnumbers
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this 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 :)
Send an Updated Pass
North Star Metric: Number of Active Citizens
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?
/api/apple/v1/passes/pass.org.passport.nation3/<serialNumber>
and opened the.pkpass
on an iOS deviceapi.push.apple.com
while observing Vercel logs.pkpass
file generation/apple/v1/log
for testing Apple request responsesAre There Admin Tasks?
0.7.0.sql
(passports-goerli
)0.7.0.sql
(passports-mainnet
)0.8.0.sql
(passports-goerli
)0.8.0.sql
(passports-mainnet
)0.9.0.sql
(passports-goerli
)0.9.0.sql
(passports-mainnet
)Are There Documentation Tasks?