@based/server 4.0.1 → 4.0.3
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/auth/defaultConfig.d.ts +3 -0
- package/dist/auth/defaultConfig.js +12 -0
- package/dist/auth/defaultConfig.js.map +1 -0
- package/dist/auth/index.d.ts +12 -6
- package/dist/auth/index.js +31 -20
- package/dist/auth/index.js.map +1 -1
- package/dist/auth/parseAuthState.d.ts +2 -1
- package/dist/auth/parseAuthState.js +28 -6
- package/dist/auth/parseAuthState.js.map +1 -1
- package/dist/authorize.d.ts +9 -0
- package/dist/authorize.js +59 -0
- package/dist/authorize.js.map +1 -0
- package/dist/compress.js +3 -0
- package/dist/compress.js.map +1 -1
- package/dist/createSimpleServer.d.ts +20 -10
- package/dist/createSimpleServer.js +64 -53
- package/dist/createSimpleServer.js.map +1 -1
- package/dist/error/errorTypeHandlers.js +31 -12
- package/dist/error/errorTypeHandlers.js.map +1 -1
- package/dist/error/index.d.ts +11 -1
- package/dist/error/index.js +9 -10
- package/dist/error/index.js.map +1 -1
- package/dist/error/types.d.ts +41 -45
- package/dist/error/types.js +3 -1
- package/dist/error/types.js.map +1 -1
- package/dist/functionApi/callFunction copy.d.ts +3 -0
- package/dist/functionApi/callFunction copy.js +29 -0
- package/dist/functionApi/callFunction copy.js.map +1 -0
- package/dist/functionApi/callFunction.d.ts +3 -0
- package/dist/functionApi/callFunction.js +29 -0
- package/dist/functionApi/callFunction.js.map +1 -0
- package/dist/functionApi/client/index.d.ts +17 -0
- package/dist/functionApi/client/index.js +54 -0
- package/dist/functionApi/client/index.js.map +1 -0
- package/dist/functionApi/client/query.d.ts +11 -0
- package/dist/functionApi/client/query.js +32 -0
- package/dist/functionApi/client/query.js.map +1 -0
- package/dist/functionApi/get.d.ts +3 -0
- package/dist/functionApi/get.js +71 -0
- package/dist/functionApi/get.js.map +1 -0
- package/dist/functionApi/index.d.ts +5 -0
- package/dist/functionApi/index.js +25 -0
- package/dist/functionApi/index.js.map +1 -0
- package/dist/functionApi/observe.d.ts +4 -0
- package/dist/functionApi/observe.js +44 -0
- package/dist/functionApi/observe.js.map +1 -0
- package/dist/functionApi/stream.d.ts +3 -0
- package/dist/functionApi/stream.js +30 -0
- package/dist/functionApi/stream.js.map +1 -0
- package/dist/functions/index.d.ts +16 -8
- package/dist/functions/index.js +39 -10
- package/dist/functions/index.js.map +1 -1
- package/dist/functions/timeout.d.ts +3 -3
- package/dist/functions/timeout.js.map +1 -1
- package/dist/functions/types.d.ts +45 -31
- package/dist/functions/types.js +40 -12
- package/dist/functions/types.js.map +1 -1
- package/dist/incoming/http/function.d.ts +3 -4
- package/dist/incoming/http/function.js +29 -35
- package/dist/incoming/http/function.js.map +1 -1
- package/dist/incoming/http/get.d.ts +3 -3
- package/dist/incoming/http/get.js +44 -43
- package/dist/incoming/http/get.js.map +1 -1
- package/dist/incoming/http/index.js +50 -31
- package/dist/incoming/http/index.js.map +1 -1
- package/dist/incoming/http/parseQuery.d.ts +1 -1
- package/dist/incoming/http/parseQuery.js +3 -1
- package/dist/incoming/http/parseQuery.js.map +1 -1
- package/dist/incoming/http/query.d.ts +4 -0
- package/dist/incoming/http/query.js +165 -0
- package/dist/incoming/http/query.js.map +1 -0
- package/dist/incoming/http/readBody.d.ts +4 -3
- package/dist/incoming/http/readBody.js +32 -8
- package/dist/incoming/http/readBody.js.map +1 -1
- package/dist/incoming/http/streamFunction/DataStream.d.ts +8 -0
- package/dist/incoming/http/streamFunction/DataStream.js +42 -3
- package/dist/incoming/http/streamFunction/DataStream.js.map +1 -1
- package/dist/incoming/http/streamFunction/getExtension.d.ts +1 -1
- package/dist/incoming/http/streamFunction/index.d.ts +3 -3
- package/dist/incoming/http/streamFunction/index.js +6 -87
- package/dist/incoming/http/streamFunction/index.js.map +1 -1
- package/dist/incoming/http/streamFunction/multiPart/index.d.ts +4 -0
- package/dist/incoming/http/streamFunction/multiPart/index.js +66 -0
- package/dist/incoming/http/streamFunction/multiPart/index.js.map +1 -0
- package/dist/incoming/http/streamFunction/multiPart/readFormData.d.ts +12 -0
- package/dist/incoming/http/streamFunction/{multipartStream.js → multiPart/readFormData.js} +80 -86
- package/dist/incoming/http/streamFunction/multiPart/readFormData.js.map +1 -0
- package/dist/incoming/http/streamFunction/stream/createStream.d.ts +6 -0
- package/dist/incoming/http/streamFunction/{stream.js → stream/createStream.js} +5 -38
- package/dist/incoming/http/streamFunction/stream/createStream.js.map +1 -0
- package/dist/incoming/http/streamFunction/stream/index.d.ts +4 -0
- package/dist/incoming/http/streamFunction/stream/index.js +70 -0
- package/dist/incoming/http/streamFunction/stream/index.js.map +1 -0
- package/dist/incoming/index.d.ts +1 -1
- package/dist/incoming/index.js +13 -11
- package/dist/incoming/index.js.map +1 -1
- package/dist/incoming/upgrade.js +18 -9
- package/dist/incoming/upgrade.js.map +1 -1
- package/dist/incoming/ws/auth.d.ts +4 -4
- package/dist/incoming/ws/auth.js +37 -19
- package/dist/incoming/ws/auth.js.map +1 -1
- package/dist/incoming/ws/function.d.ts +2 -3
- package/dist/incoming/ws/function.js +21 -73
- package/dist/incoming/ws/function.js.map +1 -1
- package/dist/incoming/ws/get.d.ts +2 -3
- package/dist/incoming/ws/get.js +33 -54
- package/dist/incoming/ws/get.js.map +1 -1
- package/dist/incoming/ws/index.d.ts +1 -1
- package/dist/incoming/ws/index.js +2 -1
- package/dist/incoming/ws/index.js.map +1 -1
- package/dist/incoming/ws/observable.d.ts +7 -6
- package/dist/incoming/ws/observable.js +25 -49
- package/dist/incoming/ws/observable.js.map +1 -1
- package/dist/incoming/ws/types.d.ts +3 -0
- package/dist/{auth → incoming/ws}/types.js +0 -0
- package/dist/{auth → incoming/ws}/types.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/installFn.d.ts +4 -0
- package/dist/installFn.js +94 -0
- package/dist/installFn.js.map +1 -0
- package/dist/observable/create.d.ts +1 -1
- package/dist/observable/create.js +5 -1
- package/dist/observable/create.js.map +1 -1
- package/dist/observable/destroy.js +1 -1
- package/dist/observable/destroy.js.map +1 -1
- package/dist/observable/index.d.ts +0 -1
- package/dist/observable/index.js +0 -1
- package/dist/observable/index.js.map +1 -1
- package/dist/observable/send.d.ts +3 -3
- package/dist/observable/send.js +2 -8
- package/dist/observable/send.js.map +1 -1
- package/dist/observable/start/error.d.ts +2 -1
- package/dist/observable/start/error.js +13 -11
- package/dist/observable/start/error.js.map +1 -1
- package/dist/observable/start/index.js +17 -8
- package/dist/observable/start/index.js.map +1 -1
- package/dist/observable/subscribe.d.ts +3 -3
- package/dist/observable/subscribe.js +6 -12
- package/dist/observable/subscribe.js.map +1 -1
- package/dist/observable/types.d.ts +6 -5
- package/dist/observable/unsub.d.ts +1 -1
- package/dist/observable/unsub.js.map +1 -1
- package/dist/protocol.d.ts +1 -0
- package/dist/protocol.js +11 -1
- package/dist/protocol.js.map +1 -1
- package/dist/security.d.ts +1 -1
- package/dist/security.js +1 -1
- package/dist/security.js.map +1 -1
- package/dist/sendError.d.ts +3 -2
- package/dist/sendError.js +30 -16
- package/dist/sendError.js.map +1 -1
- package/dist/sendHttpResponse.d.ts +3 -2
- package/dist/sendHttpResponse.js +62 -10
- package/dist/sendHttpResponse.js.map +1 -1
- package/dist/server.d.ts +10 -3
- package/dist/server.js +16 -4
- package/dist/server.js.map +1 -1
- package/dist/verifyRoute.d.ts +14 -0
- package/dist/verifyRoute.js +99 -0
- package/dist/verifyRoute.js.map +1 -0
- package/package.json +4 -2
- 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/api/index.d.ts +0 -7
- package/dist/api/index.js +0 -173
- package/dist/api/index.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/auth/dummyAuth.d.ts +0 -2
- package/dist/auth/dummyAuth.js +0 -8
- package/dist/auth/dummyAuth.js.map +0 -1
- package/dist/auth/types.d.ts +0 -10
- 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/context.d.ts +0 -54
- package/dist/context.js +0 -18
- package/dist/context.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.d.ts +0 -7
- 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 -104
- 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 +0 -3
- 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/incoming/http/authorize.d.ts +0 -4
- package/dist/incoming/http/authorize.js +0 -37
- package/dist/incoming/http/authorize.js.map +0 -1
- package/dist/incoming/http/streamFunction/multipartStream.d.ts +0 -13
- package/dist/incoming/http/streamFunction/multipartStream.js.map +0 -1
- package/dist/incoming/http/streamFunction/stream.d.ts +0 -6
- package/dist/incoming/http/streamFunction/stream.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 +0 -56
- 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 +0 -47
- 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.d.ts +0 -3
- 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 +0 -112
- 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 +0 -19
- package/dist/network/http/streamFunction/DataStream.js.map +0 -1
- package/dist/network/http/streamFunction/getExtension.d.ts +0 -2
- package/dist/network/http/streamFunction/getExtension.js +0 -29
- 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 +0 -208
- package/dist/network/http/streamFunction/multipartStream.js.map +0 -1
- package/dist/network/http/streamFunction/stream.d.ts +0 -5
- package/dist/network/http/streamFunction/stream.js +0 -103
- package/dist/network/http/streamFunction/stream.js.map +0 -1
- package/dist/network/index.d.ts +0 -4
- package/dist/network/index.js +0 -84
- 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 +0 -62
- 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 +0 -49
- 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/observable/error.d.ts +0 -4
- package/dist/observable/error.js +0 -17
- package/dist/observable/error.js.map +0 -1
- package/dist/observable/verify.d.ts +0 -4
- package/dist/observable/verify.js +0 -18
- package/dist/observable/verify.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 -3
- package/dist/security/index.js +0 -66
- 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
package/dist/incoming/ws/auth.js
CHANGED
|
@@ -1,40 +1,58 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.sendAndVerifyAuthMessage = exports.authMessage = void 0;
|
|
4
4
|
const protocol_1 = require("../../protocol");
|
|
5
5
|
const observable_1 = require("./observable");
|
|
6
|
-
const auth_1 = require("../../auth");
|
|
7
6
|
const security_1 = require("../../security");
|
|
7
|
+
const sendAuthMessage = (ctx, payload) => ctx.session?.send((0, protocol_1.encodeAuthResponse)((0, protocol_1.valueToBuffer)(payload)), true, false);
|
|
8
|
+
const parse = (payload) => {
|
|
9
|
+
try {
|
|
10
|
+
return JSON.parse(payload);
|
|
11
|
+
}
|
|
12
|
+
catch (err) {
|
|
13
|
+
return { error: 'invalid token' };
|
|
14
|
+
}
|
|
15
|
+
};
|
|
8
16
|
const authMessage = (arr, start, len, isDeflate, ctx, server) => {
|
|
9
|
-
// TODO: Check refresh etc here!
|
|
10
|
-
// TODO: Allow AUTH to be calleed in http to refresh a token
|
|
11
|
-
// include an REQ-ID in the auth request
|
|
12
|
-
// | 4 header | * payload |
|
|
13
|
-
const authPayload = (0, protocol_1.decodePayload)(new Uint8Array(arr.slice(start + 4, start + len)), isDeflate);
|
|
14
|
-
// 10 rate limit tokens for auth (very strange when this gets called often)
|
|
15
17
|
if ((0, security_1.rateLimitRequest)(server, ctx, 10, server.rateLimit.ws)) {
|
|
16
18
|
ctx.session.close();
|
|
17
19
|
return false;
|
|
18
20
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
// | 4 header | * payload |
|
|
22
|
+
const payload = (0, protocol_1.decodePayload)(new Uint8Array(arr.slice(start + 4, start + len)), isDeflate);
|
|
23
|
+
const authState = parse(payload);
|
|
24
|
+
const verified = server.auth.verifyAuthState(server.client, ctx, authState);
|
|
25
|
+
ctx.session.authState = verified === true ? authState : verified;
|
|
26
|
+
if (verified !== true && verified.error) {
|
|
27
|
+
sendAuthMessage(ctx, verified);
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
21
30
|
if (ctx.session.unauthorizedObs.size) {
|
|
22
31
|
ctx.session.unauthorizedObs.forEach((obs) => {
|
|
23
32
|
const { id, name, checksum, payload } = obs;
|
|
24
|
-
(0, observable_1.enableSubscribe)(
|
|
25
|
-
name
|
|
26
|
-
|
|
33
|
+
(0, observable_1.enableSubscribe)({
|
|
34
|
+
name,
|
|
35
|
+
query: true,
|
|
36
|
+
}, server, ctx, payload, id, checksum);
|
|
27
37
|
});
|
|
28
38
|
ctx.session.unauthorizedObs.clear();
|
|
29
39
|
}
|
|
30
|
-
|
|
31
|
-
ctx.session.send((0, protocol_1.encodeAuthResponse)((0, protocol_1.valueToBuffer)(true)), true, false);
|
|
40
|
+
sendAuthMessage(ctx, verified);
|
|
32
41
|
return true;
|
|
33
42
|
};
|
|
34
43
|
exports.authMessage = authMessage;
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
ctx.session
|
|
44
|
+
// send and verify
|
|
45
|
+
const sendAndVerifyAuthMessage = (server, ctx) => {
|
|
46
|
+
if (!ctx.session) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const verified = server.auth.verifyAuthState(server.client, ctx, ctx.session.authState);
|
|
50
|
+
if (verified === true) {
|
|
51
|
+
sendAuthMessage(ctx, true);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
ctx.session.authState = verified;
|
|
55
|
+
sendAuthMessage(ctx, verified);
|
|
38
56
|
};
|
|
39
|
-
exports.
|
|
57
|
+
exports.sendAndVerifyAuthMessage = sendAndVerifyAuthMessage;
|
|
40
58
|
//# sourceMappingURL=auth.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/incoming/ws/auth.ts"],"names":[],"mappings":";;;AAAA,6CAIuB;
|
|
1
|
+
{"version":3,"file":"auth.js","s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,CAAC,CAAA;AAtBY,QAAA,wBAAwB,4BAsBpC"}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
export declare const functionMessage: (arr: Uint8Array, start: number, len: number, isDeflate: boolean, ctx: Context<WebSocketSession>, server: BasedServer) => boolean;
|
|
1
|
+
import { BinaryMessageHandler } from './types';
|
|
2
|
+
export declare const functionMessage: BinaryMessageHandler;
|
|
@@ -4,34 +4,24 @@ exports.functionMessage = void 0;
|
|
|
4
4
|
const protocol_1 = require("../../protocol");
|
|
5
5
|
const error_1 = require("../../error");
|
|
6
6
|
const sendError_1 = require("../../sendError");
|
|
7
|
-
const functions_1 = require("../../functions");
|
|
8
7
|
const security_1 = require("../../security");
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
.function(payload, ctx)
|
|
19
|
-
.then(async (v) => {
|
|
20
|
-
ctx.session?.send((0, protocol_1.encodeFunctionResponse)(requestId, (0, protocol_1.valueToBuffer)(v)), true, false);
|
|
21
|
-
})
|
|
22
|
-
.catch((err) => {
|
|
23
|
-
(0, sendError_1.sendError)(server, ctx, err.code, {
|
|
24
|
-
route,
|
|
25
|
-
requestId,
|
|
26
|
-
err,
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
}
|
|
8
|
+
const verifyRoute_1 = require("../../verifyRoute");
|
|
9
|
+
const installFn_1 = require("../../installFn");
|
|
10
|
+
const authorize_1 = require("../../authorize");
|
|
11
|
+
const sendFunction = async (route, server, ctx, payload, requestId) => {
|
|
12
|
+
const spec = await (0, installFn_1.installFn)(server, ctx, route, requestId);
|
|
13
|
+
spec
|
|
14
|
+
?.function(server.client, payload, ctx)
|
|
15
|
+
.then(async (v) => {
|
|
16
|
+
ctx.session?.send((0, protocol_1.encodeFunctionResponse)(requestId, (0, protocol_1.valueToBuffer)(v)), true, false);
|
|
30
17
|
})
|
|
31
|
-
.catch(() =>
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
18
|
+
.catch((err) => {
|
|
19
|
+
(0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.FunctionError, {
|
|
20
|
+
route,
|
|
21
|
+
requestId,
|
|
22
|
+
err,
|
|
23
|
+
});
|
|
24
|
+
});
|
|
35
25
|
};
|
|
36
26
|
const functionMessage = (arr, start, len, isDeflate, ctx, server) => {
|
|
37
27
|
// | 4 header | 3 id | 1 name length | * name | * payload |
|
|
@@ -41,66 +31,24 @@ const functionMessage = (arr, start, len, isDeflate, ctx, server) => {
|
|
|
41
31
|
if (!name || !requestId) {
|
|
42
32
|
return false;
|
|
43
33
|
}
|
|
44
|
-
const route = server.functions.route(name);
|
|
34
|
+
const route = (0, verifyRoute_1.verifyRoute)(server, ctx, 'fn', server.functions.route(name), name, requestId);
|
|
45
35
|
// TODO: add strictness setting - if strict return false here
|
|
46
|
-
if (
|
|
47
|
-
(0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.FunctionNotFound, {
|
|
48
|
-
name,
|
|
49
|
-
requestId,
|
|
50
|
-
});
|
|
36
|
+
if (route === null) {
|
|
51
37
|
return true;
|
|
52
38
|
}
|
|
53
39
|
if ((0, security_1.rateLimitRequest)(server, ctx, route.rateLimitTokens, server.rateLimit.ws)) {
|
|
54
40
|
ctx.session.close();
|
|
55
41
|
return false;
|
|
56
42
|
}
|
|
57
|
-
if (route.observable === true) {
|
|
58
|
-
(0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.FunctionIsObservable, {
|
|
59
|
-
name,
|
|
60
|
-
requestId,
|
|
61
|
-
});
|
|
62
|
-
return true;
|
|
63
|
-
}
|
|
64
43
|
if (len > route.maxPayloadSize) {
|
|
65
44
|
(0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.PayloadTooLarge, {
|
|
66
|
-
|
|
67
|
-
requestId,
|
|
68
|
-
});
|
|
69
|
-
return true;
|
|
70
|
-
}
|
|
71
|
-
if (route.stream === true) {
|
|
72
|
-
(0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.FunctionIsStream, {
|
|
73
|
-
name,
|
|
45
|
+
route,
|
|
74
46
|
requestId,
|
|
75
47
|
});
|
|
76
48
|
return true;
|
|
77
49
|
}
|
|
78
|
-
const payload = (0, protocol_1.decodePayload)(new Uint8Array(arr.slice(start + 8 + nameLen, start + len)), isDeflate);
|
|
79
|
-
|
|
80
|
-
sendFunction(server, ctx, route, payload, requestId);
|
|
81
|
-
return true;
|
|
82
|
-
}
|
|
83
|
-
// TODO: make this fn a bit nicer.... remove nestedness...
|
|
84
|
-
server.auth
|
|
85
|
-
.authorize(ctx, name, payload)
|
|
86
|
-
.then((ok) => {
|
|
87
|
-
if (!ctx.session) {
|
|
88
|
-
return false;
|
|
89
|
-
}
|
|
90
|
-
if (!ok) {
|
|
91
|
-
(0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.AuthorizeRejectedError, {
|
|
92
|
-
route,
|
|
93
|
-
});
|
|
94
|
-
return false;
|
|
95
|
-
}
|
|
96
|
-
sendFunction(server, ctx, route, payload, requestId);
|
|
97
|
-
})
|
|
98
|
-
.catch((err) => {
|
|
99
|
-
(0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.AuthorizeFunctionError, {
|
|
100
|
-
route,
|
|
101
|
-
err,
|
|
102
|
-
});
|
|
103
|
-
});
|
|
50
|
+
const payload = (0, protocol_1.parsePayload)((0, protocol_1.decodePayload)(new Uint8Array(arr.slice(start + 8 + nameLen, start + len)), isDeflate));
|
|
51
|
+
(0, authorize_1.authorize)(route, server, ctx, payload, sendFunction, requestId);
|
|
104
52
|
return true;
|
|
105
53
|
};
|
|
106
54
|
exports.functionMessage = functionMessage;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"function.js","sourceRoot":"","sources":["../../../src/incoming/ws/function.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"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: number, isDeflate: boolean, ctx: Context<WebSocketSession>, server: BasedServer) => boolean;
|
|
1
|
+
import { BinaryMessageHandler } from './types';
|
|
2
|
+
export declare const getMessage: BinaryMessageHandler;
|
package/dist/incoming/ws/get.js
CHANGED
|
@@ -6,8 +6,12 @@ const observable_1 = require("../../observable");
|
|
|
6
6
|
const error_1 = require("../../error");
|
|
7
7
|
const sendError_1 = require("../../sendError");
|
|
8
8
|
const security_1 = require("../../security");
|
|
9
|
+
const verifyRoute_1 = require("../../verifyRoute");
|
|
10
|
+
const authorize_1 = require("../../authorize");
|
|
11
|
+
const installFn_1 = require("../../installFn");
|
|
9
12
|
const sendGetData = (server, id, obs, checksum, ctx) => {
|
|
10
13
|
if (!ctx.session) {
|
|
14
|
+
(0, observable_1.destroyObs)(server, id);
|
|
11
15
|
return;
|
|
12
16
|
}
|
|
13
17
|
if (checksum === 0) {
|
|
@@ -24,10 +28,10 @@ const sendGetData = (server, id, obs, checksum, ctx) => {
|
|
|
24
28
|
}
|
|
25
29
|
(0, observable_1.destroyObs)(server, id);
|
|
26
30
|
};
|
|
27
|
-
const getFromExisting = (server, id, ctx, checksum
|
|
31
|
+
const getFromExisting = (server, id, ctx, checksum) => {
|
|
28
32
|
const obs = (0, observable_1.getObs)(server, id);
|
|
29
33
|
if (obs.error) {
|
|
30
|
-
(0, observable_1.sendObsGetError)(server, ctx, id,
|
|
34
|
+
(0, observable_1.sendObsGetError)(server, ctx, id, obs.error);
|
|
31
35
|
return;
|
|
32
36
|
}
|
|
33
37
|
if (obs.cache) {
|
|
@@ -36,41 +40,46 @@ const getFromExisting = (server, id, ctx, checksum, name) => {
|
|
|
36
40
|
}
|
|
37
41
|
(0, observable_1.subscribeNext)(obs, (err) => {
|
|
38
42
|
if (err) {
|
|
39
|
-
(0, observable_1.sendObsGetError)(server, ctx, id,
|
|
43
|
+
(0, observable_1.sendObsGetError)(server, ctx, id, err);
|
|
40
44
|
}
|
|
41
45
|
else {
|
|
42
46
|
sendGetData(server, id, obs, checksum, ctx);
|
|
43
47
|
}
|
|
44
48
|
});
|
|
45
49
|
};
|
|
46
|
-
const
|
|
47
|
-
server
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
if (!(0, observable_1.verifyRoute)(server, name, spec, ctx)) {
|
|
50
|
+
const isAuthorized = (route, server, ctx, payload, id, checksum) => {
|
|
51
|
+
if ((0, observable_1.hasObs)(server, id)) {
|
|
52
|
+
getFromExisting(server, id, ctx, checksum);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
(0, installFn_1.installFn)(server, ctx, route, id).then((spec) => {
|
|
56
|
+
if (spec === null) {
|
|
54
57
|
return;
|
|
55
58
|
}
|
|
56
59
|
if ((0, observable_1.hasObs)(server, id)) {
|
|
57
|
-
getFromExisting(server, id, ctx, checksum
|
|
60
|
+
getFromExisting(server, id, ctx, checksum);
|
|
58
61
|
return;
|
|
59
62
|
}
|
|
60
|
-
const obs = (0, observable_1.createObs)(server, name, id, payload);
|
|
63
|
+
const obs = (0, observable_1.createObs)(server, route.name, id, payload, true);
|
|
61
64
|
if (!ctx.session?.obs.has(id)) {
|
|
62
65
|
(0, observable_1.subscribeNext)(obs, (err) => {
|
|
63
66
|
if (err) {
|
|
64
|
-
(0, observable_1.sendObsGetError)(server, ctx, id,
|
|
67
|
+
(0, observable_1.sendObsGetError)(server, ctx, id, err);
|
|
65
68
|
}
|
|
66
69
|
else {
|
|
67
70
|
sendGetData(server, id, obs, checksum, ctx);
|
|
68
71
|
}
|
|
69
72
|
});
|
|
70
73
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
+
(0, observable_1.start)(server, id);
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
const isNotAuthorized = (route, server, ctx, payload, id, checksum) => {
|
|
78
|
+
ctx.session.unauthorizedObs.add({
|
|
79
|
+
id,
|
|
80
|
+
checksum,
|
|
81
|
+
name: route.name,
|
|
82
|
+
payload,
|
|
74
83
|
});
|
|
75
84
|
};
|
|
76
85
|
const getMessage = (arr, start, len, isDeflate, ctx, server) => {
|
|
@@ -82,9 +91,9 @@ const getMessage = (arr, start, len, isDeflate, ctx, server) => {
|
|
|
82
91
|
if (!name || !id) {
|
|
83
92
|
return false;
|
|
84
93
|
}
|
|
85
|
-
const route = (0,
|
|
94
|
+
const route = (0, verifyRoute_1.verifyRoute)(server, ctx, 'query', server.functions.route(name), name, id);
|
|
86
95
|
// TODO: add strictness setting - if strict return false here
|
|
87
|
-
if (
|
|
96
|
+
if (route === null) {
|
|
88
97
|
return true;
|
|
89
98
|
}
|
|
90
99
|
if ((0, security_1.rateLimitRequest)(server, ctx, route.rateLimitTokens, server.rateLimit.ws)) {
|
|
@@ -92,44 +101,14 @@ const getMessage = (arr, start, len, isDeflate, ctx, server) => {
|
|
|
92
101
|
return false;
|
|
93
102
|
}
|
|
94
103
|
if (route.maxPayloadSize !== -1 && len > route.maxPayloadSize) {
|
|
95
|
-
(0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.PayloadTooLarge,
|
|
96
|
-
return true;
|
|
97
|
-
}
|
|
98
|
-
const payload = (0, protocol_1.decodePayload)(new Uint8Array(arr.slice(start + 21 + nameLen, start + len)), isDeflate);
|
|
99
|
-
if (route.public === true) {
|
|
100
|
-
if ((0, observable_1.hasObs)(server, id)) {
|
|
101
|
-
getFromExisting(server, id, ctx, checksum, name);
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
install(server, name, ctx, route, id, checksum, payload);
|
|
105
|
-
return true;
|
|
106
|
-
}
|
|
107
|
-
server.auth
|
|
108
|
-
.authorize(ctx, name, payload)
|
|
109
|
-
.then((ok) => {
|
|
110
|
-
if (!ctx.session) {
|
|
111
|
-
return false;
|
|
112
|
-
}
|
|
113
|
-
if (!ok) {
|
|
114
|
-
(0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.AuthorizeRejectedError, {
|
|
115
|
-
route,
|
|
116
|
-
observableId: id,
|
|
117
|
-
});
|
|
118
|
-
return false;
|
|
119
|
-
}
|
|
120
|
-
if ((0, observable_1.hasObs)(server, id)) {
|
|
121
|
-
getFromExisting(server, id, ctx, checksum, name);
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
install(server, name, ctx, route, id, checksum, payload);
|
|
125
|
-
})
|
|
126
|
-
.catch((err) => {
|
|
127
|
-
(0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.AuthorizeFunctionError, {
|
|
104
|
+
(0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.PayloadTooLarge, {
|
|
128
105
|
route,
|
|
129
106
|
observableId: id,
|
|
130
|
-
err,
|
|
131
107
|
});
|
|
132
|
-
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
const payload = (0, protocol_1.parsePayload)((0, protocol_1.decodePayload)(new Uint8Array(arr.slice(start + 21 + nameLen, start + len)), isDeflate));
|
|
111
|
+
(0, authorize_1.authorize)(route, server, ctx, payload, isAuthorized, id, checksum, isNotAuthorized);
|
|
133
112
|
return true;
|
|
134
113
|
};
|
|
135
114
|
exports.getMessage = getMessage;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get.js","sourceRoot":"","sources":["../../../src/incoming/ws/get.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"get.js","sourceRoot":"","sources":["../../../src/incoming/ws/get.ts"],"names":[],"mappings":";;;AAAA,6CAMuB;AAEvB,iDAUyB;AAGzB,uCAA4C;AAC5C,+CAA2C;AAC3C,6CAAiD;AACjD,mDAA+C;AAC/C,+CAIwB;AACxB,+CAA2C;AAG3C,MAAM,WAAW,GAAG,CAClB,MAAmB,EACnB,EAAU,EACV,GAAqB,EACrB,QAAgB,EAChB,GAA8B,EAC9B,EAAE;IACF,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE;QAChB,IAAA,uBAAU,EAAC,MAAM,EAAE,EAAE,CAAC,CAAA;QACtB,OA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G,EAAE,KAAK,CAAC,eAAe,EAAE,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,EACzE;QACA,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,CAAA;QACnB,OAAO,KAAK,CAAA;KACb;IAED,IAAI,KAAK,CAAC,cAAc,KAAK,CAAC,CAAC,IAAI,GAAG,GAAG,KAAK,CAAC,cAAc,EAAE;QAC7D,IAAA,qBAAS,EAAC,MAAM,EAAE,GAAG,EAAE,sBAAc,CAAC,eAAe,EAAE;YACrD,KAAK;YACL,YAAY,EAAE,EAAE;SACjB,CAAC,CAAA;QACF,OAAO,IAAI,CAAA;KACZ;IAED,MAAM,OAAO,GAAG,IAAA,uBAAY,EAC1B,IAAA,wBAAa,EACX,IAAI,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,GAAG,EAAE,GAAG,OAAO,EAAE,KAAK,GAAG,GAAG,CAAC,CAAC,EAC5D,SAAS,CACV,CACF,CAAA;IAED,IAAA,qBAAS,EACP,KAAK,EACL,MAAM,EACN,GAAG,EACH,OAAO,EACP,YAAY,EACZ,EAAE,EACF,QAAQ,EACR,eAAe,CAChB,CAAA;IAED,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AAlEY,QAAA,UAAU,cAkEtB"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { BasedServer } from '../../server';
|
|
2
|
-
import { WebSocketSession, Context } from '
|
|
2
|
+
import { WebSocketSession, Context } from '@based/functions';
|
|
3
3
|
export declare const message: (server: BasedServer, ctx: Context<WebSocketSession>, msg: ArrayBuffer, isBinary: boolean) => void;
|
|
@@ -19,7 +19,8 @@ const reader = (server, ctx, arr, start) => {
|
|
|
19
19
|
return next;
|
|
20
20
|
}
|
|
21
21
|
// type 2 = unsubscribe
|
|
22
|
-
if (type === 2 &&
|
|
22
|
+
if (type === 2 &&
|
|
23
|
+
(0, observable_1.unsubscribeMessage)(arr, start, len, isDeflate, ctx, server)) {
|
|
23
24
|
return next;
|
|
24
25
|
}
|
|
25
26
|
// type 3 = get
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/incoming/ws/index.ts"],"names":[],"mappings":";;;AACA,6CAAwD;AACxD,yCAA4C;AAC5C,6CAAmE;AACnE,iCAAoC;AACpC,+BAAkC;AAElC,uCAAyD;AAEzD,MAAM,MAAM,GAAG,CACb,MAAmB,EACnB,GAA8B,EAC9B,GAAe,EACf,KAAa,EACL,EAAE;IACV,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,IAAA,uBAAY,EAAC,IAAA,oBAAS,EAAC,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAA;IACvE,MAAM,IAAI,GAAG,GAAG,GAAG,KAAK,CAAA;IAExB,oBAAoB;IACpB,IAAI,IAAI,KAAK,CAAC,IAAI,IAAA,0BAAe,EAAC,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE;QAC1E,OAAO,IAAI,CAAA;KACZ;IAED,qBAAqB;IACrB,IAAI,IAAI,KAAK,CAAC,IAAI,IAAA,6BAAgB,EAAC,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE;QAC3E,OAAO,IAAI,CAAA;KACZ;IAED,uBAAuB;IACvB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/incoming/ws/index.ts"],"names":[],"mappings":";;;AACA,6CAAwD;AACxD,yCAA4C;AAC5C,6CAAmE;AACnE,iCAAoC;AACpC,+BAAkC;AAElC,uCAAyD;AAEzD,MAAM,MAAM,GAAG,CACb,MAAmB,EACnB,GAA8B,EAC9B,GAAe,EACf,KAAa,EACL,EAAE;IACV,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,IAAA,uBAAY,EAAC,IAAA,oBAAS,EAAC,GAA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AAG,EAAE,sBAAc,CAAC,gBAAgB,EAAE;YACxD,MAAM,EAAE,GAAG;SACZ,CAAC,CAAA;QACF,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,CAAA;QACnB,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,GAAG,EAAE,SAAS,EAAE,IAAI,CAAC,CAAA;QAC9C,IAAI,CAAC,KAAK,SAAS,EAAE;YACnB,8DAA8D;YAC9D,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,CAAA;YACnB,OAAM;SACP;QACD,IAAI,GAAG,CAAC,CAAA;KACT;AACH,CAAC,CAAA;AA9BY,QAAA,OAAO,WA8BnB"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
export declare const
|
|
6
|
-
export declare const
|
|
1
|
+
import { WebSocketSession } from '@based/functions';
|
|
2
|
+
import { BasedQueryFunctionRoute } from '../../functions';
|
|
3
|
+
import { IsAuthorizedHandler } from '../../authorize';
|
|
4
|
+
import { BinaryMessageHandler } from './types';
|
|
5
|
+
export declare const enableSubscribe: IsAuthorizedHandler<WebSocketSession, BasedQueryFunctionRoute>;
|
|
6
|
+
export declare const subscribeMessage: BinaryMessageHandler;
|
|
7
|
+
export declare const unsubscribeMessage: BinaryMessageHandler;
|
|
@@ -6,31 +6,35 @@ const observable_1 = require("../../observable");
|
|
|
6
6
|
const error_1 = require("../../error");
|
|
7
7
|
const sendError_1 = require("../../sendError");
|
|
8
8
|
const security_1 = require("../../security");
|
|
9
|
-
const
|
|
9
|
+
const verifyRoute_1 = require("../../verifyRoute");
|
|
10
|
+
const installFn_1 = require("../../installFn");
|
|
11
|
+
const authorize_1 = require("../../authorize");
|
|
12
|
+
const enableSubscribe = (route, server, ctx, payload, id, checksum) => {
|
|
10
13
|
if ((0, observable_1.hasObs)(server, id)) {
|
|
11
14
|
(0, observable_1.subscribeWs)(server, id, checksum, ctx);
|
|
12
15
|
return;
|
|
13
16
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
.
|
|
17
|
-
if (!(0, observable_1.verifyRoute)(server, name, spec, ctx)) {
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
if (!ctx.session?.obs.has(id)) {
|
|
17
|
+
// TODO: big perf optmization possible here (only return a promise if its not there)
|
|
18
|
+
(0, installFn_1.installFn)(server, ctx, route, id).then((spec) => {
|
|
19
|
+
if (spec === null || !ctx.session.obs.has(id)) {
|
|
21
20
|
return;
|
|
22
21
|
}
|
|
23
22
|
if (!(0, observable_1.hasObs)(server, id)) {
|
|
24
|
-
(0, observable_1.createObs)(server, name, id, payload);
|
|
23
|
+
(0, observable_1.createObs)(server, route.name, id, payload);
|
|
25
24
|
}
|
|
26
25
|
ctx.session.subscribe(String(id));
|
|
27
26
|
(0, observable_1.subscribeWs)(server, id, checksum, ctx);
|
|
28
|
-
})
|
|
29
|
-
.catch(() => {
|
|
30
|
-
(0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.FunctionNotFound, route);
|
|
31
27
|
});
|
|
32
28
|
};
|
|
33
29
|
exports.enableSubscribe = enableSubscribe;
|
|
30
|
+
const isNotAuthorized = (route, server, ctx, payload, id, checksum) => {
|
|
31
|
+
ctx.session.unauthorizedObs.add({
|
|
32
|
+
id,
|
|
33
|
+
checksum,
|
|
34
|
+
name: route.name,
|
|
35
|
+
payload,
|
|
36
|
+
});
|
|
37
|
+
};
|
|
34
38
|
const subscribeMessage = (arr, start, len, isDeflate, ctx, server) => {
|
|
35
39
|
// | 4 header | 8 id | 8 checksum | 1 name length | * name | * payload |
|
|
36
40
|
const nameLen = arr[start + 20];
|
|
@@ -40,9 +44,9 @@ const subscribeMessage = (arr, start, len, isDeflate, ctx, server) => {
|
|
|
40
44
|
if (!name || !id) {
|
|
41
45
|
return false;
|
|
42
46
|
}
|
|
43
|
-
const route = (0,
|
|
47
|
+
const route = (0, verifyRoute_1.verifyRoute)(server, ctx, 'query', server.functions.route(name), name, id);
|
|
44
48
|
// TODO: add strictness setting - if strict return false here
|
|
45
|
-
if (
|
|
49
|
+
if (route === null) {
|
|
46
50
|
return true;
|
|
47
51
|
}
|
|
48
52
|
if ((0, security_1.rateLimitRequest)(server, ctx, route.rateLimitTokens, server.rateLimit.ws)) {
|
|
@@ -50,51 +54,23 @@ const subscribeMessage = (arr, start, len, isDeflate, ctx, server) => {
|
|
|
50
54
|
return false;
|
|
51
55
|
}
|
|
52
56
|
if (route.maxPayloadSize !== -1 && len > route.maxPayloadSize) {
|
|
53
|
-
(0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.PayloadTooLarge,
|
|
57
|
+
(0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.PayloadTooLarge, {
|
|
58
|
+
route,
|
|
59
|
+
observableId: id,
|
|
60
|
+
});
|
|
54
61
|
return true;
|
|
55
62
|
}
|
|
56
63
|
if (ctx.session?.obs.has(id)) {
|
|
57
64
|
// allready subscribed to this id
|
|
58
65
|
return true;
|
|
59
66
|
}
|
|
60
|
-
const payload = (0, protocol_1.decodePayload)(new Uint8Array(arr.slice(start + 21 + nameLen, start + len)), isDeflate);
|
|
67
|
+
const payload = (0, protocol_1.parsePayload)((0, protocol_1.decodePayload)(new Uint8Array(arr.slice(start + 21 + nameLen, start + len)), isDeflate));
|
|
61
68
|
ctx.session.obs.add(id);
|
|
62
|
-
|
|
63
|
-
(0, exports.enableSubscribe)(server, ctx, id, checksum, name, payload, route);
|
|
64
|
-
return true;
|
|
65
|
-
}
|
|
66
|
-
server.auth
|
|
67
|
-
.authorize(ctx, name, payload)
|
|
68
|
-
.then((ok) => {
|
|
69
|
-
if (!ctx.session?.obs.has(id)) {
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
if (!ok) {
|
|
73
|
-
ctx.session.unauthorizedObs.add({
|
|
74
|
-
id,
|
|
75
|
-
checksum,
|
|
76
|
-
name,
|
|
77
|
-
payload,
|
|
78
|
-
});
|
|
79
|
-
(0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.AuthorizeRejectedError, {
|
|
80
|
-
route,
|
|
81
|
-
observableId: id,
|
|
82
|
-
});
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
(0, exports.enableSubscribe)(server, ctx, id, checksum, name, payload, route);
|
|
86
|
-
})
|
|
87
|
-
.catch((err) => {
|
|
88
|
-
(0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.AuthorizeFunctionError, {
|
|
89
|
-
route,
|
|
90
|
-
observableId: id,
|
|
91
|
-
err,
|
|
92
|
-
});
|
|
93
|
-
});
|
|
69
|
+
(0, authorize_1.authorize)(route, server, ctx, payload, exports.enableSubscribe, id, checksum, isNotAuthorized);
|
|
94
70
|
return true;
|
|
95
71
|
};
|
|
96
72
|
exports.subscribeMessage = subscribeMessage;
|
|
97
|
-
const unsubscribeMessage = (arr, start, ctx, server) => {
|
|
73
|
+
const unsubscribeMessage = (arr, start, len, isDeflate, ctx, server) => {
|
|
98
74
|
// | 4 header | 8 id |
|
|
99
75
|
if (!ctx.session) {
|
|
100
76
|
return false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"observable.js","sourceRoot":"","sources":["../../../src/incoming/ws/observable.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"observable.js","sourceRoot":"","sources":["../../../src/incoming/ws/observable.ts"],"names":[],"mappings":";;;AAAA,6CAKuB;AACvB,iDAAgF;AAChF,uCAA4C;AAG5C,+CAA2C;AAC3C,6CAAiD;AACjD,mDAA+C;AAC/C,+CAA2C;AAC3C,+CAIwB;AAGjB,M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functions';
|
|
3
|
+
export declare type BinaryMessageHandler = (arr: Uint8Array, start: number, len: number, isDeflate: boolean, ctx: Context<WebSocketSession>, server: BasedServer) => boolean;
|
|
File without changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/incoming/ws/types.ts"],"names":[],"mappings":""}
|