RobotsAndPencils / buford

A push notification delivery engine for the new HTTP/2 APNS service.
MIT License
475 stars 52 forks source link

Push notification - Package manifest format #98

Open miroslavhajek opened 5 years ago

miroslavhajek commented 5 years ago

1. What version of Go are you using (go version)?

2. What operating system (GOOS) are you using (go env) and what version?

3. What did you do? (steps to reproduce or a code sample is helpful)

Create package for Apple notification via

pkg := pushpackage.New(c.Response().Writer)
pkg.EncodeJSON("website.json", ...)
pkg.File("icon.iconset/icon_16x16.png", "static/icon_16x16.png")
pkg.File("icon.iconset/icon_16x16@2x.png", "static/icon_16x16@2x.png")
err := pkg.Sign(...) // err = nil, OK

Apple V2 documentation

https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/NotificationProgrammingGuideForWebsites/PushNotifications/PushNotifications.html#//apple_ref/doc/uid/TP40013225-CH3-SW24

4. What did you expect to see?

The manifest is a JSON dictionary named manifest.json that contains an entry for each file, where the local file path is the entry’s key, and a dictionary object is the entry’s value. This dictionary contains the hashType and hashValue, which is the file’s SHA512 checksum; for example:

{
   "website.json": {
      "hashType": "sha512",
      "hashValue": "..."
   },
   "icon.iconset/icon_16x16.png": {
      "hashType": "sha512",
      "hashValue": "8bb462e25ca79cca241355f5ae97ffab352acf7d2a0390f6547f1d0a55ade59e01e725bea70778ad2822b1ec137a8c0547197727ae2e9fed620b0d3ddea6803b"
   },
   ...
}

5. What did you see instead?

{
  "icon.iconset/icon_16x16.png": "da39a3ee5e6b4b0d3255bfef95601890afd80709",
  "icon.iconset/icon_16x16@2x.png": "da39a3ee5e6b4b0d3255bfef95601890afd80709",
  "website.json": "..."
}

Response from Apple on {webServiceURL}/v1/log API:

{"logs":["Unable to generate ICNS file for push notification package"]}

In buford@v0.14.0/pushpackage/pushpackage.go in only simple hastable and the checksum is sha1 algorithm instead of sha512 (buford@v0.14.0/pushpackage/checksum.go).

package pushpackage

// Package for website push package or wallet pass package.
type Package struct {
    z *zip.Writer

    // manifest is a map of relative file paths to their SHA checksums
    manifest map[string]string

    err error
}