0 | module Node.TLS.CreateServer
 1 |
 2 | import Node
 3 | import Data.Buffer.Ext
 4 | import Node.Internal.Support
 5 |
 6 | public export
 7 | record Options where
 8 |   constructor MkOptions
 9 |   -- ALPNProtocols: TODO
10 |   clientCertEngine: Maybe String
11 |   enableTrace: Bool
12 |   handshakeTimeout: Int
13 |   rejectUnauthorized: Bool
14 |   requestCert: Bool
15 |   sessionTimeout: Int
16 |   -- SNICallback(servername, callback): TODO
17 |   ticketKeys: Maybe Buffer
18 |   -- pskCallback: TODO
19 |   pskIdentityHint: Maybe String
20 |
21 | export
22 | defaultOptions : Options
23 | defaultOptions = MkOptions
24 |   { clientCertEngine = Nothing
25 |   , enableTrace = False
26 |   , handshakeTimeout = 120000
27 |   , rejectUnauthorized = True
28 |   , requestCert = False
29 |   , sessionTimeout = 300
30 |   , ticketKeys = Nothing
31 |   , pskIdentityHint = Nothing
32 |   }
33 |
34 | %foreign """
35 |   node:lambda:
36 |   ( clientCertEngine
37 |   , enableTrace
38 |   , handshakeTimeout
39 |   , rejectUnauthorized
40 |   , requestCert
41 |   , sessionTimeout
42 |   , ticketKeys
43 |   , pskIdentityHint
44 |   ) => _keepDefined({
45 |     clientCertEngine: _maybe(clientCertEngine),
46 |     enableTrace: _bool(enableTrace),
47 |     handshakeTimeout,
48 |     rejectUnauthorized: _bool(rejectUnauthorized),
49 |     requestCert: _bool(requestCert),
50 |     sessionTimeout,
51 |     ticketKeys: _maybe(ticketKeys),
52 |     pskIdentityHint: _maybe(pskIdentityHint)
53 |   })
54 |   """
55 | ffi_convertOptions : 
56 |   (clientCertEngine: Maybe String) ->
57 |   (enableTrace: Bool) ->
58 |   (handshakeTimeout: Int) ->
59 |   (rejectUnauthorized: Bool) ->
60 |   (requestCert: Bool) ->
61 |   (sessionTimeout: Int) ->
62 |   (ticketKeys: Maybe Buffer) ->
63 |   (pskIdentityHint: Maybe String) ->
64 |   Node Options
65 |
66 | export
67 | convertOptions : Options -> Node Options
68 | convertOptions o = ffi_convertOptions
69 |   o.clientCertEngine
70 |   o.enableTrace
71 |   o.handshakeTimeout
72 |   o.rejectUnauthorized
73 |   o.requestCert
74 |   o.sessionTimeout
75 |   o.ticketKeys
76 |   o.pskIdentityHint
77 |