@based/server 3.3.7 → 3.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (308) hide show
  1. package/.turbo/turbo-build.log +5 -5
  2. package/dist/BasedServerClient.d.ts +0 -0
  3. package/dist/BasedServerClient.js +0 -0
  4. package/dist/BasedServerClient.js.map +0 -0
  5. package/dist/Client.d.ts +0 -0
  6. package/dist/Client.js +0 -0
  7. package/dist/Client.js.map +0 -0
  8. package/dist/Params.d.ts +0 -0
  9. package/dist/Params.js +0 -0
  10. package/dist/Params.js.map +0 -0
  11. package/dist/auth/authorize.d.ts +2 -0
  12. package/dist/auth/authorize.js +8 -0
  13. package/dist/auth/authorize.js.map +1 -0
  14. package/dist/auth/authorizeAdvanced.d.ts +2 -0
  15. package/dist/auth/authorizeAdvanced.js +10 -0
  16. package/dist/auth/authorizeAdvanced.js.map +1 -0
  17. package/dist/auth/defaults/authorize.d.ts +2 -0
  18. package/dist/auth/defaults/authorize.js +8 -0
  19. package/dist/auth/defaults/authorize.js.map +1 -0
  20. package/dist/auth/defaults/authorizeAdvanced.d.ts +2 -0
  21. package/dist/auth/defaults/authorizeAdvanced.js +8 -0
  22. package/dist/auth/defaults/authorizeAdvanced.js.map +1 -0
  23. package/dist/auth/defaults/index.d.ts +2 -0
  24. package/dist/auth/defaults/index.js +19 -0
  25. package/dist/auth/defaults/index.js.map +1 -0
  26. package/dist/auth/index.d.ts +10 -0
  27. package/dist/auth/index.js +23 -0
  28. package/dist/auth/index.js.map +1 -0
  29. package/dist/closeListener.d.ts +0 -0
  30. package/dist/closeListener.js +0 -0
  31. package/dist/closeListener.js.map +0 -0
  32. package/dist/error.d.ts +34 -0
  33. package/dist/error.js +107 -0
  34. package/dist/error.js.map +1 -0
  35. package/dist/findPrefix.d.ts +0 -0
  36. package/dist/findPrefix.js +0 -0
  37. package/dist/findPrefix.js.map +0 -0
  38. package/dist/functions/index.d.ts +31 -0
  39. package/dist/functions/index.js +200 -0
  40. package/dist/functions/index.js.map +1 -0
  41. package/dist/functions/timeout.d.ts +3 -0
  42. package/dist/functions/timeout.js +23 -0
  43. package/dist/functions/timeout.js.map +1 -0
  44. package/dist/getFromConfig.d.ts +0 -0
  45. package/dist/getFromConfig.js +0 -0
  46. package/dist/getFromConfig.js.map +0 -0
  47. package/dist/handlers/authorize.d.ts +0 -0
  48. package/dist/handlers/authorize.js +0 -0
  49. package/dist/handlers/authorize.js.map +0 -0
  50. package/dist/handlers/bulkUpdate/index.d.ts +0 -0
  51. package/dist/handlers/bulkUpdate/index.js +0 -0
  52. package/dist/handlers/bulkUpdate/index.js.map +0 -0
  53. package/dist/handlers/configuration/index.d.ts +0 -0
  54. package/dist/handlers/configuration/index.js +0 -0
  55. package/dist/handlers/configuration/index.js.map +0 -0
  56. package/dist/handlers/configuration/observable/index.d.ts +0 -0
  57. package/dist/handlers/configuration/observable/index.js +0 -0
  58. package/dist/handlers/configuration/observable/index.js.map +0 -0
  59. package/dist/handlers/configure/index.d.ts +0 -0
  60. package/dist/handlers/configure/index.js +0 -0
  61. package/dist/handlers/configure/index.js.map +0 -0
  62. package/dist/handlers/copy/index.d.ts +0 -0
  63. package/dist/handlers/copy/index.js +0 -0
  64. package/dist/handlers/copy/index.js.map +0 -0
  65. package/dist/handlers/delete/index.d.ts +0 -0
  66. package/dist/handlers/delete/index.js +0 -0
  67. package/dist/handlers/delete/index.js.map +0 -0
  68. package/dist/handlers/digest/index.d.ts +0 -0
  69. package/dist/handlers/digest/index.js +0 -0
  70. package/dist/handlers/digest/index.js.map +0 -0
  71. package/dist/handlers/functions/call.d.ts +0 -0
  72. package/dist/handlers/functions/call.js +0 -0
  73. package/dist/handlers/functions/call.js.map +0 -0
  74. package/dist/handlers/functions/observable/Observable.d.ts +0 -0
  75. package/dist/handlers/functions/observable/Observable.js +0 -0
  76. package/dist/handlers/functions/observable/Observable.js.map +0 -0
  77. package/dist/handlers/functions/observable/SharedObservable.d.ts +0 -0
  78. package/dist/handlers/functions/observable/SharedObservable.js +0 -0
  79. package/dist/handlers/functions/observable/SharedObservable.js.map +0 -0
  80. package/dist/handlers/functions/observable/index.d.ts +0 -0
  81. package/dist/handlers/functions/observable/index.js +0 -0
  82. package/dist/handlers/functions/observable/index.js.map +0 -0
  83. package/dist/handlers/get/index.d.ts +0 -0
  84. package/dist/handlers/get/index.js +0 -0
  85. package/dist/handlers/get/index.js.map +0 -0
  86. package/dist/handlers/getConfig/index.d.ts +0 -0
  87. package/dist/handlers/getConfig/index.js +0 -0
  88. package/dist/handlers/getConfig/index.js.map +0 -0
  89. package/dist/handlers/handleRequests.d.ts +0 -0
  90. package/dist/handlers/handleRequests.js +0 -0
  91. package/dist/handlers/handleRequests.js.map +0 -0
  92. package/dist/handlers/index.d.ts +0 -0
  93. package/dist/handlers/index.js +0 -0
  94. package/dist/handlers/index.js.map +0 -0
  95. package/dist/handlers/messageParser.d.ts +0 -0
  96. package/dist/handlers/messageParser.js +0 -0
  97. package/dist/handlers/messageParser.js.map +0 -0
  98. package/dist/handlers/removeField/index.d.ts +0 -0
  99. package/dist/handlers/removeField/index.js +0 -0
  100. package/dist/handlers/removeField/index.js.map +0 -0
  101. package/dist/handlers/removeType/index.d.ts +0 -0
  102. package/dist/handlers/removeType/index.js +0 -0
  103. package/dist/handlers/removeType/index.js.map +0 -0
  104. package/dist/handlers/rest/file/DataStream.d.ts +0 -0
  105. package/dist/handlers/rest/file/DataStream.js +0 -0
  106. package/dist/handlers/rest/file/DataStream.js.map +0 -0
  107. package/dist/handlers/rest/file/formStream.d.ts +0 -0
  108. package/dist/handlers/rest/file/formStream.js +0 -0
  109. package/dist/handlers/rest/file/formStream.js.map +0 -0
  110. package/dist/handlers/rest/file/getExtenstion.d.ts +0 -0
  111. package/dist/handlers/rest/file/getExtenstion.js +0 -0
  112. package/dist/handlers/rest/file/getExtenstion.js.map +0 -0
  113. package/dist/handlers/rest/file/index.d.ts +0 -0
  114. package/dist/handlers/rest/file/index.js +0 -0
  115. package/dist/handlers/rest/file/index.js.map +0 -0
  116. package/dist/handlers/rest/file/storeFile.d.ts +0 -0
  117. package/dist/handlers/rest/file/storeFile.js +0 -0
  118. package/dist/handlers/rest/file/storeFile.js.map +0 -0
  119. package/dist/handlers/rest/file/stream.d.ts +0 -0
  120. package/dist/handlers/rest/file/stream.js +0 -0
  121. package/dist/handlers/rest/file/stream.js.map +0 -0
  122. package/dist/handlers/rest/file/types.d.ts +0 -0
  123. package/dist/handlers/rest/file/types.js +0 -0
  124. package/dist/handlers/rest/file/types.js.map +0 -0
  125. package/dist/handlers/rest/getReqMessage.d.ts +0 -0
  126. package/dist/handlers/rest/getReqMessage.js +0 -0
  127. package/dist/handlers/rest/getReqMessage.js.map +0 -0
  128. package/dist/handlers/rest/index.d.ts +0 -0
  129. package/dist/handlers/rest/index.js +0 -0
  130. package/dist/handlers/rest/index.js.map +0 -0
  131. package/dist/handlers/rest/invalidReq.d.ts +0 -0
  132. package/dist/handlers/rest/invalidReq.js +0 -0
  133. package/dist/handlers/rest/invalidReq.js.map +0 -0
  134. package/dist/handlers/rest/parseResponse.d.ts +0 -0
  135. package/dist/handlers/rest/parseResponse.js +0 -0
  136. package/dist/handlers/rest/parseResponse.js.map +0 -0
  137. package/dist/handlers/rest/playground/index.d.ts +0 -0
  138. package/dist/handlers/rest/playground/index.js +0 -0
  139. package/dist/handlers/rest/playground/index.js.map +0 -0
  140. package/dist/handlers/rest/readBody.d.ts +0 -0
  141. package/dist/handlers/rest/readBody.js +0 -0
  142. package/dist/handlers/rest/readBody.js.map +0 -0
  143. package/dist/handlers/set/index.d.ts +0 -0
  144. package/dist/handlers/set/index.js +0 -0
  145. package/dist/handlers/set/index.js.map +0 -0
  146. package/dist/handlers/subscription/index.d.ts +0 -0
  147. package/dist/handlers/subscription/index.js +0 -0
  148. package/dist/handlers/subscription/index.js.map +0 -0
  149. package/dist/handlers/token.d.ts +0 -0
  150. package/dist/handlers/token.js +0 -0
  151. package/dist/handlers/token.js.map +0 -0
  152. package/dist/handlers/track/index.d.ts +0 -0
  153. package/dist/handlers/track/index.js +0 -0
  154. package/dist/handlers/track/index.js.map +0 -0
  155. package/dist/handlers/userAuth/index.d.ts +0 -0
  156. package/dist/handlers/userAuth/index.js +0 -0
  157. package/dist/handlers/userAuth/index.js.map +0 -0
  158. package/dist/index.d.ts +0 -0
  159. package/dist/index.js +0 -0
  160. package/dist/index.js.map +0 -0
  161. package/dist/network/http/authorize.d.ts +3 -0
  162. package/dist/network/http/authorize.js +30 -0
  163. package/dist/network/http/authorize.js.map +1 -0
  164. package/dist/network/http/compress.d.ts +6 -0
  165. package/dist/network/http/compress.js +47 -0
  166. package/dist/network/http/compress.js.map +1 -0
  167. package/dist/network/http/end.d.ts +4 -0
  168. package/dist/network/http/end.js +19 -0
  169. package/dist/network/http/end.js.map +1 -0
  170. package/dist/network/http/function/index.d.ts +3 -0
  171. package/dist/network/http/function/index.js +82 -0
  172. package/dist/network/http/function/index.js.map +1 -0
  173. package/dist/network/http/function/stream/DataStream.d.ts +7 -0
  174. package/dist/network/http/function/stream/DataStream.js +17 -0
  175. package/dist/network/http/function/stream/DataStream.js.map +1 -0
  176. package/dist/network/http/function/stream/index.d.ts +8 -0
  177. package/dist/network/http/function/stream/index.js +93 -0
  178. package/dist/network/http/function/stream/index.js.map +1 -0
  179. package/dist/network/http/function/stream/multipartFormStream.d.ts +0 -0
  180. package/dist/network/http/function/stream/multipartFormStream.js +194 -0
  181. package/dist/network/http/function/stream/multipartFormStream.js.map +1 -0
  182. package/dist/network/http/function/stream/stream.d.ts +4 -0
  183. package/dist/network/http/function/stream/stream.js +49 -0
  184. package/dist/network/http/function/stream/stream.js.map +1 -0
  185. package/dist/network/http/function.d.ts +3 -0
  186. package/dist/network/http/function.js +46 -0
  187. package/dist/network/http/function.js.map +1 -0
  188. package/dist/network/http/get.d.ts +3 -0
  189. package/dist/network/http/get.js +143 -0
  190. package/dist/network/http/get.js.map +1 -0
  191. package/dist/network/http/index.d.ts +3 -0
  192. package/dist/network/http/index.js +125 -0
  193. package/dist/network/http/index.js.map +1 -0
  194. package/dist/network/http/readBody.d.ts +2 -0
  195. package/dist/network/http/readBody.js +134 -0
  196. package/dist/network/http/readBody.js.map +1 -0
  197. package/dist/network/http/readPostData.d.ts +3 -0
  198. package/dist/network/http/readPostData.js +50 -0
  199. package/dist/network/http/readPostData.js.map +1 -0
  200. package/dist/network/http/send.d.ts +6 -0
  201. package/dist/network/http/send.js +65 -0
  202. package/dist/network/http/send.js.map +1 -0
  203. package/dist/network/http/sendError.d.ts +4 -0
  204. package/dist/network/http/sendError.js +27 -0
  205. package/dist/network/http/sendError.js.map +1 -0
  206. package/dist/network/http/stream/DataStream.d.ts +7 -0
  207. package/dist/network/http/stream/DataStream.js +17 -0
  208. package/dist/network/http/stream/DataStream.js.map +1 -0
  209. package/dist/network/http/stream/formStream.d.ts +4 -0
  210. package/dist/network/http/stream/formStream.js +184 -0
  211. package/dist/network/http/stream/formStream.js.map +1 -0
  212. package/dist/network/http/stream/getExtenstion.d.ts +2 -0
  213. package/dist/network/http/stream/getExtenstion.js +22 -0
  214. package/dist/network/http/stream/getExtenstion.js.map +1 -0
  215. package/dist/network/http/stream/index.d.ts +9 -0
  216. package/dist/network/http/stream/index.js +42 -0
  217. package/dist/network/http/stream/index.js.map +1 -0
  218. package/dist/network/http/stream/multipartFormStream.d.ts +0 -0
  219. package/dist/network/http/stream/multipartFormStream.js +194 -0
  220. package/dist/network/http/stream/multipartFormStream.js.map +1 -0
  221. package/dist/network/http/stream/storeFile.d.ts +5 -0
  222. package/dist/network/http/stream/storeFile.js +30 -0
  223. package/dist/network/http/stream/storeFile.js.map +1 -0
  224. package/dist/network/http/stream/stream.d.ts +4 -0
  225. package/dist/network/http/stream/stream.js +49 -0
  226. package/dist/network/http/stream/stream.js.map +1 -0
  227. package/dist/network/http/stream/types.d.ts +9 -0
  228. package/dist/network/http/stream/types.js +3 -0
  229. package/dist/network/http/stream/types.js.map +1 -0
  230. package/dist/network/http/streamFunction/DataStream.d.ts +7 -0
  231. package/dist/network/http/streamFunction/DataStream.js +17 -0
  232. package/dist/network/http/streamFunction/DataStream.js.map +1 -0
  233. package/dist/network/http/streamFunction/endStreamRequest.d.ts +3 -0
  234. package/dist/network/http/streamFunction/endStreamRequest.js +20 -0
  235. package/dist/network/http/streamFunction/endStreamRequest.js.map +1 -0
  236. package/dist/network/http/streamFunction/getExtension.d.ts +2 -0
  237. package/dist/network/http/streamFunction/getExtension.js +22 -0
  238. package/dist/network/http/streamFunction/getExtension.js.map +1 -0
  239. package/dist/network/http/streamFunction/index.d.ts +3 -0
  240. package/dist/network/http/streamFunction/index.js +71 -0
  241. package/dist/network/http/streamFunction/index.js.map +1 -0
  242. package/dist/network/http/streamFunction/multipartFormStream.d.ts +5 -0
  243. package/dist/network/http/streamFunction/multipartFormStream.js +189 -0
  244. package/dist/network/http/streamFunction/multipartFormStream.js.map +1 -0
  245. package/dist/network/http/streamFunction/multipartStream.d.ts +13 -0
  246. package/dist/network/http/streamFunction/multipartStream.js +166 -0
  247. package/dist/network/http/streamFunction/multipartStream.js.map +1 -0
  248. package/dist/network/http/streamFunction/stream.d.ts +4 -0
  249. package/dist/network/http/streamFunction/stream.js +106 -0
  250. package/dist/network/http/streamFunction/stream.js.map +1 -0
  251. package/dist/network/index.d.ts +4 -0
  252. package/dist/network/index.js +84 -0
  253. package/dist/network/index.js.map +1 -0
  254. package/dist/network/message/auth.d.ts +4 -0
  255. package/dist/network/message/auth.js +35 -0
  256. package/dist/network/message/auth.js.map +1 -0
  257. package/dist/network/message/function.d.ts +3 -0
  258. package/dist/network/message/function.js +70 -0
  259. package/dist/network/message/function.js.map +1 -0
  260. package/dist/network/message/get.d.ts +3 -0
  261. package/dist/network/message/get.js +111 -0
  262. package/dist/network/message/get.js.map +1 -0
  263. package/dist/network/message/index.d.ts +3 -0
  264. package/dist/network/message/index.js +61 -0
  265. package/dist/network/message/index.js.map +1 -0
  266. package/dist/network/message/observable.d.ts +5 -0
  267. package/dist/network/message/observable.js +105 -0
  268. package/dist/network/message/observable.js.map +1 -0
  269. package/dist/network/message/send.d.ts +3 -0
  270. package/dist/network/message/send.js +11 -0
  271. package/dist/network/message/send.js.map +1 -0
  272. package/dist/network/rest/function.d.ts +3 -0
  273. package/dist/network/rest/function.js +85 -0
  274. package/dist/network/rest/function.js.map +1 -0
  275. package/dist/network/rest/index.d.ts +3 -0
  276. package/dist/network/rest/index.js +65 -0
  277. package/dist/network/rest/index.js.map +1 -0
  278. package/dist/network/upgrade.d.ts +4 -0
  279. package/dist/network/upgrade.js +48 -0
  280. package/dist/network/upgrade.js.map +1 -0
  281. package/dist/observable/index.d.ts +8 -0
  282. package/dist/observable/index.js +224 -0
  283. package/dist/observable/index.js.map +1 -0
  284. package/dist/openListener.d.ts +0 -0
  285. package/dist/openListener.js +0 -0
  286. package/dist/openListener.js.map +0 -0
  287. package/dist/protocol.d.ts +18 -0
  288. package/dist/protocol.js +206 -0
  289. package/dist/protocol.js.map +1 -0
  290. package/dist/secrets.d.ts +0 -0
  291. package/dist/secrets.js +0 -0
  292. package/dist/secrets.js.map +0 -0
  293. package/dist/server.d.ts +28 -0
  294. package/dist/server.js +96 -0
  295. package/dist/server.js.map +1 -0
  296. package/dist/types.d.ts +0 -0
  297. package/dist/types.js +0 -0
  298. package/dist/types.js.map +0 -0
  299. package/dist/upgradeListener.d.ts +0 -0
  300. package/dist/upgradeListener.js +0 -0
  301. package/dist/upgradeListener.js.map +0 -0
  302. package/dist/workers/index.d.ts +0 -0
  303. package/dist/workers/index.js +0 -0
  304. package/dist/workers/index.js.map +0 -0
  305. package/dist/workers/workerCode.d.ts +0 -0
  306. package/dist/workers/workerCode.js +0 -0
  307. package/dist/workers/workerCode.js.map +0 -0
  308. package/package.json +2 -2
@@ -1,5 +1,5 @@
1
- @based/server:build: cache hit, replaying output ee35da1cc527cb85
2
- @based/server:build: 
3
- @based/server:build: > @based/server@3.3.6 build
4
- @based/server:build: > npx tsc
5
- @based/server:build: 
1
+ @based/server:build: cache hit, replaying output 41052a2fc60c2a3e
2
+ @based/server:build: 
3
+ @based/server:build: > @based/server@3.3.7 build
4
+ @based/server:build: > npx tsc
5
+ @based/server:build: 
File without changes
File without changes
File without changes
package/dist/Client.d.ts CHANGED
File without changes
package/dist/Client.js CHANGED
File without changes
File without changes
package/dist/Params.d.ts CHANGED
File without changes
package/dist/Params.js CHANGED
File without changes
File without changes
@@ -0,0 +1,2 @@
1
+ import { Authorize } from '../types';
2
+ export declare const authorize: Authorize;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.authorize = void 0;
4
+ const authorize = async (_server, _ws, _name, _payload) => {
5
+ return true;
6
+ };
7
+ exports.authorize = authorize;
8
+ //# sourceMappingURL=authorize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authorize.js","sourceRoot":"","sources":["../../src/auth/authorize.ts"],"names":[],"mappings":";;;AAEO,MAAM,SAAS,GAAc,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE;IAC1E,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AAFY,QAAA,SAAS,aAErB"}
@@ -0,0 +1,2 @@
1
+ import { AuthorizeAdvanced } from '../types';
2
+ export declare const authorizeAdvanced: AuthorizeAdvanced;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.authorizeAdvanced = void 0;
4
+ const authorizeAdvanced = async (server, ws) => {
5
+ console.log('hello from authorizeAdvanced', { ws });
6
+ // const { server } = props
7
+ // return server.auth.authorizeAdvanced(props)
8
+ };
9
+ exports.authorizeAdvanced = authorizeAdvanced;
10
+ //# sourceMappingURL=authorizeAdvanced.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authorizeAdvanced.js","sourceRoot":"","sources":["../../src/auth/authorizeAdvanced.ts"],"names":[],"mappings":";;;AAIO,MAAM,iBAAiB,GAAsB,KAAK,EACvD,MAAmB,EACnB,EAAiB,EACjB,EAAE;IACF,OAAO,CAAC,GAAG,CAAC,8BAA8B,EAAE,EAAE,EAAE,EAAE,CAAC,CAAA;IACnD,2BAA2B;IAC3B,8CAA8C;AAChD,CAAC,CAAA;AAPY,QAAA,iBAAiB,qBAO7B"}
@@ -0,0 +1,2 @@
1
+ import { Authorize } from '../../types';
2
+ export declare const authorize: Authorize;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.authorize = void 0;
4
+ const authorize = async (_server, _ws, _type, _name, _payload) => {
5
+ return true;
6
+ };
7
+ exports.authorize = authorize;
8
+ //# sourceMappingURL=authorize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authorize.js","sourceRoot":"","sources":["../../../src/auth/defaults/authorize.ts"],"names":[],"mappings":";;;AAEO,MAAM,SAAS,GAAc,KAAK,EACvC,OAAO,EACP,GAAG,EACH,KAAK,EACL,KAAK,EACL,QAAQ,EACR,EAAE;IACF,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AARY,QAAA,SAAS,aAQrB"}
@@ -0,0 +1,2 @@
1
+ import { AuthorizeAvanced } from '../../types';
2
+ export declare const authorizeAdvanced: AuthorizeAvanced;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.authorizeAdvanced = void 0;
4
+ const authorizeAdvanced = async (server, ws, type, name, payload) => {
5
+ return server.auth.config, authorize(server, ws, type, name, payload);
6
+ };
7
+ exports.authorizeAdvanced = authorizeAdvanced;
8
+ //# sourceMappingURL=authorizeAdvanced.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authorizeAdvanced.js","sourceRoot":"","sources":["../../../src/auth/defaults/authorizeAdvanced.ts"],"names":[],"mappings":";;;AAEO,MAAM,iBAAiB,GAAqB,KAAK,EACtD,MAAM,EACN,EAAE,EACF,IAAI,EACJ,IAAI,EACJ,OAAO,EACP,EAAE;IACF,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,CAAC,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAA;AACvE,CAAC,CAAA;AARY,QAAA,iBAAiB,qBAQ7B"}
@@ -0,0 +1,2 @@
1
+ export * from './authorize';
2
+ export * from './authorizeAdvanced';
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./authorize"), exports);
18
+ __exportStar(require("./authorizeAdvanced"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/auth/defaults/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA2B;AAC3B,sDAAmC"}
@@ -0,0 +1,10 @@
1
+ import { AuthState } from '../network/message/auth';
2
+ import { BasedServer } from '../server';
3
+ import { AuthConfig, WebsocketClient } from '../types';
4
+ export declare class BasedAuth {
5
+ server: BasedServer;
6
+ config: AuthConfig;
7
+ constructor(server: BasedServer, config?: AuthConfig);
8
+ updateConfig(config: AuthConfig): void;
9
+ sendAuthUpdate(client: WebsocketClient, authState: AuthState): void;
10
+ }
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BasedAuth = void 0;
4
+ const utils_1 = require("@saulx/utils");
5
+ const protocol_1 = require("../protocol");
6
+ const authorize_1 = require("./authorize");
7
+ class BasedAuth {
8
+ constructor(server, config) {
9
+ this.server = server;
10
+ this.config = {
11
+ authorize: authorize_1.authorize,
12
+ };
13
+ this.updateConfig(config);
14
+ }
15
+ updateConfig(config) {
16
+ (0, utils_1.deepMerge)(this.config, config);
17
+ }
18
+ sendAuthUpdate(client, authState) {
19
+ client.ws?.send((0, protocol_1.encodeAuthResponse)((0, protocol_1.valueToBuffer)(authState)), true, false);
20
+ }
21
+ }
22
+ exports.BasedAuth = BasedAuth;
23
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":";;;AAAA,wCAAwC;AAExC,0CAA+D;AAG/D,2CAAuC;AAEvC,MAAa,SAAS;IAIpB,YAAY,MAAmB,EAAE,MAAmB;QAClD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,MAAM,GAAG;YACZ,SAAS,EAAT,qBAAS;SACV,CAAA;QACD,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAA;IAC3B,CAAC;IAED,YAAY,CAAC,MAAkB;QAC7B,IAAA,iBAAS,EAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAChC,CAAC;IAED,cAAc,CAAC,MAAuB,EAAE,SAAoB;QAC1D,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,IAAA,6BAAkB,EAAC,IAAA,wBAAa,EAAC,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,CAAA;IAC5E,CAAC;CACF;AAnBD,8BAmBC"}
File without changes
File without changes
File without changes
@@ -0,0 +1,34 @@
1
+ export declare enum BasedErrorCode {
2
+ FunctionError = 50001,
3
+ AuthorizeFunctionError = 50002,
4
+ NoOservableCacheAvailable = 50003,
5
+ ObservableFunctionError = 50004,
6
+ FunctionNotFound = 40401,
7
+ FunctionIsNotObservable = 40402,
8
+ FunctionIsObservable = 40403,
9
+ CannotStreamToObservableFunction = 40402,
10
+ AuthorizeRejectedError = 40301,
11
+ InvalidPayload = 40001,
12
+ PayloadTooLarge = 40002,
13
+ ChunkTooLarge = 40003,
14
+ UnsupportedContentEncoding = 40004,
15
+ LengthRequired = 41101,
16
+ MethodNotAllowed = 40501
17
+ }
18
+ export declare type BasedErrorData = {
19
+ message: string;
20
+ basedMessage?: string;
21
+ stack: string;
22
+ requestId?: number;
23
+ observableId?: number;
24
+ basedCode: BasedErrorCode;
25
+ status?: number;
26
+ code?: string;
27
+ };
28
+ export declare type CreateErrorProps = {
29
+ err?: Error;
30
+ name?: string;
31
+ observableId?: number;
32
+ requestId?: number;
33
+ } | string;
34
+ export declare const createError: (basedCode: BasedErrorCode, err?: CreateErrorProps) => BasedErrorData;
package/dist/error.js ADDED
@@ -0,0 +1,107 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createError = exports.BasedErrorCode = void 0;
4
+ var BasedErrorCode;
5
+ (function (BasedErrorCode) {
6
+ BasedErrorCode[BasedErrorCode["FunctionError"] = 50001] = "FunctionError";
7
+ BasedErrorCode[BasedErrorCode["AuthorizeFunctionError"] = 50002] = "AuthorizeFunctionError";
8
+ BasedErrorCode[BasedErrorCode["NoOservableCacheAvailable"] = 50003] = "NoOservableCacheAvailable";
9
+ BasedErrorCode[BasedErrorCode["ObservableFunctionError"] = 50004] = "ObservableFunctionError";
10
+ BasedErrorCode[BasedErrorCode["FunctionNotFound"] = 40401] = "FunctionNotFound";
11
+ BasedErrorCode[BasedErrorCode["FunctionIsNotObservable"] = 40402] = "FunctionIsNotObservable";
12
+ BasedErrorCode[BasedErrorCode["FunctionIsObservable"] = 40403] = "FunctionIsObservable";
13
+ BasedErrorCode[BasedErrorCode["CannotStreamToObservableFunction"] = 40402] = "CannotStreamToObservableFunction";
14
+ BasedErrorCode[BasedErrorCode["AuthorizeRejectedError"] = 40301] = "AuthorizeRejectedError";
15
+ BasedErrorCode[BasedErrorCode["InvalidPayload"] = 40001] = "InvalidPayload";
16
+ BasedErrorCode[BasedErrorCode["PayloadTooLarge"] = 40002] = "PayloadTooLarge";
17
+ BasedErrorCode[BasedErrorCode["ChunkTooLarge"] = 40003] = "ChunkTooLarge";
18
+ BasedErrorCode[BasedErrorCode["UnsupportedContentEncoding"] = 40004] = "UnsupportedContentEncoding";
19
+ BasedErrorCode[BasedErrorCode["LengthRequired"] = 41101] = "LengthRequired";
20
+ BasedErrorCode[BasedErrorCode["MethodNotAllowed"] = 40501] = "MethodNotAllowed";
21
+ })(BasedErrorCode = exports.BasedErrorCode || (exports.BasedErrorCode = {}));
22
+ const errorDefaults = {
23
+ [BasedErrorCode.FunctionError]: {
24
+ code: 500,
25
+ status: 'Internal Server Error',
26
+ message: ({ name }) => `Error in function${name ? ' ' + name : ''}.`,
27
+ },
28
+ [BasedErrorCode.FunctionNotFound]: {
29
+ code: 404,
30
+ status: 'Not Found',
31
+ message: ({ name }) => `Function${name ? ' ' + name : ''} not found.`,
32
+ },
33
+ [BasedErrorCode.CannotStreamToObservableFunction]: {
34
+ code: 404,
35
+ status: 'Not Found',
36
+ message: 'Cannot stream to observable function.',
37
+ },
38
+ [BasedErrorCode.AuthorizeFunctionError]: {
39
+ code: 403,
40
+ status: 'Forbidden',
41
+ message: 'Error in authorize function',
42
+ },
43
+ [BasedErrorCode.AuthorizeRejectedError]: {
44
+ code: 403,
45
+ status: 'Forbidden',
46
+ message: ({ name }) => `Authorize rejected access${name ? ' to function ' + name : ''}.`,
47
+ },
48
+ [BasedErrorCode.InvalidPayload]: {
49
+ code: 400,
50
+ status: 'Bad Request',
51
+ message: 'Invalid payload.',
52
+ },
53
+ [BasedErrorCode.PayloadTooLarge]: { code: 413, status: 'Payload Too Large' },
54
+ [BasedErrorCode.ChunkTooLarge]: { code: 413, status: 'Payload Too Large' },
55
+ [BasedErrorCode.UnsupportedContentEncoding]: {
56
+ code: 400,
57
+ status: 'Incorrect content encoding',
58
+ },
59
+ [BasedErrorCode.LengthRequired]: { code: 411, status: 'Length Required' },
60
+ [BasedErrorCode.MethodNotAllowed]: {
61
+ code: 405,
62
+ status: 'Method Not Allowed',
63
+ },
64
+ [BasedErrorCode.NoOservableCacheAvailable]: {
65
+ code: 500,
66
+ status: 'Internal Server Error',
67
+ message: ({ name }) => `No observable cache available${name ? ' for function ' + name : ''}.`,
68
+ },
69
+ };
70
+ const createError = (basedCode, err) => {
71
+ const errorData = { message: null, stack: null, basedCode };
72
+ errorData.basedMessage =
73
+ typeof errorDefaults[basedCode]?.message === 'function'
74
+ ? errorDefaults[basedCode]?.message(err)
75
+ : errorDefaults[basedCode]?.message ||
76
+ errorDefaults[basedCode]?.status ||
77
+ 'Oops something went wrong';
78
+ if (typeof err === 'string') {
79
+ errorData.message = err;
80
+ }
81
+ else {
82
+ if (err?.err instanceof Error) {
83
+ Object.getOwnPropertyNames(err.err).forEach((key) => {
84
+ errorData[key] = err.err[key];
85
+ });
86
+ }
87
+ else {
88
+ errorData.message = errorData.basedMessage;
89
+ const captureTarget = { stack: null };
90
+ Error.captureStackTrace(captureTarget, exports.createError);
91
+ errorData.stack = captureTarget.stack;
92
+ }
93
+ }
94
+ if (typeof err !== 'string') {
95
+ if (err?.observableId) {
96
+ errorData.observableId = err.observableId;
97
+ }
98
+ if (err?.requestId) {
99
+ errorData.requestId = err.requestId;
100
+ }
101
+ }
102
+ errorData.code = errorDefaults[basedCode]?.code;
103
+ errorData.status = errorDefaults[basedCode]?.status;
104
+ return errorData;
105
+ };
106
+ exports.createError = createError;
107
+ //# sourceMappingURL=error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":";;;AAAA,IAAY,cAgBX;AAhBD,WAAY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,CAAC,CAAA;AAzCY,QAAA,WAAW,eAyCvB"}
File without changes
File without changes
File without changes
@@ -0,0 +1,31 @@
1
+ /// <reference types="node" />
2
+ import type { BasedServer } from '../server';
3
+ import { BasedFunctionRoute, BasedFunctionSpec, BasedObservableFunctionSpec, FunctionConfig, isObservableFunctionSpec } from '../types';
4
+ export { isObservableFunctionSpec };
5
+ export declare class BasedFunctions {
6
+ server: BasedServer;
7
+ config: FunctionConfig;
8
+ unregisterTimeout: NodeJS.Timeout;
9
+ paths: {
10
+ [path: string]: string;
11
+ };
12
+ observables: {
13
+ [name: string]: BasedObservableFunctionSpec;
14
+ };
15
+ functions: {
16
+ [name: string]: BasedFunctionSpec;
17
+ };
18
+ beingUninstalled: {
19
+ [name: string]: boolean;
20
+ };
21
+ constructor(server: BasedServer, config?: FunctionConfig);
22
+ uninstallLoop(): void;
23
+ updateConfig(config: FunctionConfig): void;
24
+ install(name: string): Promise<BasedObservableFunctionSpec | BasedFunctionSpec | false>;
25
+ getNameFromPath(path: string): string;
26
+ route(name?: string, path?: string): BasedFunctionRoute | false;
27
+ getFromStore(name: string): BasedObservableFunctionSpec | BasedFunctionSpec | false;
28
+ update(spec: BasedObservableFunctionSpec | BasedFunctionSpec): boolean;
29
+ remove(name: string): boolean;
30
+ uninstall(name: string, spec?: BasedObservableFunctionSpec | BasedFunctionSpec | false): Promise<boolean>;
31
+ }
@@ -0,0 +1,200 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BasedFunctions = exports.isObservableFunctionSpec = void 0;
4
+ const types_1 = require("../types");
5
+ Object.defineProperty(exports, "isObservableFunctionSpec", { enumerable: true, get: function () { return types_1.isObservableFunctionSpec; } });
6
+ const utils_1 = require("@saulx/utils");
7
+ const timeout_1 = require("./timeout");
8
+ const observable_1 = require("../observable");
9
+ class BasedFunctions {
10
+ constructor(server, config) {
11
+ this.paths = {};
12
+ this.observables = {};
13
+ this.functions = {};
14
+ this.beingUninstalled = {};
15
+ this.server = server;
16
+ if (config) {
17
+ this.updateConfig(config);
18
+ }
19
+ }
20
+ uninstallLoop() {
21
+ this.unregisterTimeout = setTimeout(async () => {
22
+ const q = [];
23
+ for (const name in this.functions) {
24
+ const spec = this.functions[name];
25
+ if ((0, timeout_1.fnIsTimedOut)(spec)) {
26
+ q.push(this.uninstall(name, spec));
27
+ }
28
+ }
29
+ for (const name in this.observables) {
30
+ const spec = this.observables[name];
31
+ if (this.server.activeObservables[name]) {
32
+ (0, timeout_1.updateTimeoutCounter)(spec);
33
+ }
34
+ else if ((0, timeout_1.fnIsTimedOut)(spec)) {
35
+ q.push(this.uninstall(name, spec));
36
+ }
37
+ }
38
+ await Promise.all(q);
39
+ this.uninstallLoop();
40
+ }, 3e3);
41
+ }
42
+ updateConfig(config) {
43
+ if (this.config) {
44
+ (0, utils_1.deepMerge)(this.config, config);
45
+ }
46
+ else {
47
+ this.config = config;
48
+ }
49
+ if (this.config.idleTimeout === undefined) {
50
+ this.config.idleTimeout = 60e3; // 1 min
51
+ }
52
+ if (this.config.memCacheTimeout === undefined) {
53
+ this.config.memCacheTimeout = 3e3;
54
+ }
55
+ if (this.config.maxWorkers === undefined) {
56
+ this.config.maxWorkers = 0;
57
+ }
58
+ if (this.config.log === undefined) {
59
+ this.config.log = (opts) => {
60
+ console.info(opts);
61
+ };
62
+ }
63
+ if (this.unregisterTimeout) {
64
+ clearTimeout(this.unregisterTimeout);
65
+ }
66
+ this.uninstallLoop();
67
+ }
68
+ async install(name) {
69
+ let spec = this.getFromStore(name);
70
+ if (spec) {
71
+ return spec;
72
+ }
73
+ spec = await this.config.install({
74
+ server: this.server,
75
+ name,
76
+ });
77
+ if (spec) {
78
+ this.update(spec);
79
+ return this.getFromStore(name);
80
+ }
81
+ return false;
82
+ }
83
+ getNameFromPath(path) {
84
+ return this.paths[path];
85
+ }
86
+ route(name, path) {
87
+ const result = this.config.route({ server: this.server, name, path });
88
+ if (result && !result.maxPayloadSize) {
89
+ if (result.observable) {
90
+ // 50kb
91
+ result.maxPayloadSize = 50000;
92
+ }
93
+ else {
94
+ if (result.stream) {
95
+ result.maxPayloadSize = -1;
96
+ }
97
+ else {
98
+ result.maxPayloadSize = 250000;
99
+ }
100
+ }
101
+ }
102
+ return result;
103
+ }
104
+ getFromStore(name) {
105
+ const spec = this.observables[name] || this.functions[name];
106
+ if (spec) {
107
+ if (this.beingUninstalled[name]) {
108
+ console.info('getFromStore is being uninstalled', name);
109
+ delete this.beingUninstalled[name];
110
+ }
111
+ (0, timeout_1.updateTimeoutCounter)(spec);
112
+ return spec;
113
+ }
114
+ return false;
115
+ }
116
+ update(spec) {
117
+ if (spec) {
118
+ if (!spec.idleTimeout) {
119
+ spec.idleTimeout = this.config.idleTimeout;
120
+ }
121
+ if (spec.timeoutCounter === undefined) {
122
+ spec.timeoutCounter =
123
+ spec.idleTimeout === 0 ? -1 : Math.ceil(spec.idleTimeout / 1e3);
124
+ }
125
+ if (spec.path) {
126
+ this.paths[spec.path] = spec.name;
127
+ }
128
+ if ((0, types_1.isObservableFunctionSpec)(spec)) {
129
+ if (this.functions[spec.name]) {
130
+ this.remove(spec.name);
131
+ }
132
+ this.observables[spec.name] = spec;
133
+ if (this.server.activeObservables[spec.name]) {
134
+ for (const [id] of this.server.activeObservables[spec.name]) {
135
+ (0, observable_1.initFunction)(this.server, id);
136
+ }
137
+ }
138
+ }
139
+ else {
140
+ if (this.observables[spec.name]) {
141
+ this.remove(spec.name);
142
+ }
143
+ this.functions[spec.name] = spec;
144
+ }
145
+ }
146
+ return false;
147
+ }
148
+ remove(name) {
149
+ // Does not call unregister!
150
+ if (this.observables[name]) {
151
+ if (this.observables[name].path) {
152
+ delete this.paths[this.observables[name].path];
153
+ }
154
+ delete this.observables[name];
155
+ const activeObs = this.server.activeObservables[name];
156
+ if (activeObs) {
157
+ for (const [id] of activeObs) {
158
+ (0, observable_1.destroy)(this.server, id);
159
+ }
160
+ delete this.server.activeObservables[name];
161
+ }
162
+ return true;
163
+ }
164
+ else if (this.functions[name]) {
165
+ if (this.functions[name].path) {
166
+ delete this.paths[this.functions[name].path];
167
+ }
168
+ delete this.functions[name];
169
+ return true;
170
+ }
171
+ return false;
172
+ }
173
+ async uninstall(name, spec) {
174
+ if (this.beingUninstalled[name]) {
175
+ console.error('Allready being unregistered...', name);
176
+ }
177
+ if (!spec && spec !== false) {
178
+ spec = this.getFromStore(name);
179
+ }
180
+ if (spec) {
181
+ this.beingUninstalled[name] = true;
182
+ if (await this.config.uninstall({
183
+ server: this.server,
184
+ function: spec,
185
+ name,
186
+ })) {
187
+ if (this.beingUninstalled[name]) {
188
+ delete this.beingUninstalled[name];
189
+ return this.remove(name);
190
+ }
191
+ else {
192
+ console.info('got requested while being unregistered', name);
193
+ }
194
+ }
195
+ }
196
+ return false;
197
+ }
198
+ }
199
+ exports.BasedFunctions = BasedFunctions;
200
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/functions/index.ts"],"names":[],"mappings":";;;AACA,oCAMiB;AAKR,yGANP,gCAAwB,OAMO;AAJjC,wCAAwC;AACxC,uCAA8D;AAC9D,8CAAqD;AAIrD,MAAa,cAAc;IAuBzB,YAAY,MAAmB,EAAE,MAAuB;QAhBxD,UAAK,GAED,EAAE,CAAA;QAEN,gBAAW,GAEP,EAAE,CAAA;QAEN,cAAS,GAEL,EAAE,CAAA;QAEN,qBAAgB,GAEZ,EAAE,CAAA;QAGJ,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,MAAM,EAAE;YACV,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAA;SAC1B;IACH,CAAC;IAED,aAAa;QACX,IAAI,CAAC,iBAAiB,GAAG,UAAU,CAAC,KAAK,IAAI,EAAE;YAC7C,MAAM,CAAC,GAAG,EAAE,CAAA;YACZ,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,SAAS,EAAE;gBACjC,MAAM,IAAI,GAAG,IAAI,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;iBACzB;qBAAM;oBACL,OAAO,CAAC,IAAI,CAAC,wCAAwC,EAAE,IAAI,CAAC,CAAA;iBAC7D;aACF;SACF;QACD,OAAO,KAAK,CAAA;IACd,CAAC;CACF;AAjOD,wCAiOC"}
@@ -0,0 +1,3 @@
1
+ import type { BasedFunctionSpec, BasedObservableFunctionSpec } from '../types';
2
+ export declare const fnIsTimedOut: (spec: BasedObservableFunctionSpec | BasedFunctionSpec) => boolean;
3
+ export declare const updateTimeoutCounter: (spec: BasedObservableFunctionSpec | BasedFunctionSpec) => void;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.updateTimeoutCounter = exports.fnIsTimedOut = void 0;
4
+ const fnIsTimedOut = (spec) => {
5
+ if (spec.timeoutCounter !== -1) {
6
+ if (spec.timeoutCounter === 0) {
7
+ return true;
8
+ }
9
+ if (spec.idleTimeout > 0 && spec.timeoutCounter > 0) {
10
+ spec.timeoutCounter--;
11
+ }
12
+ }
13
+ return false;
14
+ };
15
+ exports.fnIsTimedOut = fnIsTimedOut;
16
+ const updateTimeoutCounter = (spec) => {
17
+ if (spec.timeoutCounter !== -1) {
18
+ spec.timeoutCounter =
19
+ spec.idleTimeout === -1 ? -1 : Math.ceil(spec.idleTimeout / 1e3 / 3);
20
+ }
21
+ };
22
+ exports.updateTimeoutCounter = updateTimeoutCounter;
23
+ //# sourceMappingURL=timeout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timeout.js","sourceRoot":"","sources":["../../src/functions/timeout.ts"],"names":[],"mappings":";;;AAEO,MAAM,YAAY,GAAG,CAC1B,IAAqD,EAC5C,EAAE;IACX,IAAI,IAAI,CAAC,cAAc,KAAK,CAAC,CAAC,EAAE;QAC9B,IAAI,IAAI,CAAC,cAAc,KAAK,CAAC,EAAE;YAC7B,OAAO,IAAI,CAAA;SACZ;QACD,IAAI,IAAI,CAAC,WAAW,GAAG,CAAC,IAAI,IAAI,CAAC,cAAc,GAAG,CAAC,EAAE;YACnD,IAAI,CAAC,cAAc,EAAE,CAAA;SACtB;KACF;IACD,OAAO,KAAK,CAAA;AACd,CAAC,CAAA;AAZY,QAAA,YAAY,gBAYxB;AAEM,MAAM,oBAAoB,GAAG,CAClC,IAAqD,EACrD,EAAE;IACF,IAAI,IAAI,CAAC,cAAc,KAAK,CAAC,CAAC,EAAE;QAC9B,IAAI,CAAC,cAAc;YACjB,IAAI,CAAC,WAAW,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,GAAG,GAAG,GAAG,CAAC,CAAC,CAAA;KACvE;AACH,CAAC,CAAA;AAPY,QAAA,oBAAoB,wBAOhC"}
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes