Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This change updates a long-standing piece of Push Subscription directions in the README which demonstrates setting of the applicationServerKey into a Uint8Array from the decoded raw bytes of the vapid public key. This step is cumbersome and there is a simpler alternative. The Push API docs for the PushSubscriptionOptions interface say of the applicationServerKey: > When provided as a DOMString, the value MUST be encoded using the base64url encoding [RFC7515]. https://www.w3.org/TR/push-api/#dom-pushsubscriptionoptions-applicationserverkey RFC 7515 states that the Base64 url-safe encoding omit the padding characters: > Base64 encoding using the URL- and filename-safe character set defined in Section 5 of RFC 4648 [RFC4648], with all trailing '=' characters omitted https://www.rfc-editor.org/rfc/rfc7515 It turns out the generated vapid public is already Base64 url-safe encoded! However, for historical reasons, Ruby's Base64.urlsafe_encode64 method includes the padding character, "=", incorrectly by default. This behavior exists in the library's current vapid key generation. Therefore, the directions include explicit deletion of the "=" character. For historical discussion of Ruby's encoding issue, see: https://bugs.ruby-lang.org/issues/10740
- Loading branch information