git.iko.soy/rowtype-yoga/purescript-yoga-subtlecrypto
on master help sign in
basic CryptoKey binding
commit31fff1477ad47d29b43d77dbc5d26f63968fde96 authorAthan Clark <athan.clark@localcooking.com> dateTue 15 Jan 2019, 18:03 (8 years ago) parent0bf2e87
3 files changed+60−2
bower.json+2−1 src/Crypto/Subtle/Hash.purs+1−1 src/Crypto/Subtle/Key.purs+57
bower.json+2−1
@@ -15,7 +15,8 @@
1515 "purescript-prelude": "^4.1.0",
1616 "purescript-arraybuffer-types": "^2.0.0",
1717 "purescript-aff": "^5.1.0",
18− "purescript-promises": "^3.0.0"
18+ "purescript-promises": "^3.0.0",
19+ "purescript-foreign": "^5.0.0"
1920 },
2021 "devDependencies": {
2122 "purescript-psci-support": "^4.0.0"
src/Crypto/Subtle/Hash.purs+1−1
@@ -1,4 +1,4 @@
1−module Crypto.Subtle.Hash where
1+module Crypto.Subtle.Hash (HashingFunction, sha1, sha256, sha384, sha512, digest) where
22
33import Prelude ((<<<), (<$))
44import Data.ArrayBuffer.Types (ArrayBuffer)
src/Crypto/Subtle/Key.pursnew file+57
@@ -0,0 +1,57 @@
1+module Crypto.Subtle.Key
2+ ( CryptoKeyType
3+ , CryptoKeyUsage
4+ , encrypt, decrypt, sign, verify, deriveKey, deriveBits, unwrapKey, wrapKey
5+ , CryptoKey (..)
6+ , getType, getExtractable, getAlgorithm, getUsages
7+ ) where
8+
9+
10+import Foreign (Foreign)
11+
12+
13+
14+newtype CryptoKeyType = CryptoKeyType String
15+
16+newtype CryptoKeyUsage = CryptoKeyUsage String
17+
18+
19+encrypt :: CryptoKeyUsage
20+encrypt = CryptoKeyUsage "encrypt"
21+decrypt :: CryptoKeyUsage
22+decrypt = CryptoKeyUsage "decrypt"
23+sign :: CryptoKeyUsage
24+sign = CryptoKeyUsage "sign"
25+verify :: CryptoKeyUsage
26+verify = CryptoKeyUsage "verify"
27+deriveKey :: CryptoKeyUsage
28+deriveKey = CryptoKeyUsage "deriveKey"
29+deriveBits :: CryptoKeyUsage
30+deriveBits = CryptoKeyUsage "deriveBits"
31+wrapKey :: CryptoKeyUsage
32+wrapKey = CryptoKeyUsage "wrapKey"
33+unwrapKey :: CryptoKeyUsage
34+unwrapKey = CryptoKeyUsage "unwrapKey"
35+
36+
37+
38+
39+newtype CryptoKey = CryptoKey
40+ { "type" :: CryptoKeyType
41+ , extractable :: Boolean
42+ , algorithm :: Foreign
43+ , usages :: Array CryptoKeyUsage
44+ }
45+
46+
47+getType :: CryptoKey -> CryptoKeyType
48+getType (CryptoKey r) = r."type"
49+
50+getExtractable :: CryptoKey -> Boolean
51+getExtractable (CryptoKey r) = r.extractable
52+
53+getAlgorithm :: CryptoKey -> Foreign
54+getAlgorithm (CryptoKey r) = r.algorithm
55+
56+getUsages :: CryptoKey -> Array CryptoKeyUsage
57+getUsages (CryptoKey r) = r.usages