Reputation: 1040
I've deployed a parse-server app in Heroku that I'd been developing locally using Docker. This app uses push notifications, and so needs access to some crypto data to play with APNs.
Locally I mounted a volume with the token key file in it. On Heroku this isn't an option, and I don't want to bundle the key in the package unencrypted. I've been trying to encode the token key in the JSON argument to the "PARSE_SERVER_PUSH" environment variable in different ways. It seems what's needed is a Buffer, but I have no idea how to represent such a thing in JSON, and I haven't found anything through some searching.
I'm currently using this at my push config:
{"ios":
{
"token": {
"key": {"type":"Buffer","data":[45, 45, ... 45]},
"keyId": "MYKEYID",
"teamId": "MYTEAMID"
},
"topic": "com.myApp",
"production": false
}
}
But the server chokes on the 'key' field:
2019-01-23T19:47:36.725181+00:00 app[web.1]: VError: Failed loading token key: path must be a string or Buffer
2019-01-23T19:47:36.725191+00:00 app[web.1]: at prepareToken (/parse-server/node_modules/apn/lib/credentials/token/prepare.js:15:13)
2019-01-23T19:47:36.725193+00:00 app[web.1]: at config (/parse-server/node_modules/apn/lib/config.js:43:31)
2019-01-23T19:47:36.725194+00:00 app[web.1]: at new Client (/parse-server/node_modules/apn/lib/client.js:21:19)
2019-01-23T19:47:36.725195+00:00 app[web.1]: at new Provider (/parse-server/node_modules/apn/lib/provider.js:12:19)
2019-01-23T19:47:36.725201+00:00 app[web.1]: at Function._createProvider (/parse-server/node_modules/@parse/push-adapter/lib/APNS.js:251:22)
2019-01-23T19:47:36.725203+00:00 app[web.1]: at new APNS (/parse-server/node_modules/@parse/push-adapter/lib/APNS.js:81:29)
2019-01-23T19:47:36.725204+00:00 app[web.1]: at new ParsePushAdapter (/parse-server/node_modules/@parse/push-adapter/lib/ParsePushAdapter.js:65:40)
2019-01-23T19:47:36.725205+00:00 app[web.1]: at loadAdapter (/parse-server/lib/Adapters/AdapterLoader.js:31:16)
2019-01-23T19:47:36.725206+00:00 app[web.1]: at loadAdapter (/parse-server/lib/Adapters/AdapterLoader.js:24:12)
2019-01-23T19:47:36.725207+00:00 app[web.1]: at getPushController (/parse-server/lib/Controllers/index.js:230:54)
Does anybody know how to achieve this?
EDIT: The documentation (https://github.com/node-apn/node-apn/blob/master/doc/provider.markdown) suggests it's possible:
token.key {Buffer|String} The filename of the provider token key (as supplied by Apple) to load from disk, or a Buffer/String containing the key data.
Upvotes: 2
Views: 314