packages feed

jsaddle-dom-0.10.0.0: src/JSDOM/Generated/CryptoKeyPair.hs

{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ImplicitParams, ConstraintKinds, KindSignatures #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
-- | Generated by dom-gen from webcrypto-2 (webref). Do not edit.
module JSDOM.Generated.CryptoKeyPair
       (newCryptoKeyPair, setPublicKey, getPublicKey, getPublicKeyUnsafe, getPublicKeyUnchecked, setPrivateKey, getPrivateKey, getPrivateKeyUnsafe, getPrivateKeyUnchecked, CryptoKeyPair(..), gTypeCryptoKeyPair)
       where
import Prelude ((.), (==), (>>=), (<$>), (++), Bool(..), Maybe(..), IO, Int, Word, Double, Float)
import qualified Prelude as P
import Control.Monad (void)
import Control.Lens.Operators ((^.))
import Language.Javascript.JSaddle (JSM, JSVal, JSString, toJSVal, valToBool, valToNumber, js, jss, jsf, jsg, new, function, asyncFunction, jsUndefined, jsNull)
import JSDOM.Types
import qualified JSDOM.Types as Types
import JSDOM.EventTargetClosures (EventName, unsafeEventName, unsafeEventNameAsync)
import JSDOM.Generated.Enums

-- | <https://w3c.github.io/webcrypto/#dfn-CryptoKeyPair CryptoKeyPair specification>
newCryptoKeyPair :: (MonadDOM m) => m CryptoKeyPair
newCryptoKeyPair = liftDOM ((((new (jsg "Object") () >>= \o -> P.return o)) >>= fromJSValUnchecked))

-- | <https://w3c.github.io/webcrypto/#dfn-CryptoKeyPair-publicKey CryptoKeyPair.publicKey specification>
setPublicKey :: (MonadDOM m) => CryptoKeyPair -> CryptoKey -> m ()
setPublicKey self val = liftDOM (void (self ^. jss "publicKey" (toJSVal val)))

-- | <https://w3c.github.io/webcrypto/#dfn-CryptoKeyPair-publicKey CryptoKeyPair.publicKey specification>
getPublicKey :: (MonadDOM m) => CryptoKeyPair -> m (Maybe CryptoKey)
getPublicKey self = liftDOM (((self ^. js "publicKey") >>= fromJSValUnchecked))

-- | <https://w3c.github.io/webcrypto/#dfn-CryptoKeyPair-publicKey CryptoKeyPair.publicKey specification>
getPublicKeyUnsafe :: (MonadDOM m, HasCallStack) => CryptoKeyPair -> m CryptoKey
getPublicKeyUnsafe self = liftDOM ((((self ^. js "publicKey") >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))

-- | <https://w3c.github.io/webcrypto/#dfn-CryptoKeyPair-publicKey CryptoKeyPair.publicKey specification>
getPublicKeyUnchecked :: (MonadDOM m) => CryptoKeyPair -> m CryptoKey
getPublicKeyUnchecked self = liftDOM (((self ^. js "publicKey") >>= fromJSValUnchecked))

-- | <https://w3c.github.io/webcrypto/#dfn-CryptoKeyPair-privateKey CryptoKeyPair.privateKey specification>
setPrivateKey :: (MonadDOM m) => CryptoKeyPair -> CryptoKey -> m ()
setPrivateKey self val = liftDOM (void (self ^. jss "privateKey" (toJSVal val)))

-- | <https://w3c.github.io/webcrypto/#dfn-CryptoKeyPair-privateKey CryptoKeyPair.privateKey specification>
getPrivateKey :: (MonadDOM m) => CryptoKeyPair -> m (Maybe CryptoKey)
getPrivateKey self = liftDOM (((self ^. js "privateKey") >>= fromJSValUnchecked))

-- | <https://w3c.github.io/webcrypto/#dfn-CryptoKeyPair-privateKey CryptoKeyPair.privateKey specification>
getPrivateKeyUnsafe :: (MonadDOM m, HasCallStack) => CryptoKeyPair -> m CryptoKey
getPrivateKeyUnsafe self = liftDOM ((((self ^. js "privateKey") >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))

-- | <https://w3c.github.io/webcrypto/#dfn-CryptoKeyPair-privateKey CryptoKeyPair.privateKey specification>
getPrivateKeyUnchecked :: (MonadDOM m) => CryptoKeyPair -> m CryptoKey
getPrivateKeyUnchecked self = liftDOM (((self ^. js "privateKey") >>= fromJSValUnchecked))