{"id":31031770,"url":"https://github.com/marknefedov/go-webpush","last_synced_at":"2025-09-14T00:47:49.211Z","repository":{"id":313418236,"uuid":"1051357121","full_name":"marknefedov/go-webpush","owner":"marknefedov","description":null,"archived":false,"fork":false,"pushed_at":"2025-09-05T23:22:05.000Z","size":32,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-09-05T23:34:28.013Z","etag":null,"topics":["golang","push","push-notifications","vapid","vapid-keys","web","webpush-notifications"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/marknefedov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-05T21:07:12.000Z","updated_at":"2025-09-05T23:22:09.000Z","dependencies_parsed_at":"2025-09-05T23:34:31.056Z","dependency_job_id":"4151d019-39e8-4f51-8439-45a54c033b8e","html_url":"https://github.com/marknefedov/go-webpush","commit_stats":null,"previous_names":["marknefedov/go-webpush"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/marknefedov/go-webpush","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marknefedov%2Fgo-webpush","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marknefedov%2Fgo-webpush/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marknefedov%2Fgo-webpush/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marknefedov%2Fgo-webpush/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marknefedov","download_url":"https://codeload.github.com/marknefedov/go-webpush/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marknefedov%2Fgo-webpush/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275047954,"owners_count":25396337,"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","status":"online","status_checked_at":"2025-09-13T02:00:10.085Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["golang","push","push-notifications","vapid","vapid-keys","web","webpush-notifications"],"created_at":"2025-09-14T00:47:46.143Z","updated_at":"2025-09-14T00:47:49.190Z","avatar_url":"https://github.com/marknefedov.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-webpush \n[![Go Reference](https://pkg.go.dev/badge/github.com/marknefedov/go-webpush.svg)](https://pkg.go.dev/github.com/marknefedov/go-webpush)\n[![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/marknefedov/go-webpush)\n[![GitHub release (latest SemVer)](https://img.shields.io/github/v/tag/marknefedov/go-webpush)](https://github.com/marknefedov/go-webpush/tag/latest)\n[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/marknefedov/go-webpush/ci.yml?branch=master)](https://github.com/marknefedov/go-webpush/actions/workflows/ci.yml)\n\nWeb Push API encryption and sending library for Go with VAPID support.\n\nThis library lets you send encrypted Web Push notifications from a Go server to browsers supporting the Push API. It implements message encryption (aes128gcm), VAPID authentication (JWT over ES256), and useful headers like TTL and Urgency.\n\n## Installation\n\n```\ngo get github.com/marknefedov/go-webpush\n```\n\n## Quick start\n\n1) Generate VAPID keys (one-time):\n\n```go\npackage main\n\nimport (\n    \"os\"\n    webpush \"github.com/marknefedov/go-webpush\"\n)\n\nfunc main() {\n    keys, err := webpush.GenerateVAPIDKeys()\n    if err != nil { panic(err) }\n    // Persist them somewhere safe; you can export as JSON or PEM\n    pem, _ := keys.ExportVAPIDPrivateKeyPEM()\n    _ = os.WriteFile(\"vapid_private.pem\", pem, 0o600)\n}\n```\n\n2) On the client, subscribe with the VAPID public key and send the subscription object to your server. See the example directory for a working page and service worker.\n\n3) Send a push message from your server:\n\n```go\npackage main\n\nimport (\n    \"context\"\n    \"encoding/json\"\n    \"log\"\n    \"os\"\n    \"time\"\n\n    webpush \"github.com/marknefedov/go-webpush\"\n)\n\nfunc main() {\n    // Parse subscription JSON you stored from the browser\n    var sub webpush.Subscription\n    _ = json.Unmarshal([]byte(`{...}`), \u0026sub)\n\n    // Load your VAPID keys (from PEM)\n    keys, err := webpush.LoadVAPIDPrivateKeyPEM(mustRead(\"vapid_private.pem\"))\n    if err != nil { log.Fatal(err) }\n\n    ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)\n    defer cancel()\n\n    resp, err := webpush.SendNotification(\n        ctx,\n        []byte(\"Hello from Go!\"), // payload (optional but recommended)\n        \u0026sub,\n        \u0026webpush.Options{\n            Subscriber: \"user@example.com\", // an email or URL\n            VAPIDKeys:  keys,\n            TTL:        60,                   // seconds push service should retain the message\n            // Urgency: webpush.UrgencyHigh,   // optional: VeryLow, Low, Normal, High\n            // Topic:   \"demo-1\",             // optional: collapse key\n        },\n    )\n    if err != nil { log.Fatal(err) }\n    defer resp.Body.Close()\n    log.Println(\"push status:\", resp.Status)\n}\n\nfunc mustRead(p string) []byte { b, _ := os.ReadFile(p); return b }\n```\n\n## Examples\n\nA complete end-to-end example (CLI sender, HTML page, and service worker) is provided in the example/ directory:\n\n- example/index.html – subscribe and copy the resulting subscription JSON\n- example/service-worker.js – displays the push\n- example/main.go – generate/load VAPID keys and send a notification\n\nTo run the example sender:\n\n```\ncd example\ngo run .\n```\n\nThen paste the subscription JSON from the page into the terminal when prompted.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarknefedov%2Fgo-webpush","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarknefedov%2Fgo-webpush","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarknefedov%2Fgo-webpush/lists"}