@based/server 3.4.5 → 4.0.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.
- package/dist/api/index.d.ts +7 -0
- package/dist/api/index.js +173 -0
- package/dist/api/index.js.map +1 -0
- package/dist/auth/dummyAuth.d.ts +1 -1
- package/dist/auth/dummyAuth.js +3 -2
- package/dist/auth/dummyAuth.js.map +1 -1
- package/dist/auth/index.d.ts +8 -4
- package/dist/auth/index.js +28 -23
- package/dist/auth/index.js.map +1 -1
- package/dist/auth/parseAuthState.d.ts +2 -0
- package/dist/auth/parseAuthState.js +16 -0
- package/dist/auth/parseAuthState.js.map +1 -0
- package/dist/auth/types.d.ts +10 -0
- package/dist/{handlers/rest/file → auth}/types.js +0 -0
- package/dist/auth/types.js.map +1 -0
- package/dist/compress.d.ts +5 -0
- package/dist/{network/http/compress.js → compress.js} +2 -6
- package/dist/compress.js.map +1 -0
- package/dist/context.d.ts +54 -0
- package/dist/context.js +18 -0
- package/dist/context.js.map +1 -0
- package/dist/error/errorTypeHandlers.d.ts +6 -0
- package/dist/error/errorTypeHandlers.js +130 -0
- package/dist/error/errorTypeHandlers.js.map +1 -0
- package/dist/error/index.d.ts +5 -0
- package/dist/error/index.js +61 -0
- package/dist/error/index.js.map +1 -0
- package/dist/error/types.d.ts +105 -0
- package/dist/error/types.js +30 -0
- package/dist/error/types.js.map +1 -0
- package/dist/functions/index.d.ts +10 -24
- package/dist/functions/index.js +98 -287
- package/dist/functions/index.js.map +1 -1
- package/dist/functions/timeout.d.ts +1 -1
- package/dist/functions/types.d.ts +69 -0
- package/dist/functions/types.js +15 -0
- package/dist/functions/types.js.map +1 -0
- package/dist/incoming/http/authorize.d.ts +4 -0
- package/dist/incoming/http/authorize.js +37 -0
- package/dist/incoming/http/authorize.js.map +1 -0
- package/dist/incoming/http/function.d.ts +4 -0
- package/dist/{network → incoming}/http/function.js +13 -13
- package/dist/incoming/http/function.js.map +1 -0
- package/dist/incoming/http/get.d.ts +4 -0
- package/dist/incoming/http/get.js +155 -0
- package/dist/incoming/http/get.js.map +1 -0
- package/dist/{network → incoming}/http/index.d.ts +0 -0
- package/dist/incoming/http/index.js +134 -0
- package/dist/incoming/http/index.js.map +1 -0
- package/dist/incoming/http/parseQuery.d.ts +4 -0
- package/dist/incoming/http/parseQuery.js +25 -0
- package/dist/incoming/http/parseQuery.js.map +1 -0
- package/dist/incoming/http/readBody.d.ts +4 -0
- package/dist/{network → incoming}/http/readBody.js +27 -32
- package/dist/incoming/http/readBody.js.map +1 -0
- package/dist/{handlers/rest/file → incoming/http/streamFunction}/DataStream.d.ts +0 -0
- package/dist/{network → incoming}/http/streamFunction/DataStream.js +0 -0
- package/dist/incoming/http/streamFunction/DataStream.js.map +1 -0
- package/dist/{network → incoming}/http/streamFunction/getExtension.d.ts +0 -0
- package/dist/{network → incoming}/http/streamFunction/getExtension.js +0 -0
- package/dist/incoming/http/streamFunction/getExtension.js.map +1 -0
- package/dist/incoming/http/streamFunction/index.d.ts +4 -0
- package/dist/incoming/http/streamFunction/index.js +106 -0
- package/dist/incoming/http/streamFunction/index.js.map +1 -0
- package/dist/incoming/http/streamFunction/multipartStream.d.ts +13 -0
- package/dist/{network → incoming}/http/streamFunction/multipartStream.js +12 -12
- package/dist/incoming/http/streamFunction/multipartStream.js.map +1 -0
- package/dist/{network → incoming}/http/streamFunction/stream.d.ts +3 -2
- package/dist/{network → incoming}/http/streamFunction/stream.js +16 -11
- package/dist/incoming/http/streamFunction/stream.js.map +1 -0
- package/dist/incoming/index.d.ts +3 -0
- package/dist/{network → incoming}/index.js +28 -28
- package/dist/incoming/index.js.map +1 -0
- package/dist/incoming/upgrade.d.ts +4 -0
- package/dist/{network → incoming}/upgrade.js +24 -9
- package/dist/incoming/upgrade.js.map +1 -0
- package/dist/incoming/ws/auth.d.ts +5 -0
- package/dist/incoming/ws/auth.js +40 -0
- package/dist/incoming/ws/auth.js.map +1 -0
- package/dist/incoming/ws/function.d.ts +3 -0
- package/dist/incoming/ws/function.js +107 -0
- package/dist/incoming/ws/function.js.map +1 -0
- package/dist/incoming/ws/get.d.ts +3 -0
- package/dist/incoming/ws/get.js +136 -0
- package/dist/incoming/ws/get.js.map +1 -0
- package/dist/incoming/ws/index.d.ts +3 -0
- package/dist/{network/message → incoming/ws}/index.js +17 -18
- package/dist/incoming/ws/index.js.map +1 -0
- package/dist/incoming/ws/observable.d.ts +6 -0
- package/dist/incoming/ws/observable.js +112 -0
- package/dist/incoming/ws/observable.js.map +1 -0
- package/dist/index.d.ts +10 -35
- package/dist/index.js +17 -196
- package/dist/index.js.map +1 -1
- package/dist/ip.d.ts +2 -0
- package/dist/ip.js +8 -0
- package/dist/ip.js.map +1 -0
- package/dist/observable/create.d.ts +3 -0
- package/dist/observable/create.js +30 -0
- package/dist/observable/create.js.map +1 -0
- package/dist/observable/destroy.d.ts +2 -0
- package/dist/observable/destroy.js +51 -0
- package/dist/observable/destroy.js.map +1 -0
- package/dist/observable/error.d.ts +4 -0
- package/dist/observable/error.js +17 -0
- package/dist/observable/error.js.map +1 -0
- package/dist/observable/extendCache.d.ts +2 -0
- package/dist/observable/extendCache.js +11 -0
- package/dist/observable/extendCache.js.map +1 -0
- package/dist/observable/genObservableId.d.ts +1 -0
- package/dist/observable/genObservableId.js +9 -0
- package/dist/observable/genObservableId.js.map +1 -0
- package/dist/observable/get.d.ts +4 -0
- package/dist/observable/get.js +15 -0
- package/dist/observable/get.js.map +1 -0
- package/dist/observable/index.d.ts +11 -8
- package/dist/observable/index.js +25 -151
- package/dist/observable/index.js.map +1 -1
- package/dist/observable/send.d.ts +6 -0
- package/dist/observable/send.js +32 -0
- package/dist/observable/send.js.map +1 -0
- package/dist/observable/start/error.d.ts +3 -0
- package/dist/observable/start/error.js +36 -0
- package/dist/observable/start/error.js.map +1 -0
- package/dist/observable/start/index.d.ts +2 -0
- package/dist/observable/start/index.js +46 -0
- package/dist/observable/start/index.js.map +1 -0
- package/dist/observable/start/update.d.ts +6 -0
- package/dist/observable/start/update.js +104 -0
- package/dist/observable/start/update.js.map +1 -0
- package/dist/observable/subscribe.d.ts +7 -0
- package/dist/observable/subscribe.js +54 -0
- package/dist/observable/subscribe.js.map +1 -0
- package/dist/observable/types.d.ts +26 -0
- package/dist/observable/types.js +3 -0
- package/dist/observable/types.js.map +1 -0
- package/dist/observable/unsub.d.ts +6 -0
- package/dist/observable/unsub.js +43 -0
- package/dist/observable/unsub.js.map +1 -0
- package/dist/observable/verify.d.ts +4 -0
- package/dist/observable/verify.js +18 -0
- package/dist/observable/verify.js.map +1 -0
- package/dist/protocol.d.ts +2 -0
- package/dist/protocol.js +32 -11
- package/dist/protocol.js.map +1 -1
- package/dist/security.d.ts +6 -0
- package/dist/security.js +95 -0
- package/dist/security.js.map +1 -0
- package/dist/sendError.d.ts +5 -0
- package/dist/sendError.js +42 -0
- package/dist/sendError.js.map +1 -0
- package/dist/sendHttpResponse.d.ts +4 -0
- package/dist/sendHttpResponse.js +53 -0
- package/dist/sendHttpResponse.js.map +1 -0
- package/dist/server.d.ts +42 -8
- package/dist/server.js +26 -12
- package/dist/server.js.map +1 -1
- package/package.json +16 -14
- package/.turbo/turbo-build.log +0 -4
- package/dist/BasedServerClient.d.ts +0 -71
- package/dist/BasedServerClient.js +0 -390
- package/dist/BasedServerClient.js.map +0 -1
- package/dist/Client.d.ts +0 -75
- package/dist/Client.js +0 -277
- package/dist/Client.js.map +0 -1
- package/dist/Params.d.ts +0 -20
- package/dist/Params.js +0 -48
- package/dist/Params.js.map +0 -1
- package/dist/auth/authorize.d.ts +0 -2
- package/dist/auth/authorize.js +0 -8
- package/dist/auth/authorize.js.map +0 -1
- package/dist/clientContext.d.ts +0 -0
- package/dist/clientContext.js +0 -83
- package/dist/clientContext.js.map +0 -1
- package/dist/closeListener.d.ts +0 -4
- package/dist/closeListener.js +0 -13
- package/dist/closeListener.js.map +0 -1
- package/dist/error.d.ts +0 -66
- package/dist/error.js +0 -149
- package/dist/error.js.map +0 -1
- package/dist/findPrefix.d.ts +0 -3
- package/dist/findPrefix.js +0 -20
- package/dist/findPrefix.js.map +0 -1
- package/dist/functions/workerPool.d.ts +0 -0
- package/dist/functions/workerPool.js +0 -5
- package/dist/functions/workerPool.js.map +0 -1
- package/dist/getFromConfig.d.ts +0 -3
- package/dist/getFromConfig.js +0 -50
- package/dist/getFromConfig.js.map +0 -1
- package/dist/handlers/authorize.d.ts +0 -5
- package/dist/handlers/authorize.js +0 -196
- package/dist/handlers/authorize.js.map +0 -1
- package/dist/handlers/bulkUpdate/index.d.ts +0 -5
- package/dist/handlers/bulkUpdate/index.js +0 -26
- package/dist/handlers/bulkUpdate/index.js.map +0 -1
- package/dist/handlers/configuration/index.d.ts +0 -10
- package/dist/handlers/configuration/index.js +0 -74
- package/dist/handlers/configuration/index.js.map +0 -1
- package/dist/handlers/configuration/observable/index.d.ts +0 -46
- package/dist/handlers/configuration/observable/index.js +0 -277
- package/dist/handlers/configuration/observable/index.js.map +0 -1
- package/dist/handlers/configure/index.d.ts +0 -5
- package/dist/handlers/configure/index.js +0 -44
- package/dist/handlers/configure/index.js.map +0 -1
- package/dist/handlers/copy/index.d.ts +0 -8
- package/dist/handlers/copy/index.js +0 -135
- package/dist/handlers/copy/index.js.map +0 -1
- package/dist/handlers/delete/index.d.ts +0 -5
- package/dist/handlers/delete/index.js +0 -34
- package/dist/handlers/delete/index.js.map +0 -1
- package/dist/handlers/digest/index.d.ts +0 -5
- package/dist/handlers/digest/index.js +0 -23
- package/dist/handlers/digest/index.js.map +0 -1
- package/dist/handlers/functions/call.d.ts +0 -6
- package/dist/handlers/functions/call.js +0 -54
- package/dist/handlers/functions/call.js.map +0 -1
- package/dist/handlers/functions/observable/Observable.d.ts +0 -49
- package/dist/handlers/functions/observable/Observable.js +0 -290
- package/dist/handlers/functions/observable/Observable.js.map +0 -1
- package/dist/handlers/functions/observable/SharedObservable.d.ts +0 -45
- package/dist/handlers/functions/observable/SharedObservable.js +0 -291
- package/dist/handlers/functions/observable/SharedObservable.js.map +0 -1
- package/dist/handlers/functions/observable/index.d.ts +0 -14
- package/dist/handlers/functions/observable/index.js +0 -130
- package/dist/handlers/functions/observable/index.js.map +0 -1
- package/dist/handlers/get/index.d.ts +0 -5
- package/dist/handlers/get/index.js +0 -23
- package/dist/handlers/get/index.js.map +0 -1
- package/dist/handlers/getConfig/index.d.ts +0 -5
- package/dist/handlers/getConfig/index.js +0 -38
- package/dist/handlers/getConfig/index.js.map +0 -1
- package/dist/handlers/handleRequests.d.ts +0 -5
- package/dist/handlers/handleRequests.js +0 -78
- package/dist/handlers/handleRequests.js.map +0 -1
- package/dist/handlers/index.d.ts +0 -4
- package/dist/handlers/index.js +0 -49
- package/dist/handlers/index.js.map +0 -1
- package/dist/handlers/messageParser.d.ts +0 -5
- package/dist/handlers/messageParser.js +0 -122
- package/dist/handlers/messageParser.js.map +0 -1
- package/dist/handlers/removeField/index.d.ts +0 -5
- package/dist/handlers/removeField/index.js +0 -42
- package/dist/handlers/removeField/index.js.map +0 -1
- package/dist/handlers/removeType/index.d.ts +0 -5
- package/dist/handlers/removeType/index.js +0 -30
- package/dist/handlers/removeType/index.js.map +0 -1
- package/dist/handlers/rest/file/DataStream.js +0 -17
- package/dist/handlers/rest/file/DataStream.js.map +0 -1
- package/dist/handlers/rest/file/formStream.d.ts +0 -4
- package/dist/handlers/rest/file/formStream.js +0 -188
- package/dist/handlers/rest/file/formStream.js.map +0 -1
- package/dist/handlers/rest/file/getExtenstion.d.ts +0 -2
- package/dist/handlers/rest/file/getExtenstion.js +0 -22
- package/dist/handlers/rest/file/getExtenstion.js.map +0 -1
- package/dist/handlers/rest/file/index.d.ts +0 -4
- package/dist/handlers/rest/file/index.js +0 -53
- package/dist/handlers/rest/file/index.js.map +0 -1
- package/dist/handlers/rest/file/storeFile.d.ts +0 -6
- package/dist/handlers/rest/file/storeFile.js +0 -44
- package/dist/handlers/rest/file/storeFile.js.map +0 -1
- package/dist/handlers/rest/file/stream.d.ts +0 -5
- package/dist/handlers/rest/file/stream.js +0 -105
- package/dist/handlers/rest/file/stream.js.map +0 -1
- package/dist/handlers/rest/file/types.d.ts +0 -9
- package/dist/handlers/rest/file/types.js.map +0 -1
- package/dist/handlers/rest/getReqMessage.d.ts +0 -3
- package/dist/handlers/rest/getReqMessage.js +0 -92
- package/dist/handlers/rest/getReqMessage.js.map +0 -1
- package/dist/handlers/rest/index.d.ts +0 -4
- package/dist/handlers/rest/index.js +0 -121
- package/dist/handlers/rest/index.js.map +0 -1
- package/dist/handlers/rest/invalidReq.d.ts +0 -4
- package/dist/handlers/rest/invalidReq.js +0 -20
- package/dist/handlers/rest/invalidReq.js.map +0 -1
- package/dist/handlers/rest/parseResponse.d.ts +0 -6
- package/dist/handlers/rest/parseResponse.js +0 -230
- package/dist/handlers/rest/parseResponse.js.map +0 -1
- package/dist/handlers/rest/playground/index.d.ts +0 -5
- package/dist/handlers/rest/playground/index.js +0 -308
- package/dist/handlers/rest/playground/index.js.map +0 -1
- package/dist/handlers/rest/readBody.d.ts +0 -3
- package/dist/handlers/rest/readBody.js +0 -45
- package/dist/handlers/rest/readBody.js.map +0 -1
- package/dist/handlers/set/index.d.ts +0 -5
- package/dist/handlers/set/index.js +0 -20
- package/dist/handlers/set/index.js.map +0 -1
- package/dist/handlers/subscription/index.d.ts +0 -32
- package/dist/handlers/subscription/index.js +0 -223
- package/dist/handlers/subscription/index.js.map +0 -1
- package/dist/handlers/token.d.ts +0 -5
- package/dist/handlers/token.js +0 -122
- package/dist/handlers/token.js.map +0 -1
- package/dist/handlers/track/index.d.ts +0 -7
- package/dist/handlers/track/index.js +0 -102
- package/dist/handlers/track/index.js.map +0 -1
- package/dist/handlers/userAuth/index.d.ts +0 -5
- package/dist/handlers/userAuth/index.js +0 -78
- package/dist/handlers/userAuth/index.js.map +0 -1
- package/dist/network/http/authorize.d.ts +0 -3
- package/dist/network/http/authorize.js +0 -28
- package/dist/network/http/authorize.js.map +0 -1
- package/dist/network/http/compress.d.ts +0 -6
- package/dist/network/http/compress.js.map +0 -1
- package/dist/network/http/end.d.ts +0 -4
- package/dist/network/http/end.js +0 -19
- package/dist/network/http/end.js.map +0 -1
- package/dist/network/http/function.d.ts +0 -3
- package/dist/network/http/function.js.map +0 -1
- package/dist/network/http/get.d.ts +0 -3
- package/dist/network/http/get.js +0 -129
- package/dist/network/http/get.js.map +0 -1
- package/dist/network/http/index.js +0 -122
- package/dist/network/http/index.js.map +0 -1
- package/dist/network/http/readBody.d.ts +0 -3
- package/dist/network/http/readBody.js.map +0 -1
- package/dist/network/http/send.d.ts +0 -5
- package/dist/network/http/send.js +0 -60
- package/dist/network/http/send.js.map +0 -1
- package/dist/network/http/streamFunction/DataStream.d.ts +0 -7
- package/dist/network/http/streamFunction/DataStream.js.map +0 -1
- package/dist/network/http/streamFunction/getExtension.js.map +0 -1
- package/dist/network/http/streamFunction/index.d.ts +0 -3
- package/dist/network/http/streamFunction/index.js +0 -81
- package/dist/network/http/streamFunction/index.js.map +0 -1
- package/dist/network/http/streamFunction/multipartStream.d.ts +0 -12
- package/dist/network/http/streamFunction/multipartStream.js.map +0 -1
- package/dist/network/http/streamFunction/stream.js.map +0 -1
- package/dist/network/index.d.ts +0 -4
- package/dist/network/index.js.map +0 -1
- package/dist/network/message/auth.d.ts +0 -4
- package/dist/network/message/auth.js +0 -32
- package/dist/network/message/auth.js.map +0 -1
- package/dist/network/message/function.d.ts +0 -3
- package/dist/network/message/function.js +0 -67
- package/dist/network/message/function.js.map +0 -1
- package/dist/network/message/get.d.ts +0 -3
- package/dist/network/message/get.js +0 -109
- package/dist/network/message/get.js.map +0 -1
- package/dist/network/message/index.d.ts +0 -3
- package/dist/network/message/index.js.map +0 -1
- package/dist/network/message/observable.d.ts +0 -5
- package/dist/network/message/observable.js +0 -103
- package/dist/network/message/observable.js.map +0 -1
- package/dist/network/message/send.d.ts +0 -4
- package/dist/network/message/send.js +0 -11
- package/dist/network/message/send.js.map +0 -1
- package/dist/network/upgrade.d.ts +0 -4
- package/dist/network/upgrade.js.map +0 -1
- package/dist/network/worker/get.d.ts +0 -0
- package/dist/network/worker/get.js +0 -122
- package/dist/network/worker/get.js.map +0 -1
- package/dist/network/worker/observable.d.ts +0 -0
- package/dist/network/worker/observable.js +0 -120
- package/dist/network/worker/observable.js.map +0 -1
- package/dist/openListener.d.ts +0 -4
- package/dist/openListener.js +0 -13
- package/dist/openListener.js.map +0 -1
- package/dist/secrets.d.ts +0 -9
- package/dist/secrets.js +0 -150
- package/dist/secrets.js.map +0 -1
- package/dist/security/index.d.ts +0 -2
- package/dist/security/index.js +0 -57
- package/dist/security/index.js.map +0 -1
- package/dist/types.d.ts +0 -129
- package/dist/types.js +0 -17
- package/dist/types.js.map +0 -1
- package/dist/upgradeListener.d.ts +0 -4
- package/dist/upgradeListener.js +0 -47
- package/dist/upgradeListener.js.map +0 -1
- package/dist/worker/authorize.d.ts +0 -5
- package/dist/worker/authorize.js +0 -15
- package/dist/worker/authorize.js.map +0 -1
- package/dist/worker/fnMap.d.ts +0 -2
- package/dist/worker/fnMap.js +0 -5
- package/dist/worker/fnMap.js.map +0 -1
- package/dist/worker/functions.d.ts +0 -3
- package/dist/worker/functions.js +0 -8
- package/dist/worker/functions.js.map +0 -1
- package/dist/worker/http/function.d.ts +0 -4
- package/dist/worker/http/function.js +0 -75
- package/dist/worker/http/function.js.map +0 -1
- package/dist/worker/index.d.ts +0 -1
- package/dist/worker/index.js +0 -101
- package/dist/worker/index.js.map +0 -1
- package/dist/worker/observable.d.ts +0 -15
- package/dist/worker/observable.js +0 -110
- package/dist/worker/observable.js.map +0 -1
- package/dist/worker/ws/function.d.ts +0 -3
- package/dist/worker/ws/function.js +0 -42
- package/dist/worker/ws/function.js.map +0 -1
- package/dist/workers/index.d.ts +0 -0
- package/dist/workers/index.js +0 -20
- package/dist/workers/index.js.map +0 -1
- package/dist/workers/workerCode.d.ts +0 -12
- package/dist/workers/workerCode.js +0 -46
- package/dist/workers/workerCode.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
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AE,MAAM,EAAE,MAAM,CAAC,EAAE;QACzE,OAAO,IAAI,CAAA;KACZ;IAED,mBAAmB;IACnB,+DAA+D;AACjE,CAAC,CAAA;AAEM,MAAM,OAAO,GAAG,CACrB,MAAmB,EACnB,MAAuB,EACvB,GAAgB,EAChB,QAAiB,EACjB,EAAE;IACF,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE;QACd,OAAM;KACP;IAED,IAAI,CAAC,QAAQ,EAAE;QACb,IAAA,mBAAW,EAAC,MAAM,EAAE,MAAM,EAAE,sBAAc,CAAC,gBAAgB,EAAE,GAAG,CAAC,CAAA;QACjE,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,CAAA;QACjB,OAAM;KACP;IAED,iDAAiD;IACjD,MAAM,SAAS,GAAG,IAAI,UAAU,CAAC,GAAG,CAAC,CAAA;IACrC,MAAM,GAAG,GAAG,SAAS,CAAC,MAAM,CAAA;IAC5B,IAAI,IAAI,GAAG,CAAC,CAAA;IACZ,OAAO,IAAI,GAAG,GAAG,EAAE;QACjB,MAAM,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,CAAC,CAAA;QACjD,IAAI,CAAC,KAAK,SAAS,EAAE;YACnB,iCAAiC;YACjC,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,CAAA;YACjB,OAAM;SACP;QACD,IAAI,GAAG,CAAC,CAAA;KACT;AACH,CAAC,CAAA;AA7BY,QAAA,OAAO,WA6BnB"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { BasedServer } from '../../server';
|
|
2
|
-
import { WebsocketClient, BasedFunctionRoute } from '../../types';
|
|
3
|
-
export declare const enableSubscribe: (server: BasedServer, client: WebsocketClient, id: number, checksum: number, name: string, payload: any, route: BasedFunctionRoute) => void;
|
|
4
|
-
export declare const subscribeMessage: (arr: Uint8Array, start: number, len: number, isDeflate: boolean, client: WebsocketClient, server: BasedServer) => boolean;
|
|
5
|
-
export declare const unsubscribeMessage: (arr: Uint8Array, start: number, client: WebsocketClient, server: BasedServer) => boolean;
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.unsubscribeMessage = exports.subscribeMessage = exports.enableSubscribe = void 0;
|
|
4
|
-
const functions_1 = require("../../functions");
|
|
5
|
-
const protocol_1 = require("../../protocol");
|
|
6
|
-
const observable_1 = require("../../observable");
|
|
7
|
-
const error_1 = require("../../error");
|
|
8
|
-
const send_1 = require("./send");
|
|
9
|
-
const enableSubscribe = (server, client, id, checksum, name, payload, route) => {
|
|
10
|
-
client.ws.subscribe(String(id));
|
|
11
|
-
client.ws.obs.add(id);
|
|
12
|
-
if (server.activeObservablesById.has(id)) {
|
|
13
|
-
(0, observable_1.subscribe)(server, id, checksum, client);
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
server.functions
|
|
17
|
-
.install(name)
|
|
18
|
-
.then((spec) => {
|
|
19
|
-
if (spec && (0, functions_1.isObservableFunctionSpec)(spec)) {
|
|
20
|
-
const obs = (0, observable_1.create)(server, name, id, payload);
|
|
21
|
-
if (!client.ws?.obs.has(id)) {
|
|
22
|
-
if (obs.clients.size === 0) {
|
|
23
|
-
(0, observable_1.destroy)(server, id);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
(0, observable_1.subscribe)(server, id, checksum, client);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
(0, send_1.sendError)(server, client, error_1.BasedErrorCode.FunctionNotFound, route);
|
|
32
|
-
}
|
|
33
|
-
})
|
|
34
|
-
.catch(() => {
|
|
35
|
-
(0, send_1.sendError)(server, client, error_1.BasedErrorCode.FunctionNotFound, route);
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
exports.enableSubscribe = enableSubscribe;
|
|
40
|
-
const subscribeMessage = (arr, start, len, isDeflate, client, server) => {
|
|
41
|
-
// | 4 header | 8 id | 8 checksum | 1 name length | * name | * payload |
|
|
42
|
-
const nameLen = arr[start + 20];
|
|
43
|
-
const id = (0, protocol_1.readUint8)(arr, start + 4, 8);
|
|
44
|
-
const checksum = (0, protocol_1.readUint8)(arr, start + 12, 8);
|
|
45
|
-
const name = (0, protocol_1.decodeName)(arr, start + 21, start + 21 + nameLen);
|
|
46
|
-
if (!name || !id) {
|
|
47
|
-
return false;
|
|
48
|
-
}
|
|
49
|
-
const route = server.functions.route(name);
|
|
50
|
-
if (!route || !route.observable) {
|
|
51
|
-
return false;
|
|
52
|
-
}
|
|
53
|
-
if (route.maxPayloadSize !== -1 && len > route.maxPayloadSize) {
|
|
54
|
-
(0, send_1.sendError)(server, client, error_1.BasedErrorCode.PayloadTooLarge, route);
|
|
55
|
-
return false;
|
|
56
|
-
}
|
|
57
|
-
if (client.ws?.obs.has(id)) {
|
|
58
|
-
// allready subscribed to this id
|
|
59
|
-
return true;
|
|
60
|
-
}
|
|
61
|
-
const payload = (0, protocol_1.decodePayload)(new Uint8Array(arr.slice(start + 21 + nameLen, start + len)), isDeflate);
|
|
62
|
-
server.auth
|
|
63
|
-
.authorize(client.ws, name, payload)
|
|
64
|
-
.then((ok) => {
|
|
65
|
-
if (!client.ws) {
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
if (!ok) {
|
|
69
|
-
client.ws.unauthorizedObs.add({ id, checksum, name, payload });
|
|
70
|
-
(0, send_1.sendError)(server, client, error_1.BasedErrorCode.AuthorizeRejectedError, route);
|
|
71
|
-
return false;
|
|
72
|
-
}
|
|
73
|
-
(0, exports.enableSubscribe)(server, client, id, checksum, name, payload, route);
|
|
74
|
-
})
|
|
75
|
-
.catch((err) => {
|
|
76
|
-
(0, send_1.sendError)(server, client, error_1.BasedErrorCode.AuthorizeFunctionError, {
|
|
77
|
-
route,
|
|
78
|
-
observableId: id,
|
|
79
|
-
err,
|
|
80
|
-
});
|
|
81
|
-
(0, observable_1.destroy)(server, id);
|
|
82
|
-
});
|
|
83
|
-
return true;
|
|
84
|
-
};
|
|
85
|
-
exports.subscribeMessage = subscribeMessage;
|
|
86
|
-
const unsubscribeMessage = (arr, start, client, server) => {
|
|
87
|
-
// | 4 header | 8 id |
|
|
88
|
-
const id = (0, protocol_1.readUint8)(arr, start + 4, 8);
|
|
89
|
-
if (!id) {
|
|
90
|
-
return false;
|
|
91
|
-
}
|
|
92
|
-
if (!client.ws) {
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
if (!client.ws.obs.has(id)) {
|
|
96
|
-
return true;
|
|
97
|
-
}
|
|
98
|
-
client.ws.unsubscribe(String(id));
|
|
99
|
-
(0, observable_1.unsubscribe)(server, id, client);
|
|
100
|
-
return true;
|
|
101
|
-
};
|
|
102
|
-
exports.unsubscribeMessage = unsubscribeMessage;
|
|
103
|
-
//# sourceMappingURL=observable.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"observable.js","sourceRoot":"","sources":["../../../src/network/message/observable.ts"],"names":[],"mappings":";;;AAAA,+CAA0D;AAC1D,6CAAqE;AAErE,iDAA0E;AAC1E,uCAA4C;AAC5C,iCAAkC;AAG3B,MAAM,eAAe,GAAG,CAC7B,MAAmB,EACnB,MAAuB,EACvB,EAAU,EACV,QAAgB,EAChB,IAAY,EACZ,OAAY,EACZ,KAAyB,EACzB,EAAE;IACF,MAAM,CAAC,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAA;IAC/B,MAAM,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;IAErB,IAAI,MAAM,CAAC,qBAAqB,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;QACxC,IAAA,sBAAS,EAAC,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAA;KACxC;SAAM;QACL,MAAM,CAAC,SAAS;aACb,OAAO,CAAC,IAAI,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
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { BasedErrorCode, ErrorPayload } from '../../error';
|
|
2
|
-
import { WebsocketClient } from '../../types';
|
|
3
|
-
import { BasedServer } from '../../server';
|
|
4
|
-
export declare const sendError: (server: BasedServer, client: WebsocketClient, basedCode: BasedErrorCode, err?: ErrorPayload[BasedErrorCode]) => void;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.sendError = void 0;
|
|
4
|
-
const protocol_1 = require("../../protocol");
|
|
5
|
-
const error_1 = require("../../error");
|
|
6
|
-
const sendError = (server, client, basedCode, err) => {
|
|
7
|
-
const errorData = (0, error_1.createError)(server, client, basedCode, err);
|
|
8
|
-
client.ws?.send((0, protocol_1.encodeErrorResponse)((0, protocol_1.valueToBuffer)(errorData)), true, false);
|
|
9
|
-
};
|
|
10
|
-
exports.sendError = sendError;
|
|
11
|
-
//# sourceMappingURL=send.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"send.js","sourceRoot":"","sources":["../../../src/network/message/send.ts"],"names":[],"mappings":";;;AAAA,6CAAmE;AACnE,uCAAuE;AAIhE,MAAM,SAAS,GAAG,CACvB,MAAmB,EACnB,MAAuB,EACvB,SAAyB,EACzB,GAAkC,EAC5B,EAAE;IACR,MAAM,SAAS,GAAG,IAAA,mBAAW,EAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,CAAC,CAAA;IAC7D,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,IAAA,8BAAmB,EAAC,IAAA,wBAAa,EAAC,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,CAAA;AAC7E,CAAC,CAAA;AARY,QAAA,SAAS,aAQrB"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import uws from '@based/uws';
|
|
2
|
-
import { AuthorizeConnection } from '../types';
|
|
3
|
-
export declare const upgrade: (res: uws.HttpResponse, req: uws.HttpRequest, ctx: uws.us_socket_context_t) => void;
|
|
4
|
-
export declare const upgradeAuthorize: (authorizeConnection: AuthorizeConnection, res: uws.HttpResponse, req: uws.HttpRequest, ctx: uws.us_socket_context_t) => void;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"upgrade.js","sourceRoot":"","sources":["../../src/network/upgrade.ts"],"names":[],"mappings":";;;AAGA,IAAI,QAAQ,GAAG,CAAC,CAAA;AAEhB,oCAAoC;AAE7B,MAAM,OAAO,GAAG,CACrB,GAAqB,EACrB,GAAoB;AACpB,2BAA2B;AAC3B,GAA4B,EAC5B,EAAE;IACF,MAAM,KAAK,GAAG,GAAG,CAAC,QAAQ,EAAE,CAAA,CAAC,SAAS;IACtC,MAAM,EAAE,GAAG,GAAG,CAAC,SAAS,CAAC,YAAY,CAAC,CAAA;IAEtC,MAAM,EAAE,GACN,GAAG,CAAC,SAAS,CAAC,iBAAiB,CAAC;QAChC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,sBAAsB,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAA;IACtD,MAAM,eAAe,GAAG,GAAG,CAAC,SAAS,CAAC,mBAAmB,CAAC,CAAA;IAC1D,MAAM,oBAAoB,GAAG,GAAG,CAAC,SAAS,CAAC,wBAAwB,CAAC,CAAA;IACpE,MAAM,sBAAsB,GAAG,GAAG,CAAC,SAAS,CAAC,0BAA0B,CAAC,CAAA;IAExE,GAAG,CAAC,WAAW,CAAC,yBAAyB,CAAC,CAAA;IAE1C,GAAG,CAAC,OAAO,CACT;QACE,KAAK;QACL,EAAE;QACF,EAAE;QACF,EAAE,EAAE,EAAE,QAAQ;QACd,GAAG,EAAE,IAAI,GAAG,EAAE;QACd,eAAe,EAAE,IAAI,GAAG,EAAE;QAC1B,OAAO,EAAE,EAAE,EAAE,wCAAwC;KACtD,EACD,eAAe,EACf,oBAAoB,EACpB,sBAAsB,EACtB,GAAG,CACJ,CAAA;AACH,CAAC,CAAA;AAjCY,QAAA,OAAO,WAiCnB;AAEM,MAAM,gBAAgB,GAAG,CAC9B,mBAAwC,EACxC,GAAqB,EACrB,GAAoB;AACpB,2BAA2B;AAC3B,GAA4B,EAC5B,EAAE;IACF,IAAI,OAAO,GAAG,KAAK,CAAA;IACnB,GAAG,CAAC,SAAS,CAAC,GAAG,EAAE;QACjB,OAAO,GAAG,IAAI,CAAA;IAChB,CAAC,CAAC,CAAA;IACF,mBAAmB,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE;QAC3C,IAAI,OAAO,EAAE;YACX,OAAM;SACP;QACD,IAAI,UAAU,EAAE;YACd,IAAA,eAAO,EAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAA;SACvB;aAAM;YACL,GAAG,CAAC,WAAW,CAAC,kBAAkB,CAAC,CAAA;YACnC,GAAG,CAAC,GAAG,EAAE,CAAA;SACV;IACH,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA;AAtBY,QAAA,gBAAgB,oBAsB5B"}
|
|
File without changes
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
// import { isObservableFunctionSpec } from '../../functions'
|
|
2
|
-
// import {
|
|
3
|
-
// decodePayload,
|
|
4
|
-
// decodeName,
|
|
5
|
-
// readUint8,
|
|
6
|
-
// encodeGetResponse,
|
|
7
|
-
// } from '../../protocol'
|
|
8
|
-
// import { BasedServer } from '../../server'
|
|
9
|
-
// import { create, destroy } from '../../observable'
|
|
10
|
-
// import { ActiveObservable, WebsocketClient } from '../../types'
|
|
11
|
-
// import { BasedErrorCode } from '../../error'
|
|
12
|
-
// // import { sendError } from './send'
|
|
13
|
-
// const sendGetData = (
|
|
14
|
-
// server: BasedServer,
|
|
15
|
-
// id: number,
|
|
16
|
-
// obs: ActiveObservable,
|
|
17
|
-
// checksum: number,
|
|
18
|
-
// client: WebsocketClient
|
|
19
|
-
// ) => {
|
|
20
|
-
// if (!client.ws) {
|
|
21
|
-
// return
|
|
22
|
-
// }
|
|
23
|
-
// if (checksum === 0) {
|
|
24
|
-
// client.ws.send(obs.cache, true, false)
|
|
25
|
-
// } else if (checksum === obs.checksum) {
|
|
26
|
-
// client.ws.send(encodeGetResponse(id), true, false)
|
|
27
|
-
// } else if (obs.diffCache && obs.previousChecksum === checksum) {
|
|
28
|
-
// client.ws.send(obs.diffCache, true, false)
|
|
29
|
-
// } else {
|
|
30
|
-
// client.ws.send(obs.cache, true, false)
|
|
31
|
-
// }
|
|
32
|
-
// if (obs.clients.size === 0) {
|
|
33
|
-
// destroy(server, id)
|
|
34
|
-
// }
|
|
35
|
-
// }
|
|
36
|
-
// export const getMessage = (
|
|
37
|
-
// arr: Uint8Array,
|
|
38
|
-
// start: number,
|
|
39
|
-
// len: number,
|
|
40
|
-
// isDeflate: boolean,
|
|
41
|
-
// client: WebsocketClient,
|
|
42
|
-
// server: BasedServer
|
|
43
|
-
// ) => {
|
|
44
|
-
// // | 4 header | 8 id | 8 checksum | 1 name length | * name | * payload |
|
|
45
|
-
// const nameLen = arr[start + 20]
|
|
46
|
-
// const id = readUint8(arr, start + 4, 8)
|
|
47
|
-
// const checksum = readUint8(arr, start + 12, 8)
|
|
48
|
-
// const name = decodeName(arr, start + 21, start + 21 + nameLen)
|
|
49
|
-
// if (!name || !id) {
|
|
50
|
-
// return false
|
|
51
|
-
// }
|
|
52
|
-
// const route = server.functions.route(name)
|
|
53
|
-
// if (!route || !route.observable) {
|
|
54
|
-
// return false
|
|
55
|
-
// }
|
|
56
|
-
// if (route.maxPayloadSize !== -1 && len > route.maxPayloadSize) {
|
|
57
|
-
// sendError(server, client, BasedErrorCode.PayloadTooLarge, route)
|
|
58
|
-
// return false
|
|
59
|
-
// }
|
|
60
|
-
// const payload = decodePayload(
|
|
61
|
-
// new Uint8Array(arr.slice(start + 21 + nameLen, start + len)),
|
|
62
|
-
// isDeflate
|
|
63
|
-
// )
|
|
64
|
-
// server.auth.config
|
|
65
|
-
// .authorize(server, client, name, payload)
|
|
66
|
-
// .then((ok) => {
|
|
67
|
-
// if (!client.ws) {
|
|
68
|
-
// return false
|
|
69
|
-
// }
|
|
70
|
-
// if (!ok) {
|
|
71
|
-
// sendError(server, client, BasedErrorCode.AuthorizeRejectedError, route)
|
|
72
|
-
// return false
|
|
73
|
-
// }
|
|
74
|
-
// if (server.activeObservablesById.has(id)) {
|
|
75
|
-
// const obs = server.activeObservablesById.get(id)
|
|
76
|
-
// if (obs.beingDestroyed) {
|
|
77
|
-
// clearTimeout(obs.beingDestroyed)
|
|
78
|
-
// obs.beingDestroyed = null
|
|
79
|
-
// }
|
|
80
|
-
// if (obs.cache) {
|
|
81
|
-
// sendGetData(server, id, obs, checksum, client)
|
|
82
|
-
// } else {
|
|
83
|
-
// if (!obs.onNextData) {
|
|
84
|
-
// obs.onNextData = new Set()
|
|
85
|
-
// }
|
|
86
|
-
// obs.onNextData.add(() => {
|
|
87
|
-
// sendGetData(server, id, obs, checksum, client)
|
|
88
|
-
// })
|
|
89
|
-
// }
|
|
90
|
-
// } else {
|
|
91
|
-
// server.functions
|
|
92
|
-
// .install(name)
|
|
93
|
-
// .then((spec) => {
|
|
94
|
-
// if (spec && isObservableFunctionSpec(spec)) {
|
|
95
|
-
// const obs = create(server, name, id, payload)
|
|
96
|
-
// if (!client.ws?.obs.has(id)) {
|
|
97
|
-
// if (!obs.onNextData) {
|
|
98
|
-
// obs.onNextData = new Set()
|
|
99
|
-
// }
|
|
100
|
-
// obs.onNextData.add(() => {
|
|
101
|
-
// sendGetData(server, id, obs, checksum, client)
|
|
102
|
-
// })
|
|
103
|
-
// }
|
|
104
|
-
// } else {
|
|
105
|
-
// sendError(server, client, BasedErrorCode.FunctionNotFound, route)
|
|
106
|
-
// }
|
|
107
|
-
// })
|
|
108
|
-
// .catch(() => {
|
|
109
|
-
// sendError(server, client, BasedErrorCode.FunctionNotFound, route)
|
|
110
|
-
// })
|
|
111
|
-
// }
|
|
112
|
-
// })
|
|
113
|
-
// .catch((err) => {
|
|
114
|
-
// sendError(server, client, BasedErrorCode.AuthorizeFunctionError, {
|
|
115
|
-
// route,
|
|
116
|
-
// observableId: id,
|
|
117
|
-
// err,
|
|
118
|
-
// })
|
|
119
|
-
// })
|
|
120
|
-
// return true
|
|
121
|
-
// }
|
|
122
|
-
//# sourceMappingURL=get.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"get.js","sourceRoot":"","sources":["../../../src/network/worker/get.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,WAAW;AACX,mBAAmB;AACnB,gBAAgB;AAChB,eAAe;AACf,uBAAuB;AACvB,0BAA0B;AAC1B,6CAA6C;AAC7C,qDAAqD;AACrD,kEAAkE;AAClE,+CAA+C;AAC/C,wCAAwC;AAExC,wBAAwB;AACxB,yBAAyB;AACzB,gBAAgB;AAChB,2BAA2B;AAC3B,sBAAsB;AACtB,4BAA4B;AAC5B,SAAS;AACT,sBAAsB;AACtB,aAAa;AACb,MAAM;AAEN,0BAA0B;AAC1B,6CAA6C;AAC7C,4CAA4C;AAC5C,yDAAyD;AACzD,qEAAqE;AACrE,iDAAiD;AACjD,aAAa;AACb,6CAA6C;AAC7C,MAAM;AAEN,kCAAkC;AAClC,0BAA0B;AAC1B,MAAM;AACN,IAAI;AAEJ,8BAA8B;AAC9B,qBAAqB;AACrB,mBAAmB;AACnB,iBAAiB;AACjB,wBAAwB;AACxB,6BAA6B;AAC7B,wBAAwB;AACxB,SAAS;AACT,6EAA6E;AAE7E,oCAAoC;AAEpC,4CAA4C;AAC5C,mDAAmD;AACnD,mEAAmE;AAEnE,wBAAwB;AACxB,mBAAmB;AACnB,MAAM;AAEN,+CAA+C;AAE/C,uCAAuC;AACvC,mBAAmB;AACnB,MAAM;AAEN,qEAAqE;AACrE,uEAAuE;AACvE,mBAAmB;AACnB,MAAM;AAEN,mCAAmC;AACnC,oEAAoE;AACpE,gBAAgB;AAChB,MAAM;AAEN,uBAAuB;AACvB,gDAAgD;AAChD,sBAAsB;AACtB,0BAA0B;AAC1B,uBAAuB;AACvB,UAAU;AAEV,mBAAmB;AACnB,kFAAkF;AAClF,uBAAuB;AACvB,UAAU;AAEV,oDAAoD;AACpD,2DAA2D;AAC3D,oCAAoC;AACpC,6CAA6C;AAC7C,sCAAsC;AACtC,YAAY;AACZ,2BAA2B;AAC3B,2DAA2D;AAC3D,mBAAmB;AACnB,mCAAmC;AACnC,yCAAyC;AACzC,cAAc;AACd,uCAAuC;AACvC,6DAA6D;AAC7D,eAAe;AACf,YAAY;AACZ,iBAAiB;AACjB,2BAA2B;AAC3B,2BAA2B;AAC3B,8BAA8B;AAC9B,4DAA4D;AAC5D,8DAA8D;AAC9D,+CAA+C;AAC/C,yCAAyC;AACzC,+CAA+C;AAC/C,oBAAoB;AACpB,6CAA6C;AAC7C,mEAAmE;AACnE,qBAAqB;AACrB,kBAAkB;AAClB,uBAAuB;AACvB,kFAAkF;AAClF,gBAAgB;AAChB,eAAe;AACf,2BAA2B;AAC3B,gFAAgF;AAChF,eAAe;AACf,UAAU;AACV,SAAS;AACT,wBAAwB;AACxB,2EAA2E;AAC3E,iBAAiB;AACjB,4BAA4B;AAC5B,eAAe;AACf,WAAW;AACX,SAAS;AAET,gBAAgB;AAChB,IAAI"}
|
|
File without changes
|
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
// import { isObservableFunctionSpec } from '../../functions'
|
|
2
|
-
// import { decodePayload, decodeName, readUint8 } from '../../protocol'
|
|
3
|
-
// import { BasedServer } from '../../server'
|
|
4
|
-
// import { create, unsubscribe, destroy, subscribe } from '../../observable'
|
|
5
|
-
// import { BasedErrorCode } from '../../error'
|
|
6
|
-
// import { sendError } from '../message/send'
|
|
7
|
-
// import { WebsocketClient, BasedFunctionRoute } from '../../types'
|
|
8
|
-
// gets worker (and client context)
|
|
9
|
-
// export const enableSubscribe = (
|
|
10
|
-
// server: BasedServer,
|
|
11
|
-
// client: WebsocketClient,
|
|
12
|
-
// id: number,
|
|
13
|
-
// checksum: number,
|
|
14
|
-
// name: string,
|
|
15
|
-
// payload: any,
|
|
16
|
-
// route: BasedFunctionRoute
|
|
17
|
-
// ) => {
|
|
18
|
-
// client.ws.subscribe(String(id))
|
|
19
|
-
// client.ws.obs.add(id)
|
|
20
|
-
// if (server.activeObservablesById.has(id)) {
|
|
21
|
-
// subscribe(server, id, checksum, client)
|
|
22
|
-
// } else {
|
|
23
|
-
// server.functions
|
|
24
|
-
// .install(name)
|
|
25
|
-
// .then((spec) => {
|
|
26
|
-
// if (spec && isObservableFunctionSpec(spec)) {
|
|
27
|
-
// const obs = create(server, name, id, payload)
|
|
28
|
-
// if (!client.ws?.obs.has(id)) {
|
|
29
|
-
// if (obs.clients.size === 0) {
|
|
30
|
-
// destroy(server, id)
|
|
31
|
-
// }
|
|
32
|
-
// } else {
|
|
33
|
-
// subscribe(server, id, checksum, client)
|
|
34
|
-
// }
|
|
35
|
-
// } else {
|
|
36
|
-
// sendError(server, client, BasedErrorCode.FunctionNotFound, route)
|
|
37
|
-
// }
|
|
38
|
-
// })
|
|
39
|
-
// .catch(() => {
|
|
40
|
-
// sendError(server, client, BasedErrorCode.FunctionNotFound, route)
|
|
41
|
-
// })
|
|
42
|
-
// }
|
|
43
|
-
// }
|
|
44
|
-
// export const subscribeMessage = (
|
|
45
|
-
// arr: Uint8Array,
|
|
46
|
-
// start: number,
|
|
47
|
-
// len: number,
|
|
48
|
-
// isDeflate: boolean,
|
|
49
|
-
// client: WebsocketClient,
|
|
50
|
-
// server: BasedServer
|
|
51
|
-
// ) => {
|
|
52
|
-
// // | 4 header | 8 id | 8 checksum | 1 name length | * name | * payload |
|
|
53
|
-
// const nameLen = arr[start + 20]
|
|
54
|
-
// const id = readUint8(arr, start + 4, 8)
|
|
55
|
-
// const checksum = readUint8(arr, start + 12, 8)
|
|
56
|
-
// const name = decodeName(arr, start + 21, start + 21 + nameLen)
|
|
57
|
-
// if (!name || !id) {
|
|
58
|
-
// return false
|
|
59
|
-
// }
|
|
60
|
-
// const route = server.functions.route(name)
|
|
61
|
-
// if (!route || !route.observable) {
|
|
62
|
-
// return false
|
|
63
|
-
// }
|
|
64
|
-
// if (route.maxPayloadSize !== -1 && len > route.maxPayloadSize) {
|
|
65
|
-
// sendError(server, client, BasedErrorCode.PayloadTooLarge, route)
|
|
66
|
-
// return false
|
|
67
|
-
// }
|
|
68
|
-
// if (client.ws?.obs.has(id)) {
|
|
69
|
-
// // allready subscribed to this id
|
|
70
|
-
// return true
|
|
71
|
-
// }
|
|
72
|
-
// const payload = decodePayload(
|
|
73
|
-
// new Uint8Array(arr.slice(start + 21 + nameLen, start + len)),
|
|
74
|
-
// isDeflate
|
|
75
|
-
// )
|
|
76
|
-
// server.auth.config
|
|
77
|
-
// .authorize(server, client, name, payload)
|
|
78
|
-
// .then((ok) => {
|
|
79
|
-
// if (!client.ws) {
|
|
80
|
-
// return
|
|
81
|
-
// }
|
|
82
|
-
// if (!ok) {
|
|
83
|
-
// client.ws.unauthorizedObs.add({ id, checksum, name, payload })
|
|
84
|
-
// sendError(server, client, BasedErrorCode.AuthorizeRejectedError, route)
|
|
85
|
-
// return false
|
|
86
|
-
// }
|
|
87
|
-
// enableSubscribe(server, client, id, checksum, name, payload, route)
|
|
88
|
-
// })
|
|
89
|
-
// .catch((err) => {
|
|
90
|
-
// sendError(server, client, BasedErrorCode.AuthorizeFunctionError, {
|
|
91
|
-
// route,
|
|
92
|
-
// observableId: id,
|
|
93
|
-
// err,
|
|
94
|
-
// })
|
|
95
|
-
// destroy(server, id)
|
|
96
|
-
// })
|
|
97
|
-
// return true
|
|
98
|
-
// }
|
|
99
|
-
// export const unsubscribeMessage = (
|
|
100
|
-
// arr: Uint8Array,
|
|
101
|
-
// start: number,
|
|
102
|
-
// client: WebsocketClient,
|
|
103
|
-
// server: BasedServer
|
|
104
|
-
// ) => {
|
|
105
|
-
// // | 4 header | 8 id |
|
|
106
|
-
// const id = readUint8(arr, start + 4, 8)
|
|
107
|
-
// if (!id) {
|
|
108
|
-
// return false
|
|
109
|
-
// }
|
|
110
|
-
// if (!client.ws) {
|
|
111
|
-
// return
|
|
112
|
-
// }
|
|
113
|
-
// if (!client.ws.obs.has(id)) {
|
|
114
|
-
// return true
|
|
115
|
-
// }
|
|
116
|
-
// client.ws.unsubscribe(String(id))
|
|
117
|
-
// unsubscribe(server, id, client)
|
|
118
|
-
// return true
|
|
119
|
-
// }
|
|
120
|
-
//# sourceMappingURL=observable.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"observable.js","sourceRoot":"","sources":["../../../src/network/worker/observable.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,wEAAwE;AACxE,6CAA6C;AAC7C,6EAA6E;AAC7E,+CAA+C;AAC/C,8CAA8C;AAC9C,oEAAoE;AAEpE,mCAAmC;AAEnC,mCAAmC;AACnC,yBAAyB;AACzB,6BAA6B;AAC7B,gBAAgB;AAChB,sBAAsB;AACtB,kBAAkB;AAClB,kBAAkB;AAClB,8BAA8B;AAC9B,SAAS;AACT,oCAAoC;AACpC,0BAA0B;AAE1B,gDAAgD;AAChD,8CAA8C;AAC9C,aAAa;AACb,uBAAuB;AACvB,uBAAuB;AACvB,0BAA0B;AAC1B,wDAAwD;AACxD,0DAA0D;AAC1D,2CAA2C;AAC3C,4CAA4C;AAC5C,oCAAoC;AACpC,gBAAgB;AAChB,qBAAqB;AACrB,sDAAsD;AACtD,cAAc;AACd,mBAAmB;AACnB,8EAA8E;AAC9E,YAAY;AACZ,WAAW;AACX,uBAAuB;AACvB,4EAA4E;AAC5E,WAAW;AACX,MAAM;AACN,IAAI;AAEJ,oCAAoC;AACpC,qBAAqB;AACrB,mBAAmB;AACnB,iBAAiB;AACjB,wBAAwB;AACxB,6BAA6B;AAC7B,wBAAwB;AACxB,SAAS;AACT,6EAA6E;AAE7E,oCAAoC;AAEpC,4CAA4C;AAC5C,mDAAmD;AACnD,mEAAmE;AAEnE,wBAAwB;AACxB,mBAAmB;AACnB,MAAM;AAEN,+CAA+C;AAE/C,uCAAuC;AACvC,mBAAmB;AACnB,MAAM;AAEN,qEAAqE;AACrE,uEAAuE;AACvE,mBAAmB;AACnB,MAAM;AAEN,kCAAkC;AAClC,wCAAwC;AACxC,kBAAkB;AAClB,MAAM;AAEN,mCAAmC;AACnC,oEAAoE;AACpE,gBAAgB;AAChB,MAAM;AAEN,uBAAuB;AACvB,gDAAgD;AAChD,sBAAsB;AACtB,0BAA0B;AAC1B,iBAAiB;AACjB,UAAU;AAEV,mBAAmB;AACnB,yEAAyE;AACzE,kFAAkF;AAClF,uBAAuB;AACvB,UAAU;AAEV,4EAA4E;AAC5E,SAAS;AACT,wBAAwB;AACxB,2EAA2E;AAC3E,iBAAiB;AACjB,4BAA4B;AAC5B,eAAe;AACf,WAAW;AACX,4BAA4B;AAC5B,SAAS;AAET,gBAAgB;AAChB,IAAI;AAEJ,sCAAsC;AACtC,qBAAqB;AACrB,mBAAmB;AACnB,6BAA6B;AAC7B,wBAAwB;AACxB,SAAS;AACT,2BAA2B;AAE3B,4CAA4C;AAE5C,eAAe;AACf,mBAAmB;AACnB,MAAM;AAEN,sBAAsB;AACtB,aAAa;AACb,MAAM;AAEN,kCAAkC;AAClC,kBAAkB;AAClB,MAAM;AAEN,sCAAsC;AAEtC,oCAAoC;AAEpC,gBAAgB;AAChB,IAAI"}
|
package/dist/openListener.d.ts
DELETED
package/dist/openListener.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const Client_1 = __importDefault(require("./Client"));
|
|
7
|
-
const open = (server, socket) => {
|
|
8
|
-
const client = new Client_1.default(server, socket);
|
|
9
|
-
server.clients[client.id] = client;
|
|
10
|
-
server.emit('open', client);
|
|
11
|
-
};
|
|
12
|
-
exports.default = open;
|
|
13
|
-
//# sourceMappingURL=openListener.js.map
|
package/dist/openListener.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"openListener.js","sourceRoot":"","sources":["../src/openListener.ts"],"names":[],"mappings":";;;;;AAEA,sDAA6B;AAE7B,MAAM,IAAI,GAAG,CAAC,MAAmB,EAAE,MAAqB,EAAE,EAAE;IAC1D,MAAM,MAAM,GAAG,IAAI,gBAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACzC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,MAAM,CAAA;IAClC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AAC7B,CAAC,CAAA;AAED,kBAAe,IAAI,CAAA"}
|
package/dist/secrets.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { BasedServer } from '.';
|
|
2
|
-
import { SignOptions } from 'jsonwebtoken';
|
|
3
|
-
export declare const getSecret: (server: BasedServer, secret: string) => Promise<any>;
|
|
4
|
-
export declare const decodeToken: (value: string, publicKey: string) => Promise<any>;
|
|
5
|
-
export declare const encodeValueBySecret: (server: BasedServer, payload: string | object, privateKeySecretOrKey: string | {
|
|
6
|
-
secret?: string;
|
|
7
|
-
key?: string;
|
|
8
|
-
}, type?: 'jwt', signOptions?: SignOptions) => Promise<any>;
|
|
9
|
-
export declare const decodeValueBySecret: (server: BasedServer, value: string, publicKeySecret: string, type?: 'jwt') => Promise<any>;
|
package/dist/secrets.js
DELETED
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.decodeValueBySecret = exports.encodeValueBySecret = exports.decodeToken = exports.getSecret = void 0;
|
|
7
|
-
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
8
|
-
const types_1 = require("@based/types");
|
|
9
|
-
const jwtDecode = (resolve, reject, value, publicKey) => {
|
|
10
|
-
try {
|
|
11
|
-
jsonwebtoken_1.default.verify(value, publicKey,
|
|
12
|
-
// {
|
|
13
|
-
// algorithms: ['RS256'],
|
|
14
|
-
// },
|
|
15
|
-
(err, decoded) => {
|
|
16
|
-
if (err) {
|
|
17
|
-
if (err instanceof jsonwebtoken_1.default.TokenExpiredError) {
|
|
18
|
-
const basedError = new types_1.BasedError('Token expired');
|
|
19
|
-
basedError.code = types_1.BasedErrorCodes.TokenExpired;
|
|
20
|
-
basedError.stack = err.stack;
|
|
21
|
-
reject(basedError);
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
resolve(false);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
resolve(decoded);
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
catch (err) {
|
|
33
|
-
reject(err);
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
const getSecret = async (server, secret) => {
|
|
37
|
-
try {
|
|
38
|
-
let cert = server.config?.secrets?.[secret];
|
|
39
|
-
// can make a thing to update it as well - but later...
|
|
40
|
-
if (server.config?.secretsConfig) {
|
|
41
|
-
if (!server.config.secretsConfig.secretTimeouts) {
|
|
42
|
-
server.config.secretsConfig.secretTimeouts = {};
|
|
43
|
-
}
|
|
44
|
-
if (!cert) {
|
|
45
|
-
cert = await server.config.secretsConfig.getInitial(server, secret);
|
|
46
|
-
if (!cert) {
|
|
47
|
-
return null;
|
|
48
|
-
}
|
|
49
|
-
if (!server.config.secrets) {
|
|
50
|
-
server.config.secrets = {};
|
|
51
|
-
}
|
|
52
|
-
server.config.secretsConfig.secretTimeouts[secret] = 0;
|
|
53
|
-
server.config.secrets[secret] = cert;
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
if (server.config.secretsConfig.secretTimeouts[secret] !== undefined) {
|
|
57
|
-
server.config.secretsConfig.secretTimeouts[secret] = 0;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
return cert || false;
|
|
62
|
-
}
|
|
63
|
-
catch (err) {
|
|
64
|
-
console.warn('Error getting secret (unhandled)', err);
|
|
65
|
-
return false;
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
exports.getSecret = getSecret;
|
|
69
|
-
const cleanCarriageReturn = (value) => typeof value === 'string' ? value.replace(/\n$/, '') : value;
|
|
70
|
-
const decodeToken = (value, publicKey) => {
|
|
71
|
-
return new Promise((resolve, reject) => {
|
|
72
|
-
jwtDecode(resolve, reject, cleanCarriageReturn(value), publicKey);
|
|
73
|
-
});
|
|
74
|
-
};
|
|
75
|
-
exports.decodeToken = decodeToken;
|
|
76
|
-
const encodeValueBySecret = (server, payload, privateKeySecretOrKey, type = 'jwt', signOptions) => {
|
|
77
|
-
return new Promise((resolve, reject) => {
|
|
78
|
-
new Promise((resolve, reject) => {
|
|
79
|
-
if (typeof privateKeySecretOrKey === 'string') {
|
|
80
|
-
resolve((0, exports.getSecret)(server, privateKeySecretOrKey));
|
|
81
|
-
}
|
|
82
|
-
else if (privateKeySecretOrKey.secret) {
|
|
83
|
-
resolve((0, exports.getSecret)(server, privateKeySecretOrKey.secret));
|
|
84
|
-
}
|
|
85
|
-
else if (privateKeySecretOrKey.key) {
|
|
86
|
-
resolve(privateKeySecretOrKey.key);
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
reject(new Error('Need to pass a secret name or a key'));
|
|
90
|
-
}
|
|
91
|
-
})
|
|
92
|
-
.then((privateKey) => {
|
|
93
|
-
if (privateKey) {
|
|
94
|
-
const defaultOptions = {
|
|
95
|
-
expiresIn: '2d',
|
|
96
|
-
algorithm: 'RS256',
|
|
97
|
-
};
|
|
98
|
-
if (type === 'jwt') {
|
|
99
|
-
jsonwebtoken_1.default.sign(payload, privateKey, { ...defaultOptions, ...signOptions }, (err, decoded) => {
|
|
100
|
-
if (err) {
|
|
101
|
-
resolve(false);
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
resolve(decoded);
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
else {
|
|
109
|
-
reject(new Error(`Encode ${type} not implementedd yet`));
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
reject(new Error(`Secret does not exist ${privateKeySecretOrKey}`));
|
|
114
|
-
}
|
|
115
|
-
})
|
|
116
|
-
.catch((err) => {
|
|
117
|
-
reject(err);
|
|
118
|
-
});
|
|
119
|
-
});
|
|
120
|
-
};
|
|
121
|
-
exports.encodeValueBySecret = encodeValueBySecret;
|
|
122
|
-
const decodeValueBySecret = (server, value, publicKeySecret, type = 'jwt') => {
|
|
123
|
-
return new Promise((resolve, reject) => {
|
|
124
|
-
// make this better
|
|
125
|
-
(0, exports.getSecret)(server, publicKeySecret)
|
|
126
|
-
.then((publicKey) => {
|
|
127
|
-
if (publicKey) {
|
|
128
|
-
if (type === 'jwt') {
|
|
129
|
-
try {
|
|
130
|
-
jwtDecode(resolve, reject, cleanCarriageReturn(value), publicKey);
|
|
131
|
-
}
|
|
132
|
-
catch (err) {
|
|
133
|
-
reject(err);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
else {
|
|
137
|
-
console.error(`decode ${type} not implemented yet`);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
else {
|
|
141
|
-
reject(new Error(`Secret does not exist ${publicKeySecret}`));
|
|
142
|
-
}
|
|
143
|
-
})
|
|
144
|
-
.catch((err) => {
|
|
145
|
-
reject(err);
|
|
146
|
-
});
|
|
147
|
-
});
|
|
148
|
-
};
|
|
149
|
-
exports.decodeValueBySecret = decodeValueBySecret;
|
|
150
|
-
//# sourceMappingURL=secrets.js.map
|
package/dist/secrets.js.map
DELETED
|
@@ -1 +0,0 @@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