-- 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.5 module Web.WebPush.Internal -- | Server identification for a single host, used to identify the server -- to the remote push server data ServerIdentification ServerIdentification :: Text -> Int -> Text -> ServerIdentification [serverIdentificationAudience] :: ServerIdentification -> Text [serverIdentificationExpiration] :: ServerIdentification -> Int -- | Contact information for the server, either email URI in rfc6068 format -- 'mailto:text@example.com' or HTTPS URL in rfc2818 format -- 'https://example.com/contact' [serverIdentificationSubject] :: ServerIdentification -> Text webPushJWT :: MonadRandom m => PrivateKey -> ServerIdentification -> m ByteString -- | All inputs are in raw bytes with no encoding except for the plaintext -- for which raw bytes are the Base 64 encoded bytes 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 -- | Intermediate encryption output used in tests All in raw bytes 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 data EncryptError EncodeApplicationPublicKeyError :: String -> EncryptError EncryptCipherInitError :: CryptoError -> EncryptError EncryptAeadInitError :: CryptoError -> EncryptError EncryptInputPublicKeyError :: CryptoError -> EncryptError EncryptInputApplicationPublicKeyError :: String -> EncryptError -- | Payload encryption -- https://tools.ietf.org/html/draft-ietf-webpush-encryption-04 webPushEncrypt :: WebPushEncryptionInput -> Either EncryptError WebPushEncryptionOutput -- | Authorization header for a vapid push notification request this is -- shared between all push notifications sent to a single push service -- host hostHeaders :: (MonadIO m, MonadRandom m) => PrivateKey -> ServerIdentification -> m [Header] -- | The host for URI including scheme and port uriHost :: URI -> Maybe Text ecPublicKeyToBytes :: Point -> Either String ByteString ecPublicKeyToBytes' :: (Integer, Integer) -> ByteString ecBytesToPublicKey :: ByteString -> Either CryptoError Point type Bytes32 = (Word64, Word64, Word64, Word64) int32Bytes :: Integer -> Bytes32 bytes32Int :: Bytes32 -> Integer instance GHC.Show.Show Web.WebPush.Internal.ServerIdentification instance GHC.Show.Show Web.WebPush.Internal.WebPushEncryptionInput instance GHC.Show.Show Web.WebPush.Internal.EncryptError instance GHC.Classes.Eq Web.WebPush.Internal.EncryptError instance Data.Aeson.Types.ToJSON.ToJSON Web.WebPush.Internal.ServerIdentification module Web.WebPush.Keys -- | VAPIDKeys are the public and private keys used to sign the JWT -- authentication token sent for the push sendPushNotification -- -- The key is an ECDSA key pair with the p256 curve newtype VAPIDKeys VAPIDKeys :: KeyPair -> VAPIDKeys [unVAPIDKeys] :: VAPIDKeys -> KeyPair -- | Get the public key from the VAPID keys vapidPublicKey :: VAPIDKeys -> PublicKey -- | Errors from reading the VAPID keys from files data VAPIDKeysError -- | Error reading the public key VAPIDKeysPublicKeyError :: PublicKeyError -> VAPIDKeysError -- | Error reading the private key VAPIDKeysPrivateKeyError :: PrivateKeyError -> VAPIDKeysError -- | The public and private keys are not on the same curve VAPIDKeysCurveMismatch :: VAPIDKeysError -- | Read the public and private keys from files readVapidKeys :: FilePath -> FilePath -> IO (Either VAPIDKeysError VAPIDKeys) -- | Convert public and private keys to a key pair toKeyPair :: PublicKey -> PrivateKey -> KeyPair -- | Errors from reading the VAPID private key from files data PrivateKeyError -- | Error parsing the PEM file PrivateKeyPEMParseError :: PEMError -> PrivateKeyError -- | The curve name is not known PrivateKeyUnknownCurveName :: PrivateKeyError -- | The curve is not p256 PrivateKeyWrongCurve :: CurveName -> PrivateKeyError -- | The PEM file is not a single private key PrivateKeyInvalidPEM :: PrivateKeyError -- | Read the private key from a PEM file -- -- The private key is an ECDSA private number on the p256 curve readWebPushPrivateKey :: FilePath -> IO (Either PrivateKeyError PrivateKey) -- | Errors from reading the VAPID public key from files data PublicKeyError -- | PEM encoding error PublicKeyPEMParseError :: PEMError -> PublicKeyError -- | ASN1 decoding error PublicKeyASN1Error :: ASN1Error -> PublicKeyError -- | Error converting ASN1 to ECDSA public key PublicKeyFromASN1Error :: String -> PublicKeyError -- | The key type is not supported PublicKeyUnsupportedKeyType :: PublicKeyError -- | The curve is not known PublicKeyUnknownCurve :: PublicKeyError -- | Error unserialising the EC point PublicKeyUnserialiseError :: PublicKeyError -- | The PEM file is not a single public key PublicKeyInvalidPEM :: PublicKeyError -- | Read the public key from a PEM file -- -- The public key is an ECDSA public point on the p256 curve readWebPushPublicKey :: FilePath -> IO (Either PublicKeyError PublicKey) -- | Write the public and private keys to files NOTE: This will overwrite -- any existing files and it does not store keys in the exact same format -- as they were read in from if they were created with OpenSSL writeVAPIDKeys :: FilePath -> FilePath -> VAPIDKeys -> IO () -- | Generate a new VAPID key pair, this is an ECDSA key pair on the p256 -- curve -- -- Store them securely and use them across multiple push notification -- requests. generateVAPIDKeys :: MonadRandom m => m (Either String VAPIDKeys) -- | Pass the VAPID public key bytes as applicationServerKey when -- calling subscribe on the PushManager object on a registered -- service worker -- --
--   applicationServerKey = new Uint8Array( #{toJSON vapidPublicKeyBytes} )
--   
vapidPublicKeyBytes :: PublicKey -> Either String [Word8] instance GHC.Show.Show Web.WebPush.Keys.VAPIDKeys instance GHC.Show.Show Web.WebPush.Keys.PrivateKeyError instance GHC.Show.Show Web.WebPush.Keys.PublicKeyError instance GHC.Show.Show Web.WebPush.Keys.VAPIDKeysError module Web.WebPush -- | 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, MonadRandom m) => Manager -> VapidConfig -> PushNotification msg -> Subscription -> m (Either PushNotificationError PushNotificationCreated) -- | Send a push notification to multiple subscribers similar to -- sendPushNotification but shares VAPID keys across multiple -- requests sendPushNotifications :: (MonadIO m, ToJSON msg, MonadRandom m) => Manager -> VapidConfig -> PushNotification msg -> [Subscription] -> m [(Subscription, Either PushNotificationError PushNotificationCreated)] -- | Subscription information for a push notification data Subscription Subscription :: URI -> PushP256dh -> PushAuth -> Subscription -- | Endpoint URI to remote push service [subscriptionEndpoint] :: Subscription -> URI -- | Public key of the client [subscriptionP256dh] :: Subscription -> PushP256dh -- | Authentication secret of the client [subscriptionAuth] :: Subscription -> PushAuth -- | Configuration for VAPID server identification data VapidConfig VapidConfig :: Text -> VAPIDKeys -> VapidConfig -- | Contact information for the application server, either a `mailto:` URI -- or an HTTPS URL [vapidConfigContact] :: VapidConfig -> Text -- | Keypair used to sign the VAPID identification [vapidConfigKeys] :: VapidConfig -> VAPIDKeys -- | Web push notification expiration and message to send data PushNotification msg PushNotification :: Int -> msg -> PushNotification msg -- | Expiration time in seconds [pnExpireInSeconds] :: PushNotification msg -> Int -- | Message to send [pnMessage] :: PushNotification msg -> msg -- | Result of a successful push notification request data PushNotificationCreated PushNotificationCreated :: Maybe Int -> PushNotificationCreated -- | Optional TTL of the notification [pushNotificationCreatedTTL] :: PushNotificationCreated -> Maybe Int -- | 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 -- | Endpoint URL could not be parsed EndpointParseFailed :: HttpException -> PushNotificationError PushNotificationBadHost :: URI -> PushNotificationError PushEncryptError :: EncryptError -> PushNotificationError -- | Application server key encoding failed ApplicationKeyEncodeError :: String -> PushNotificationError -- | The endpoint is no longer recognized by the push service RecepientEndpointNotFound :: PushNotificationError -- | Push request failed PushRequestFailed :: SomeException -> PushNotificationError -- | Push request failed with non-201 status code PushRequestNotCreated :: Response ByteString -> PushNotificationError type PushP256dh = Text type PushAuth = Text instance GHC.Show.Show Web.WebPush.PushNotificationCreated instance GHC.Classes.Ord Web.WebPush.PushNotificationCreated instance GHC.Classes.Eq Web.WebPush.PushNotificationCreated instance GHC.Show.Show Web.WebPush.Subscription instance GHC.Classes.Ord Web.WebPush.Subscription instance GHC.Classes.Eq Web.WebPush.Subscription instance GHC.Show.Show msg => GHC.Show.Show (Web.WebPush.PushNotification msg) instance GHC.Classes.Ord msg => GHC.Classes.Ord (Web.WebPush.PushNotification msg) instance GHC.Classes.Eq msg => GHC.Classes.Eq (Web.WebPush.PushNotification msg) instance GHC.Exception.Type.Exception Web.WebPush.PushNotificationError instance GHC.Show.Show Web.WebPush.PushNotificationError