{"id":21083587,"url":"https://github.com/threema-ch/push-relay","last_synced_at":"2025-04-05T20:09:21.916Z","repository":{"id":17475249,"uuid":"81233821","full_name":"threema-ch/push-relay","owner":"threema-ch","description":"Relay service for Threema Web push notifications.","archived":false,"fork":false,"pushed_at":"2025-01-29T14:02:22.000Z","size":558,"stargazers_count":99,"open_issues_count":0,"forks_count":20,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-03-29T19:08:05.520Z","etag":null,"topics":["apns","gcm","push","rust","threema","webclient"],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/threema-ch.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-02-07T17:17:10.000Z","updated_at":"2025-03-02T13:34:42.000Z","dependencies_parsed_at":"2023-11-14T10:28:32.673Z","dependency_job_id":"f329713a-b3a4-4f62-af68-0a325f9f64ab","html_url":"https://github.com/threema-ch/push-relay","commit_stats":null,"previous_names":[],"tags_count":29,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/threema-ch%2Fpush-relay","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/threema-ch%2Fpush-relay/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/threema-ch%2Fpush-relay/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/threema-ch%2Fpush-relay/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/threema-ch","download_url":"https://codeload.github.com/threema-ch/push-relay/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247393572,"owners_count":20931813,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["apns","gcm","push","rust","threema","webclient"],"created_at":"2024-11-19T20:18:53.680Z","updated_at":"2025-04-05T20:09:21.896Z","avatar_url":"https://github.com/threema-ch.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Push Relay\n\n[![CI][ci-badge]][ci]\n[![License][license-badge]][license]\n\nThis server accepts push requests via HTTP and relays those requests to the appropriate push backends.\n\nSupported backends:\n\n- Apple APNs\n- Google FCM\n- Huawei HMS\n- Threema Gateway\n\n## Request Format\n\n- POST request to `/push`\n- Request body must use `application/x-www-form-urlencoded` encoding\n\nRequest keys:\n\n- `type`: `apns`, `fcm`, `hms` or `threema-gateway`\n- `token`: The device push token (not provided when using Threema Gateway)\n  - for FCM: The token itself as received from the OS\n  - for iOS: The hex encoded token (without bundle id or encryption key appended)\n- `session`: SHA256 hash of public permanent key of the initiator\n- `version`: Threema Web protocol version\n- `affiliation` (optional): An identifier for affiliating consecutive pushes\n- `ttl` (optional): The lifespan of a push message, defaults to 90 seconds\n- `collapse_key`: (optional) A parameter identifying a group of push messages that can be\n  collapsed.\n- `bundleid` (APNs only): The bundle id to use\n- `endpoint` (APNs only): Either `p` (production) or `s` (sandbox)\n- `appid` (HMS only): Can be used to differentiate between multiple configs\n- `identity` (Threema Gateway only): The Threema ID of the user.\n- `public_key` (Threema Gateway only): Public key associated to the Threema ID of the user.\n\nExamples:\n\n    curl -X POST -H \"Origin: https://localhost\" localhost:3000/push \\\n        -d \"type=apns\u0026token=asdf\u0026session=123deadbeef\u0026version=3\u0026bundleid=com.example.app\u0026endpoint=s\"\n    curl -X POST -H \"Origin: https://localhost\" localhost:3000/push \\\n        -d \"type=fcm\u0026token=asdf\u0026session=123deadbeef\u0026version=3\"\n    curl -X POST -H \"Origin: https://localhost\" localhost:3000/push \\\n        -d \"type=hms\u0026appid=123456\u0026token=asdf\u0026session=123deadbeef\u0026version=3\"\n    curl -X POST -H \"Origin: https://localhost\" localhost:3000/push \\\n        -d \"type=threema-gateway\u0026session=123deadbeef\u0026version=3\u0026identity=ECHOECHO\u0026public_key=0000000000000000000000000000000000000000000000000000000000000000\"\n\nPossible response codes:\n\n- `HTTP 204 (No Content)`: Request was processed successfully\n- `HTTP 400 (Bad Request)`: Invalid or missing POST parameters (including expired push tokens)\n- `HTTP 500 (Internal Server Error)`: Processing of push request failed on the Push Relay server\n- `HTTP 502 (Bad Gateway)`: Processing of push request failed on the APNs, FCM, HMS or Threema Gateway server\n\n## Push Payload\n\nThe payload format looks like this:\n\n- `wcs`: Webclient session (sha256 hash of the public permanent key of the\n  initiator), `string`\n- `wca`: An optional identifier for affiliating consecutive pushes, `string` or `null`\n- `wct`: Unix epoch timestamp of the request in seconds, `i64`\n- `wcv`: Protocol version, `u16`\n\n### APNs\n\nThe APNs message contains a key \"3mw\" containing the payload data as specified\nabove.\n\n### FCM / HMS / Threema Gateway\n\nThe FCM, HMS and Threema Gateway messages contain the payload data as specified above.\n\n## Running\n\nYou need the Rust compiler. First, create a `config.toml` file that looks like this:\n\n    [fcm]\n    service_account_key_base64 = \"aHR0cHM6Ly93d3cueW91dHViZS5jb20vd2F0Y2g/dj1kUXc0dzlXZ1hjUQo=\"\n    project_id = 12345654321\n    max_retries = 6\n\n    [apns]\n    keyfile = \"your-keyfile.p8\"\n    key_id = \"AB123456XY\"\n    team_id = \"CD987654YZ\"\n\nTo support HMS as well, you need to add one or more named HMS config sections.\nThe name should correspond to the App ID (and currently matches the Client ID).\n\n    [hms.app-id-1]\n    client_id = \"your-client-id\"\n    client_secret = \"your-client-secret\"\n\n    [hms.app-id-2]\n    client_id = \"your-client-id\"\n    client_secret = \"your-client-secret\"\n\nTo support Threema Gateway, the following config sections need to be added.\nNote: The apps only support messages sent from `*3MAPUSH`.\n\n    [threema_gateway]\n    base_url = \"https://msgapi.threema.ch\"\n    identity = \"*3MAPUSH\"\n    secret = \"secret-for-*3MAPUSH\"\n    private_key_file = \"private-key-file-for-*3MAPUSH\"\n\nIf you want to log the pushes to InfluxDB, add the following section:\n\n    [influxdb]\n    connection_string = \"http://127.0.0.1:8086\"\n    user = \"foo\"\n    pass = \"bar\"\n    db = \"baz\"\n\nThen simply run\n\n    export RUST_LOG=push_relay=debug,hyper=info,a2=info,tower=debug\n    cargo run\n\n...to build and start the server in debug mode.\n\n## Deployment\n\n- Always create a build in release mode: `cargo build --release`\n- Use a reverse proxy with proper TLS termination (e.g. Nginx)\n- Set `RUST_LOG=info` env variable\n\n## Testing\n\nTo run tests:\n\n    cargo test\n\n## Linting\n\nTo run lints:\n\n    $ rustup component add clippy\n    $ cargo clean \u0026\u0026 cargo clippy --all-targets\n\n## License\n\nLicensed under either of\n\n * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or\n   http://www.apache.org/licenses/LICENSE-2.0)\n * MIT license ([LICENSE-MIT](LICENSE-MIT) or\n   http://opensource.org/licenses/MIT)\n\nat your option.\n\n\u003c!-- Badges --\u003e\n[ci]: https://github.com/threema-ch/push-relay/actions?query=workflow%3ACI\n[ci-badge]: https://img.shields.io/github/actions/workflow/status/threema-ch/push-relay/ci.yml?branch=master\n[license]: https://github.com/threema-ch/push-relay#license\n[license-badge]: https://img.shields.io/badge/License-Apache%202.0%20%2f%20MIT-blue.svg\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthreema-ch%2Fpush-relay","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthreema-ch%2Fpush-relay","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthreema-ch%2Fpush-relay/lists"}