-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Send messages using Web Push protocol. -- -- Please see README.md @package web-push @version 0.1.2.0 module Web.WebPush.Internal type VAPIDKeys = KeyPair data VAPIDClaims VAPIDClaims :: Audience -> StringOrURI -> NumericDate -> VAPIDClaims [vapidAud] :: VAPIDClaims -> Audience [vapidSub] :: VAPIDClaims -> StringOrURI [vapidExp] :: VAPIDClaims -> NumericDate webPushJWT :: MonadIO m => VAPIDKeys -> VAPIDClaims -> m (Either (Error) ByteString) data PushNotificationMessage PushNotificationMessage :: Text -> Text -> Text -> Text -> Text -> PushNotificationMessage [title] :: PushNotificationMessage -> Text [body] :: PushNotificationMessage -> Text [icon] :: PushNotificationMessage -> Text [url] :: PushNotificationMessage -> Text [tag] :: PushNotificationMessage -> Text 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 instance Data.Aeson.Types.ToJSON.ToJSON Web.WebPush.Internal.PushNotificationMessage module Web.WebPush -- | Generate the 3 integers minimally representing a unique pair of public -- and private keys. -- -- Store them in configuration 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 using -- applicationServerKey = new Uint8Array(vapidPublicKeyBytes) in -- Javascript. vapidPublicKeyBytes :: VAPIDKeys -> [Word8] -- | Send a Push Message. The message sent is Base64 URL encoded. Decode -- the message in Service Worker notification handler in browser before -- trying to read the JSON. sendPushNotification :: MonadIO m => VAPIDKeys -> Manager -> PushNotificationDetails -> m (Either PushNotificationError ()) type VAPIDKeys = KeyPair -- | 3 integers minimally representing a unique VAPID key pair. data VAPIDKeysMinDetails VAPIDKeysMinDetails :: Integer -> Integer -> Integer -> VAPIDKeysMinDetails [privateNumber] :: VAPIDKeysMinDetails -> Integer [publicCoordX] :: VAPIDKeysMinDetails -> Integer [publicCoordY] :: VAPIDKeysMinDetails -> Integer -- | Web push subscription and message details. -- -- Get subscription details from front end using subscription.endpoint, -- subscription.toJSON().keys.p256dh and subscription.toJSON().keys.auth. -- Save subscription details to send messages to the endpoint in future. data PushNotificationDetails PushNotificationDetails :: Text -> Text -> Text -> Text -> Int64 -> PushNotificationMessage -> PushNotificationDetails [endpoint] :: PushNotificationDetails -> Text [p256dh] :: PushNotificationDetails -> Text [auth] :: PushNotificationDetails -> Text [senderEmail] :: PushNotificationDetails -> Text [expireInHours] :: PushNotificationDetails -> Int64 [message] :: PushNotificationDetails -> PushNotificationMessage 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. data PushNotificationError EndpointParseFailed :: SomeException -> PushNotificationError JWTGenerationFailed :: Error -> PushNotificationError MessageEncryptionFailed :: CryptoError -> PushNotificationError RecepientEndpointNotFound :: PushNotificationError PushRequestFailed :: SomeException -> PushNotificationError