Giter VIP home page Giter VIP logo

webpush's Introduction

Web Push (Nextcloud App)

General

⚠️ This is only a Proof of Concept, use at your own risk ⚠️

ℹ️ What WebPush is: Video (0:00 - 1:15 minutes)

🚧 At this stage you can use this App only to..

  • send WebPush with occ CLI tool ✅
  • or integrate it yourself into your other Nextcloud App Sourcecode
  • or extend this app yourself to serve as kind of (REST) API

🚫 It is not..

  • able to send out every usual Notification as WebPush, therefore the Nextcloud/Notifications App or Pushproxy would have to be altered (perhaps see here)

Requirements

Installation

Place this app in .../apps/ like so:

  • .../apps/$ git clone https://github.com/githubkoma/webpush.git
  • Adjust permissions to match the other folders+files in .../apps/*
  • Enable the App in Nextcloud
  • Set Your Admin E-Mail Adress in Nextcloud Personal Settings
  • Go To Nextcloud Admin Settings -> Web Push -> "Generate new Vapid Keys"
    • CAUTION: Best Case is you only use this button once after Installation. Because after using this button again, EVERY User has to re-subscribe!
  • Test from CLI: sudo -u www-data php occ webpush:generate admin "hello"
  • Proceed with Usage (below)

Usage

  1. Make sure REQUIREMENTS are met and INSTALLATION is finished (both see above ⬆️)
  2. As a User you visit your Nextcloud Settings
  3. On the Left side choose the Section "Web Push"
  4. Click on "Subscribe to Webpush" twice (and be patient)
  5. "My WebPush Subscription:" changes from "empty" to something like "...fy3R3F"
  6. You will get a test Notification, that states your success
    • (if not, contact your nextcloud admin)

Dev Info

image

Test WebPush with Python

Keypair:

openssl ecparam -genkey -name prime256v1 -out private_key.pem
openssl ec -in private_key.pem -pubout -outform DER|tail -c 65|base64|tr -d '=' |tr '/+' '_-' >> public_key.txt
openssl ec -in private_key.pem -outform DER|tail -c +8|head -c 32|base64|tr -d '=' |tr '/+' '_-' >> private_key.txt

data.json:

{
    "title": "This is the title",
    "body": "This is the body"
}

claims.json:

{
    "sub": "mailto:[email protected]",
    "aud": "https://fcm.googleapis.com/",
    "exp": 1683101017
}

header.json

{"Authorization": "vapid t=eyJ0eXAiOiJKVjoibWFpbHRvOmFkbWluQHdl1QiLCJhbGciOiJFUzI1NiJ9.eyJhdWQiOiJodHRwczovL3B1c2guc2VydmljZXMubW96aWxsYS5jb20iLCJleHAiOiIxNjgzMTAxMDEitgznbPCiPXMNEwO93Iiwic3ViIeWNsb3VkL0Tfd6bSlJlMYiz9Jv97hPIzjLU6GySAMmRlIn0.NzgCOvNKY_9CL5hbQj9LsLOEvGjmocxFMkSrabnDUVBJFYgfNX8j2w-HzRQzItEIfXas7_8CqC8cPpJncGXfQ4w,k=BPsGDOSf9gwgVQm0JJiozSnzCkcWQYwN7D1uo"}

subscription.json

 {"endpoint":"https://fcm.googleapis.com/fcm/send/enlz59YzXHB4q:APA91bFx-q7SaVPa8tEpLUvccKNfF4TrbaLbMwQlMx4FajGnwPWZMuje6TQsqAsqTevezMTCX0WeoUKZNqTCStgJCqsLb_Tgji9sKCuQ_fP0ayPFtP7mmeleWm8EP0RinQ2Wa4wPjl","expirationTime":null,"keys":{"p256dh":"BAOw-9bykz2_c00jsWEYifX5sonXho8NJy0EyuD96XQSVrVlrVYCziJVD3KRQV_oY70kk-fqSwGLB7ZFBJO-1lM","auth":"6XW0HmBwjUFseX2xIIryKQ"}}

private_key.pem

-----BEGIN PRIVATE KEY-----
MCCqGSM49AIGHyqGSM49AgEGwEHBG0wawIBAAgEAMBMGBQQglCHlId7ZBI75bKj2
eTsROmEHqM0p8wpwaFve4TyM4y1DtBUwBp8CrvAxN1gBgzkn/YMIAjrzSmP/Qi+YW0I/S7F
UJtCSYHNE3GhRANCAAT73em0pSZTGIs/SbwDOhskkGMDew9bq
-----END PRIVATE KEY-----

webpush's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.