Skip to content
This repository has been archived by the owner on Apr 23, 2021. It is now read-only.

Some basic docs to get started with #2

Merged
merged 2 commits into from
Mar 31, 2016
Merged

Some basic docs to get started with #2

merged 2 commits into from
Mar 31, 2016

Conversation

wibblymat
Copy link
Contributor

@gauntface
Copy link
Contributor

Would it be worth changing this to just be steps to use rather than an explainer of the API?

I'd expect API docs to explain the API itself and the README be the rough steps to get this working.

  1. install the library

    npm install ....
    
  2. Send a payload to a subscription.

    // Subscription should be stored on your backend {endpoint: '.....', keys: {auth: '....', p256dh: '...'}}
    sendWebPush(data, subscription);
    

Question regarding API - was there a reason for not handling the authentication header inside the library rather than the developer having to manage it?

@wibblymat
Copy link
Contributor Author

addAuthToken may be a bad name, then... it is the method you use to tell the library what your API key is for that service. You call it once in your application, not per message sent. So for GCM I'd do:

webpush.addAuthToken('.googleapis.com/gcm', '<string I copied from console.developers.google.com>');

subscriptions.forEach(sub => webpush.sendWebPush('whatever', subscription));

Does that make sense? The actual Authentication: key=BLAH header is added to the POST request by the library.


Require the module:

`const webpush = require('web-push-encryption');`
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: I thought the plan for ES2015 usage was to use it in the libraries, but keep samples and docs in plain JS?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

never heard this being discussed but it's a good point - it probably should be.

@petele
Copy link

petele commented Feb 25, 2016

Added a few comments, if you gave this to me today and said go, it would take me too long to figure out how to use it. I want a quick start explanation to get me going immediately, then go from there.

@gauntface
Copy link
Contributor

Ta for the explanation, still not entirely convinced by this API though.

1.) If it's only used by GCM, then should it just be of addGCMAuthToken('');
2.) If it is for other push providers or will be in the future - it presumably would just be a server key or something to that affect and would be shared across all push providers meaning you could have

webpush.addGCMAuthToken('');
webpush.addAuthToken('');

Essentially - I just really dislike the pattern requirement - feels to error prone and boilerplate.

SIDE NOTE: This should probably be moved to an issue and doesn't block these this docs PR.

@gauntface
Copy link
Contributor

+1 Peters comments.

I think keep this on the bare minimum titled getting started to just install and use the library for Chrome and Firefox.

We can either than add further comments in API docs OR seperate sections. For now I'd go minimal and start asking people for feedback and iterate on it.

@gauntface
Copy link
Contributor

Moved auth token comments to: #6 would appreciate any feedback.

@wibblymat
Copy link
Contributor Author

@gauntface @petele I simplified the docs, removing the API reference.

I also simplified the auth token business - auth token is now a parameter of sendWebPush and we push the process onto the developer. This came up in the code review for the Go version, too, and in the end it seemed like it was actually easier for developers to grok what was going on if they were left in control.


Install the module using npm:

`npm install web-push-encryption`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the name we are actually published on? Does it make sense to make it slightly more generic if we can support encrypted push and just tickles?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted web-push but Mozilla got there first :)

Will open an issue.

@gauntface
Copy link
Contributor

LGTM

Commented on the naming of the module, but that can be moved to an issue.

@wibblymat wibblymat merged commit bd407f5 into master Mar 31, 2016
@wibblymat wibblymat deleted the initial-docs branch March 31, 2016 12:05
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants