0 | module Node.HTTP2.CreateSecureServer
  1 |
  2 | import Node
  3 | import Node.HTTP2.CreateServer
  4 | import Node.HTTP2.Module
  5 | import Node.Internal.Support
  6 | import public Node.Net.CreateServer
  7 | import public Node.TLS.CreateServer
  8 | import public Node.TLS.CreateSecureContext
  9 |
 10 | public export
 11 | record Options where
 12 |   constructor MkOptions
 13 |   allowHTTP1: Bool
 14 |   maxDeflateDynamicTableSize: Int
 15 |   maxSettings: Int
 16 |   maxSessionMemory: Int
 17 |   maxHeaderListPairs: Int
 18 |   maxOutstandingPings: Int
 19 |   maxSendHeaderBlockLength: Maybe Int
 20 |   paddingStrategy: PaddingStrategy
 21 |   peerMaxConcurrentStreams: Int
 22 |   maxSessionInvalidFrames: Int
 23 |   maxSessionRejectedStreams: Int
 24 |   settings: Settings
 25 |   origins: List String
 26 |   unknownProtocolTimeout: Int
 27 |
 28 | export
 29 | defaultOptions : CreateSecureServer.Options
 30 | defaultOptions = MkOptions
 31 |   { allowHTTP1 = False
 32 |   , maxDeflateDynamicTableSize = 4096
 33 |   , maxSettings = 32
 34 |   , maxSessionMemory = 10
 35 |   , maxHeaderListPairs = 128
 36 |   , maxOutstandingPings = 10
 37 |   , maxSendHeaderBlockLength = Nothing
 38 |   , paddingStrategy = None
 39 |   , peerMaxConcurrentStreams = 100
 40 |   , maxSessionInvalidFrames = 1000
 41 |   , maxSessionRejectedStreams = 100
 42 |   , settings = defaultSettings
 43 |   , origins = []
 44 |   , unknownProtocolTimeout = 10000
 45 |   }
 46 |
 47 | %foreign """
 48 |   node:lambda:
 49 |   ( allowHTTP1
 50 |   , maxDeflateDynamicTableSize
 51 |   , maxSettings
 52 |   , maxSessionMemory
 53 |   , maxHeaderListPairs
 54 |   , maxOutstandingPings
 55 |   , maxSendHeaderBlockLength
 56 |   , paddingStrategy
 57 |   , peerMaxConcurrentStreams
 58 |   , maxSessionInvalidFrames
 59 |   , maxSessionRejectedStreams
 60 |   , settings
 61 |   , origins
 62 |   , unknownProtocolTimeout
 63 |   ) => _keepDefined({
 64 |     allowHTTP1: _bool(allowHTTP1),
 65 |     maxDeflateDynamicTableSize,
 66 |     maxSettings,
 67 |     maxSessionMemory,
 68 |     maxHeaderListPairs,
 69 |     maxOutstandingPings,
 70 |     maxSendHeaderBlockLength: _maybe(maxSendHeaderBlockLength),
 71 |     paddingStrategy,
 72 |     peerMaxConcurrentStreams,
 73 |     maxSessionInvalidFrames,
 74 |     maxSessionRejectedStreams,
 75 |     settings,
 76 |     origins: __prim_idris2js_array(origins),
 77 |     unknownProtocolTimeout
 78 |   })
 79 |   """
 80 | ffi_convertOptions :
 81 |   (allowHTTP1: Bool) ->
 82 |   (maxDeflateDynamicTableSize: Int) ->
 83 |   (maxSettings: Int) ->
 84 |   (maxSessionMemory: Int) ->
 85 |   (maxHeaderListPairs: Int) ->
 86 |   (maxOutstandingPings: Int) ->
 87 |   (maxSendHeaderBlockLength: Maybe Int) ->
 88 |   (paddingStrategy: Node PaddingStrategy) ->
 89 |   (peerMaxConcurrentStreams: Int) ->
 90 |   (maxSessionInvalidFrames: Int) ->
 91 |   (maxSessionRejectedStreams: Int) ->
 92 |   (settings: Node Settings) ->
 93 |   (origins: List String) ->
 94 |   (unknownProtocolTimeout: Int) ->
 95 |   Node CreateSecureServer.Options
 96 |
 97 | export
 98 | convertOptions : {auto http : HTTP2Module} -> CreateSecureServer.Options -> Node CreateSecureServer.Options
 99 | convertOptions o = ffi_convertOptions
100 |   o.allowHTTP1
101 |   o.maxDeflateDynamicTableSize
102 |   o.maxSettings
103 |   o.maxSessionMemory
104 |   o.maxHeaderListPairs
105 |   o.maxOutstandingPings
106 |   o.maxSendHeaderBlockLength
107 |   (convertPaddingStrategy o.paddingStrategy)
108 |   o.peerMaxConcurrentStreams
109 |   o.maxSessionInvalidFrames
110 |   o.maxSessionRejectedStreams
111 |   (convertSettings o.settings)
112 |   o.origins
113 |   o.unknownProtocolTimeout
114 |
115 | namespace Command
116 |
117 |   public export
118 |   record Options where
119 |     constructor MkOptions
120 |     server: HTTP2.CreateSecureServer.Options
121 |     context: TLS.CreateSecureContext.Options
122 |     tls: TLS.CreateServer.Options
123 |     net: Net.CreateServer.Options
124 |
125 |   export
126 |   defaultOptions : HTTP2.CreateSecureServer.Command.Options
127 |   defaultOptions = MkOptions
128 |     { server = defaultOptions
129 |     , context = defaultOptions
130 |     , tls = defaultOptions
131 |     , net = defaultOptions
132 |     }
133 |
134 |   %foreign """
135 |     node:lambda:
136 |     ( server
137 |     , context
138 |     , tls
139 |     , net
140 |     ) => ({
141 |       ...net,
142 |       ...tls,
143 |       ...context,
144 |       ...server
145 |     })
146 |     """
147 |   ffi_convertOptions :
148 |     (server : Node HTTP2.CreateSecureServer.Options)
149 |     -> (context : Node TLS.CreateSecureContext.Options)
150 |     -> (tls : Node TLS.CreateServer.Options)
151 |     -> (net : Node Net.CreateServer.Options)
152 |     -> Node CreateSecureServer.Command.Options
153 |
154 |   export
155 |   convertOptions : {auto http : HTTP2Module} -> HTTP2.CreateSecureServer.Command.Options -> Node HTTP2.CreateSecureServer.Command.Options
156 |   convertOptions o = ffi_convertOptions
157 |     (convertOptions o.server)
158 |     (convertOptions o.context)
159 |     (convertOptions o.tls)
160 |     (convertOptions o.net)
161 |
162 |