-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Send messages using Web Push protocol. -- -- Web Push is a simple protocol for delivery of real-time events to user -- agents using HTTP/2 server push. This can be used to send -- notifications to browsers using the Push API. @package web-push @version 0.3 module Web.WebPush.Internal type VAPIDKeys = KeyPair webPushJWT :: MonadIO m => VAPIDKeys -> Request -> Text -> m ByteString data WebPushEncryptionInput EncryptionInput :: PrivateNumber -> ByteString -> ByteString -> ByteString -> ByteString -> Int64 -> WebPushEncryptionInput [applicationServerPrivateKey] :: WebPushEncryptionInput -> PrivateNumber [userAgentPublicKeyBytes] :: WebPushEncryptionInput -> ByteString [authenticationSecret] :: WebPushEncryptionInput -> ByteString [salt] :: WebPushEncryptionInput -> ByteString [plainText] :: WebPushEncryptionInput -> ByteString [paddingLength] :: WebPushEncryptionInput -> Int64 data WebPushEncryptionOutput EncryptionOutput :: ByteString -> ByteString -> ByteString -> ByteString -> ByteString -> ByteString -> ByteString -> ByteString -> WebPushEncryptionOutput [sharedECDHSecretBytes] :: WebPushEncryptionOutput -> ByteString [inputKeyingMaterialBytes] :: WebPushEncryptionOutput -> ByteString [contentEncryptionKeyContext] :: WebPushEncryptionOutput -> ByteString [contentEncryptionKey] :: WebPushEncryptionOutput -> ByteString [nonceContext] :: WebPushEncryptionOutput -> ByteString [nonce] :: WebPushEncryptionOutput -> ByteString [paddedPlainText] :: WebPushEncryptionOutput -> ByteString [encryptedMessage] :: WebPushEncryptionOutput -> ByteString webPushEncrypt :: WebPushEncryptionInput -> Either CryptoError WebPushEncryptionOutput ecPublicKeyToBytes :: Point -> ByteString ecBytesToPublicKey :: ByteString -> Point type Bytes32 = (Word64, Word64, Word64, Word64) int32Bytes :: Integer -> Bytes32 bytes32Int :: Bytes32 -> Integer b64UrlNoPadding :: ByteString -> ByteString module Web.WebPush -- | Generate the 3 integers minimally representing a unique pair of public -- and private keys. -- -- Store them securely and use them across multiple push notification -- requests. generateVAPIDKeys :: MonadRandom m => m VAPIDKeysMinDetails -- | Read VAPID key pair from the 3 integers minimally representing a -- unique key pair. readVAPIDKeys :: VAPIDKeysMinDetails -> VAPIDKeys -- | Pass the VAPID public key bytes to browser when subscribing to push -- notifications. Generate application server key browser using: -- --
--   applicationServerKey = new Uint8Array( #{toJSON vapidPublicKeyBytes} )
--   
vapidPublicKeyBytes :: VAPIDKeys -> [Word8] -- | Send a Push Message. Read the message in Service Worker notification -- handler in browser: -- --
--   self.addEventListener('push', function(event){ console.log(event.data.json()); });
--   
sendPushNotification :: (MonadIO m, ToJSON msg) => VAPIDKeys -> Manager -> PushNotification msg -> m (Either PushNotificationError ()) pushEndpoint :: Lens' (PushNotification msg) PushEndpoint pushP256dh :: Lens' (PushNotification msg) PushP256dh pushAuth :: Lens' (PushNotification msg) PushAuth pushSenderEmail :: Lens' (PushNotification msg) Text pushExpireInSeconds :: Lens' (PushNotification msg) Int64 pushMessage :: ToJSON msg => Lens (PushNotification a) (PushNotification msg) a msg -- | Constuct a push notification. -- -- PushEndpoint, PushP256dh and PushAuth should be -- obtained from push subscription in client's browser. Push message can -- be set through pushMessage; text and json messages are usually -- supported by browsers. pushSenderEmail and -- pushExpireInSeconds can be used to set additional details. mkPushNotification :: PushEndpoint -> PushP256dh -> PushAuth -> PushNotification () type VAPIDKeys = KeyPair -- | 3 integers minimally representing a unique VAPID public-private key -- pair. data VAPIDKeysMinDetails VAPIDKeysMinDetails :: Integer -> Integer -> Integer -> VAPIDKeysMinDetails [privateNumber] :: VAPIDKeysMinDetails -> Integer [publicCoordX] :: VAPIDKeysMinDetails -> Integer [publicCoordY] :: VAPIDKeysMinDetails -> Integer -- | Web push subscription and message details. Use -- mkPushNotification to construct push notification. data PushNotification msg -- | Example payload structure for web-push. Any datatype with JSON -- instance can also be used instead. See mkPushNotification. data PushNotificationMessage PushNotificationMessage :: Text -> Text -> Text -> Text -> Text -> PushNotificationMessage [title] :: PushNotificationMessage -> Text [body] :: PushNotificationMessage -> Text [icon] :: PushNotificationMessage -> Text [url] :: PushNotificationMessage -> Text [tag] :: PushNotificationMessage -> Text -- | RecepientEndpointNotFound comes up when the endpoint is no -- longer recognized by the push service. This may happen if the user has -- cancelled the push subscription, and hence deleted the endpoint. You -- may want to delete the endpoint from database in this case, or if -- EndpointParseFailed. data PushNotificationError EndpointParseFailed :: SomeException -> PushNotificationError MessageEncryptionFailed :: CryptoError -> PushNotificationError RecepientEndpointNotFound :: PushNotificationError PushRequestFailed :: SomeException -> PushNotificationError type PushEndpoint = Text type PushP256dh = Text type PushAuth = Text instance GHC.Exception.Type.Exception Web.WebPush.PushNotificationError instance GHC.Show.Show Web.WebPush.PushNotificationError instance GHC.Show.Show Web.WebPush.VAPIDKeysMinDetails instance Data.Aeson.Types.ToJSON.ToJSON Web.WebPush.PushNotificationMessage instance GHC.Generics.Generic Web.WebPush.PushNotificationMessage instance GHC.Show.Show Web.WebPush.PushNotificationMessage instance GHC.Classes.Eq Web.WebPush.PushNotificationMessage