@wirebench/engine 2.1.1
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/LICENSE +201 -0
- package/README.md +3 -0
- package/dist/assert/contract.d.ts +3 -0
- package/dist/assert/contract.js +17 -0
- package/dist/assert/index.d.ts +4 -0
- package/dist/assert/index.js +27 -0
- package/dist/assert/match.d.ts +3 -0
- package/dist/assert/match.js +58 -0
- package/dist/assert/model.d.ts +73 -0
- package/dist/assert/model.js +8 -0
- package/dist/assert/schema.d.ts +34 -0
- package/dist/assert/schema.js +46 -0
- package/dist/assert/sla.d.ts +3 -0
- package/dist/assert/sla.js +8 -0
- package/dist/assert/soap-fault.d.ts +3 -0
- package/dist/assert/soap-fault.js +20 -0
- package/dist/assert/status.d.ts +3 -0
- package/dist/assert/status.js +14 -0
- package/dist/errors.d.ts +77 -0
- package/dist/errors.js +121 -0
- package/dist/fs.d.ts +35 -0
- package/dist/fs.js +64 -0
- package/dist/generate.d.ts +12 -0
- package/dist/generate.js +14 -0
- package/dist/grpc/browser.d.ts +11 -0
- package/dist/grpc/browser.js +9 -0
- package/dist/grpc/cache.d.ts +113 -0
- package/dist/grpc/cache.js +244 -0
- package/dist/grpc/call.d.ts +64 -0
- package/dist/grpc/call.js +72 -0
- package/dist/grpc/codec.d.ts +29 -0
- package/dist/grpc/codec.js +416 -0
- package/dist/grpc/command.d.ts +23 -0
- package/dist/grpc/command.js +91 -0
- package/dist/grpc/expand.d.ts +25 -0
- package/dist/grpc/expand.js +52 -0
- package/dist/grpc/framing.d.ts +28 -0
- package/dist/grpc/framing.js +61 -0
- package/dist/grpc/import.d.ts +47 -0
- package/dist/grpc/import.js +88 -0
- package/dist/grpc/model.d.ts +179 -0
- package/dist/grpc/model.js +91 -0
- package/dist/grpc/proto/describe.d.ts +92 -0
- package/dist/grpc/proto/describe.js +205 -0
- package/dist/grpc/proto/load.d.ts +35 -0
- package/dist/grpc/proto/load.js +112 -0
- package/dist/grpc/proto/sample.d.ts +21 -0
- package/dist/grpc/proto/sample.js +79 -0
- package/dist/grpc/proto/well-known.d.ts +42 -0
- package/dist/grpc/proto/well-known.js +143 -0
- package/dist/grpc/reconcile.d.ts +42 -0
- package/dist/grpc/reconcile.js +153 -0
- package/dist/grpc/reflection/client.d.ts +70 -0
- package/dist/grpc/reflection/client.js +197 -0
- package/dist/grpc/reflection/descriptors.d.ts +69 -0
- package/dist/grpc/reflection/descriptors.js +140 -0
- package/dist/grpc/reflection/proto.d.ts +33 -0
- package/dist/grpc/reflection/proto.js +144 -0
- package/dist/grpc/send.d.ts +132 -0
- package/dist/grpc/send.js +435 -0
- package/dist/grpc/shape.d.ts +29 -0
- package/dist/grpc/shape.js +36 -0
- package/dist/grpc/status.d.ts +21 -0
- package/dist/grpc/status.js +62 -0
- package/dist/grpc/target.d.ts +21 -0
- package/dist/grpc/target.js +66 -0
- package/dist/http/auth/apply.d.ts +37 -0
- package/dist/http/auth/apply.js +74 -0
- package/dist/http/auth/basic.d.ts +36 -0
- package/dist/http/auth/basic.js +69 -0
- package/dist/http/auth/md4.d.ts +13 -0
- package/dist/http/auth/md4.js +81 -0
- package/dist/http/auth/ntlm-transport.d.ts +61 -0
- package/dist/http/auth/ntlm-transport.js +97 -0
- package/dist/http/auth/ntlm.d.ts +190 -0
- package/dist/http/auth/ntlm.js +377 -0
- package/dist/http/client.d.ts +73 -0
- package/dist/http/client.js +403 -0
- package/dist/http/curl-flags.d.ts +15 -0
- package/dist/http/curl-flags.js +95 -0
- package/dist/http/curl.d.ts +94 -0
- package/dist/http/curl.js +245 -0
- package/dist/http/decompress.d.ts +7 -0
- package/dist/http/decompress.js +22 -0
- package/dist/http/errors.d.ts +22 -0
- package/dist/http/errors.js +144 -0
- package/dist/http/failed-request.d.ts +27 -0
- package/dist/http/failed-request.js +48 -0
- package/dist/http/headers.d.ts +15 -0
- package/dist/http/headers.js +50 -0
- package/dist/http/heredoc.d.ts +25 -0
- package/dist/http/heredoc.js +74 -0
- package/dist/http/proxy.d.ts +103 -0
- package/dist/http/proxy.js +168 -0
- package/dist/http/raw-capture.d.ts +23 -0
- package/dist/http/raw-capture.js +57 -0
- package/dist/http/timings.d.ts +79 -0
- package/dist/http/timings.js +212 -0
- package/dist/http/tls.d.ts +111 -0
- package/dist/http/tls.js +167 -0
- package/dist/http/types.d.ts +125 -0
- package/dist/http/types.js +6 -0
- package/dist/import-detect.d.ts +26 -0
- package/dist/import-detect.js +169 -0
- package/dist/import.d.ts +20 -0
- package/dist/import.js +163 -0
- package/dist/index.d.ts +272 -0
- package/dist/index.js +157 -0
- package/dist/json/cursor.d.ts +43 -0
- package/dist/json/cursor.js +168 -0
- package/dist/operations.d.ts +12 -0
- package/dist/operations.js +52 -0
- package/dist/project/attachments-cache.d.ts +80 -0
- package/dist/project/attachments-cache.js +186 -0
- package/dist/project/endpoints.d.ts +23 -0
- package/dist/project/endpoints.js +47 -0
- package/dist/project/environments.d.ts +68 -0
- package/dist/project/environments.js +124 -0
- package/dist/project/fs.d.ts +45 -0
- package/dist/project/fs.js +78 -0
- package/dist/project/history.d.ts +171 -0
- package/dist/project/history.js +179 -0
- package/dist/project/keystores.d.ts +24 -0
- package/dist/project/keystores.js +66 -0
- package/dist/project/load.d.ts +44 -0
- package/dist/project/load.js +634 -0
- package/dist/project/migrate.d.ts +27 -0
- package/dist/project/migrate.js +46 -0
- package/dist/project/model.d.ts +401 -0
- package/dist/project/model.js +126 -0
- package/dist/project/paths.d.ts +134 -0
- package/dist/project/paths.js +259 -0
- package/dist/project/preferences.d.ts +318 -0
- package/dist/project/preferences.js +239 -0
- package/dist/project/properties.d.ts +97 -0
- package/dist/project/properties.js +356 -0
- package/dist/project/save.d.ts +65 -0
- package/dist/project/save.js +295 -0
- package/dist/project/schema.d.ts +1329 -0
- package/dist/project/schema.js +737 -0
- package/dist/project/serialize.d.ts +42 -0
- package/dist/project/serialize.js +385 -0
- package/dist/project/wss-configs.d.ts +40 -0
- package/dist/project/wss-configs.js +142 -0
- package/dist/project/yaml.d.ts +17 -0
- package/dist/project/yaml.js +39 -0
- package/dist/redact/index.d.ts +77 -0
- package/dist/redact/index.js +328 -0
- package/dist/redact/literal.d.ts +12 -0
- package/dist/redact/literal.js +68 -0
- package/dist/rest/auth.d.ts +53 -0
- package/dist/rest/auth.js +80 -0
- package/dist/rest/body.d.ts +61 -0
- package/dist/rest/body.js +184 -0
- package/dist/rest/browser.d.ts +12 -0
- package/dist/rest/browser.js +11 -0
- package/dist/rest/cookies.d.ts +41 -0
- package/dist/rest/cookies.js +102 -0
- package/dist/rest/curl.d.ts +75 -0
- package/dist/rest/curl.js +417 -0
- package/dist/rest/expand.d.ts +35 -0
- package/dist/rest/expand.js +104 -0
- package/dist/rest/model.d.ts +247 -0
- package/dist/rest/model.js +118 -0
- package/dist/rest/oauth2.d.ts +118 -0
- package/dist/rest/oauth2.js +212 -0
- package/dist/rest/openapi/cache.d.ts +54 -0
- package/dist/rest/openapi/cache.js +128 -0
- package/dist/rest/openapi/import.d.ts +67 -0
- package/dist/rest/openapi/import.js +91 -0
- package/dist/rest/openapi/map.d.ts +102 -0
- package/dist/rest/openapi/map.js +477 -0
- package/dist/rest/openapi/model.d.ts +203 -0
- package/dist/rest/openapi/model.js +37 -0
- package/dist/rest/openapi/parse.d.ts +44 -0
- package/dist/rest/openapi/parse.js +1530 -0
- package/dist/rest/openapi/refs.d.ts +63 -0
- package/dist/rest/openapi/refs.js +258 -0
- package/dist/rest/openapi/sample.d.ts +68 -0
- package/dist/rest/openapi/sample.js +336 -0
- package/dist/rest/postman/import.d.ts +21 -0
- package/dist/rest/postman/import.js +47 -0
- package/dist/rest/postman/index.d.ts +7 -0
- package/dist/rest/postman/index.js +7 -0
- package/dist/rest/postman/map.d.ts +28 -0
- package/dist/rest/postman/map.js +427 -0
- package/dist/rest/postman/model.d.ts +118 -0
- package/dist/rest/postman/model.js +7 -0
- package/dist/rest/postman/parse.d.ts +29 -0
- package/dist/rest/postman/parse.js +518 -0
- package/dist/rest/response.d.ts +72 -0
- package/dist/rest/response.js +221 -0
- package/dist/rest/send.d.ts +102 -0
- package/dist/rest/send.js +148 -0
- package/dist/rest/url.d.ts +92 -0
- package/dist/rest/url.js +213 -0
- package/dist/run/effective-auth.d.ts +10 -0
- package/dist/run/effective-auth.js +19 -0
- package/dist/run/index.d.ts +8 -0
- package/dist/run/index.js +4 -0
- package/dist/run/prepare.d.ts +43 -0
- package/dist/run/prepare.js +280 -0
- package/dist/run/run.d.ts +53 -0
- package/dist/run/run.js +223 -0
- package/dist/run/secret-needs.d.ts +13 -0
- package/dist/run/secret-needs.js +125 -0
- package/dist/run/select.d.ts +34 -0
- package/dist/run/select.js +76 -0
- package/dist/secrets/env-names.d.ts +27 -0
- package/dist/secrets/env-names.js +40 -0
- package/dist/secrets/resolve.d.ts +58 -0
- package/dist/secrets/resolve.js +136 -0
- package/dist/send-options.d.ts +141 -0
- package/dist/send-options.js +228 -0
- package/dist/send.d.ts +53 -0
- package/dist/send.js +210 -0
- package/dist/soap/body-builder.d.ts +38 -0
- package/dist/soap/body-builder.js +250 -0
- package/dist/soap/build-problems.d.ts +12 -0
- package/dist/soap/build-problems.js +2 -0
- package/dist/soap/charset.d.ts +23 -0
- package/dist/soap/charset.js +47 -0
- package/dist/soap/envelope.d.ts +44 -0
- package/dist/soap/envelope.js +76 -0
- package/dist/soap/fault.d.ts +46 -0
- package/dist/soap/fault.js +129 -0
- package/dist/soap/form-request.d.ts +34 -0
- package/dist/soap/form-request.js +251 -0
- package/dist/soap/legacy-project/definition-fetcher.d.ts +21 -0
- package/dist/soap/legacy-project/definition-fetcher.js +43 -0
- package/dist/soap/legacy-project/format.d.ts +18 -0
- package/dist/soap/legacy-project/format.js +24 -0
- package/dist/soap/legacy-project/import.d.ts +21 -0
- package/dist/soap/legacy-project/import.js +46 -0
- package/dist/soap/legacy-project/index.d.ts +9 -0
- package/dist/soap/legacy-project/index.js +5 -0
- package/dist/soap/legacy-project/map.d.ts +91 -0
- package/dist/soap/legacy-project/map.js +290 -0
- package/dist/soap/legacy-project/model.d.ts +98 -0
- package/dist/soap/legacy-project/model.js +5 -0
- package/dist/soap/legacy-project/parse.d.ts +16 -0
- package/dist/soap/legacy-project/parse.js +325 -0
- package/dist/soap/mime/cid-scan.d.ts +36 -0
- package/dist/soap/mime/cid-scan.js +52 -0
- package/dist/soap/mime/inline-files.d.ts +39 -0
- package/dist/soap/mime/inline-files.js +71 -0
- package/dist/soap/mime/mtom.d.ts +74 -0
- package/dist/soap/mime/mtom.js +134 -0
- package/dist/soap/mime/multipart.d.ts +66 -0
- package/dist/soap/mime/multipart.js +329 -0
- package/dist/soap/mime/send-pipeline.d.ts +61 -0
- package/dist/soap/mime/send-pipeline.js +145 -0
- package/dist/soap/mime/swa.d.ts +45 -0
- package/dist/soap/mime/swa.js +62 -0
- package/dist/soap/mime/types.d.ts +69 -0
- package/dist/soap/mime/types.js +10 -0
- package/dist/soap/namespace-scope.d.ts +32 -0
- package/dist/soap/namespace-scope.js +85 -0
- package/dist/soap/prefixes.d.ts +24 -0
- package/dist/soap/prefixes.js +70 -0
- package/dist/soap/recreate.d.ts +28 -0
- package/dist/soap/recreate.js +168 -0
- package/dist/soap/request-builder.d.ts +63 -0
- package/dist/soap/request-builder.js +161 -0
- package/dist/soap/response-parser.d.ts +29 -0
- package/dist/soap/response-parser.js +71 -0
- package/dist/soap/soap-action.d.ts +31 -0
- package/dist/soap/soap-action.js +28 -0
- package/dist/soap/transforms.d.ts +52 -0
- package/dist/soap/transforms.js +164 -0
- package/dist/types.d.ts +307 -0
- package/dist/types.js +6 -0
- package/dist/validate/index.d.ts +61 -0
- package/dist/validate/index.js +72 -0
- package/dist/validate/schema-file-set.d.ts +51 -0
- package/dist/validate/schema-file-set.js +288 -0
- package/dist/validate/schema-validator.d.ts +53 -0
- package/dist/validate/schema-validator.js +251 -0
- package/dist/validate/soap-structure.d.ts +34 -0
- package/dist/validate/soap-structure.js +255 -0
- package/dist/validate/types.d.ts +47 -0
- package/dist/validate/types.js +8 -0
- package/dist/validate/wsi/assertions/helpers.d.ts +145 -0
- package/dist/validate/wsi/assertions/helpers.js +387 -0
- package/dist/validate/wsi/assertions/index.d.ts +44 -0
- package/dist/validate/wsi/assertions/index.js +77 -0
- package/dist/validate/wsi/assertions/message/helpers.d.ts +63 -0
- package/dist/validate/wsi/assertions/message/helpers.js +168 -0
- package/dist/validate/wsi/assertions/message/index.d.ts +39 -0
- package/dist/validate/wsi/assertions/message/index.js +62 -0
- package/dist/validate/wsi/assertions/message/r1001.d.ts +10 -0
- package/dist/validate/wsi/assertions/message/r1001.js +38 -0
- package/dist/validate/wsi/assertions/message/r1003.d.ts +14 -0
- package/dist/validate/wsi/assertions/message/r1003.js +45 -0
- package/dist/validate/wsi/assertions/message/r1005.d.ts +12 -0
- package/dist/validate/wsi/assertions/message/r1005.js +37 -0
- package/dist/validate/wsi/assertions/message/r1006.d.ts +10 -0
- package/dist/validate/wsi/assertions/message/r1006.js +49 -0
- package/dist/validate/wsi/assertions/message/r1007.d.ts +10 -0
- package/dist/validate/wsi/assertions/message/r1007.js +30 -0
- package/dist/validate/wsi/assertions/message/r1011.d.ts +10 -0
- package/dist/validate/wsi/assertions/message/r1011.js +33 -0
- package/dist/validate/wsi/assertions/message/r1012.d.ts +13 -0
- package/dist/validate/wsi/assertions/message/r1012.js +37 -0
- package/dist/validate/wsi/assertions/message/r1013.d.ts +9 -0
- package/dist/validate/wsi/assertions/message/r1013.js +42 -0
- package/dist/validate/wsi/assertions/message/r1014.d.ts +10 -0
- package/dist/validate/wsi/assertions/message/r1014.js +30 -0
- package/dist/validate/wsi/assertions/message/r1015.d.ts +12 -0
- package/dist/validate/wsi/assertions/message/r1015.js +36 -0
- package/dist/validate/wsi/assertions/message/r1017.d.ts +10 -0
- package/dist/validate/wsi/assertions/message/r1017.js +30 -0
- package/dist/validate/wsi/assertions/message/r1100.d.ts +10 -0
- package/dist/validate/wsi/assertions/message/r1100.js +39 -0
- package/dist/validate/wsi/assertions/message/r1101.d.ts +10 -0
- package/dist/validate/wsi/assertions/message/r1101.js +37 -0
- package/dist/validate/wsi/assertions/message/r1102.d.ts +10 -0
- package/dist/validate/wsi/assertions/message/r1102.js +41 -0
- package/dist/validate/wsi/assertions/message/r1103.d.ts +10 -0
- package/dist/validate/wsi/assertions/message/r1103.js +28 -0
- package/dist/validate/wsi/assertions/message/r1107.d.ts +10 -0
- package/dist/validate/wsi/assertions/message/r1107.js +38 -0
- package/dist/validate/wsi/assertions/message/r1109.d.ts +10 -0
- package/dist/validate/wsi/assertions/message/r1109.js +32 -0
- package/dist/validate/wsi/assertions/message/r1124.d.ts +10 -0
- package/dist/validate/wsi/assertions/message/r1124.js +31 -0
- package/dist/validate/wsi/assertions/message/r1132.d.ts +9 -0
- package/dist/validate/wsi/assertions/message/r1132.js +23 -0
- package/dist/validate/wsi/assertions/message/r1140.d.ts +10 -0
- package/dist/validate/wsi/assertions/message/r1140.js +42 -0
- package/dist/validate/wsi/assertions/message/r1141.d.ts +10 -0
- package/dist/validate/wsi/assertions/message/r1141.js +32 -0
- package/dist/validate/wsi/assertions/message/r2113.d.ts +11 -0
- package/dist/validate/wsi/assertions/message/r2113.js +33 -0
- package/dist/validate/wsi/assertions/message/r2211.d.ts +7 -0
- package/dist/validate/wsi/assertions/message/r2211.js +42 -0
- package/dist/validate/wsi/assertions/r2001.d.ts +15 -0
- package/dist/validate/wsi/assertions/r2001.js +47 -0
- package/dist/validate/wsi/assertions/r2002.d.ts +11 -0
- package/dist/validate/wsi/assertions/r2002.js +38 -0
- package/dist/validate/wsi/assertions/r2003.d.ts +7 -0
- package/dist/validate/wsi/assertions/r2003.js +32 -0
- package/dist/validate/wsi/assertions/r2005.d.ts +7 -0
- package/dist/validate/wsi/assertions/r2005.js +40 -0
- package/dist/validate/wsi/assertions/r2101.d.ts +14 -0
- package/dist/validate/wsi/assertions/r2101.js +65 -0
- package/dist/validate/wsi/assertions/r2102.d.ts +10 -0
- package/dist/validate/wsi/assertions/r2102.js +41 -0
- package/dist/validate/wsi/assertions/r2105.d.ts +8 -0
- package/dist/validate/wsi/assertions/r2105.js +39 -0
- package/dist/validate/wsi/assertions/r2110.d.ts +8 -0
- package/dist/validate/wsi/assertions/r2110.js +38 -0
- package/dist/validate/wsi/assertions/r2111.d.ts +6 -0
- package/dist/validate/wsi/assertions/r2111.js +30 -0
- package/dist/validate/wsi/assertions/r2112.d.ts +7 -0
- package/dist/validate/wsi/assertions/r2112.js +35 -0
- package/dist/validate/wsi/assertions/r2201.d.ts +7 -0
- package/dist/validate/wsi/assertions/r2201.js +28 -0
- package/dist/validate/wsi/assertions/r2203.d.ts +7 -0
- package/dist/validate/wsi/assertions/r2203.js +30 -0
- package/dist/validate/wsi/assertions/r2204.d.ts +6 -0
- package/dist/validate/wsi/assertions/r2204.js +29 -0
- package/dist/validate/wsi/assertions/r2205.d.ts +8 -0
- package/dist/validate/wsi/assertions/r2205.js +46 -0
- package/dist/validate/wsi/assertions/r2206.d.ts +7 -0
- package/dist/validate/wsi/assertions/r2206.js +36 -0
- package/dist/validate/wsi/assertions/r2209.d.ts +12 -0
- package/dist/validate/wsi/assertions/r2209.js +37 -0
- package/dist/validate/wsi/assertions/r2210.d.ts +7 -0
- package/dist/validate/wsi/assertions/r2210.js +30 -0
- package/dist/validate/wsi/assertions/r2303.d.ts +7 -0
- package/dist/validate/wsi/assertions/r2303.js +44 -0
- package/dist/validate/wsi/assertions/r2304.d.ts +6 -0
- package/dist/validate/wsi/assertions/r2304.js +32 -0
- package/dist/validate/wsi/assertions/r2401.d.ts +12 -0
- package/dist/validate/wsi/assertions/r2401.js +31 -0
- package/dist/validate/wsi/assertions/r2701.d.ts +7 -0
- package/dist/validate/wsi/assertions/r2701.js +28 -0
- package/dist/validate/wsi/assertions/r2702.d.ts +6 -0
- package/dist/validate/wsi/assertions/r2702.js +26 -0
- package/dist/validate/wsi/assertions/r2705.d.ts +11 -0
- package/dist/validate/wsi/assertions/r2705.js +31 -0
- package/dist/validate/wsi/assertions/r2706.d.ts +7 -0
- package/dist/validate/wsi/assertions/r2706.js +29 -0
- package/dist/validate/wsi/assertions/r2710.d.ts +13 -0
- package/dist/validate/wsi/assertions/r2710.js +37 -0
- package/dist/validate/wsi/assertions/r2716.d.ts +7 -0
- package/dist/validate/wsi/assertions/r2716.js +29 -0
- package/dist/validate/wsi/assertions/r2717.d.ts +9 -0
- package/dist/validate/wsi/assertions/r2717.js +31 -0
- package/dist/validate/wsi/assertions/r2718.d.ts +7 -0
- package/dist/validate/wsi/assertions/r2718.js +41 -0
- package/dist/validate/wsi/assertions/r2720.d.ts +7 -0
- package/dist/validate/wsi/assertions/r2720.js +29 -0
- package/dist/validate/wsi/assertions/r2721.d.ts +6 -0
- package/dist/validate/wsi/assertions/r2721.js +27 -0
- package/dist/validate/wsi/assertions/r2722.d.ts +6 -0
- package/dist/validate/wsi/assertions/r2722.js +29 -0
- package/dist/validate/wsi/assertions/r2801.d.ts +7 -0
- package/dist/validate/wsi/assertions/r2801.js +39 -0
- package/dist/validate/wsi/assertions/r2803.d.ts +7 -0
- package/dist/validate/wsi/assertions/r2803.js +29 -0
- package/dist/validate/wsi/docs.d.ts +29 -0
- package/dist/validate/wsi/docs.js +167 -0
- package/dist/validate/wsi/index.d.ts +16 -0
- package/dist/validate/wsi/index.js +11 -0
- package/dist/validate/wsi/report-html.d.ts +36 -0
- package/dist/validate/wsi/report-html.js +135 -0
- package/dist/validate/wsi/run-message.d.ts +50 -0
- package/dist/validate/wsi/run-message.js +190 -0
- package/dist/validate/wsi/run-wsdl.d.ts +48 -0
- package/dist/validate/wsi/run-wsdl.js +99 -0
- package/dist/validate/wsi/types.d.ts +173 -0
- package/dist/validate/wsi/types.js +17 -0
- package/dist/workspace/commit-message.d.ts +47 -0
- package/dist/workspace/commit-message.js +195 -0
- package/dist/workspace/environments.d.ts +79 -0
- package/dist/workspace/environments.js +115 -0
- package/dist/workspace/index.d.ts +28 -0
- package/dist/workspace/index.js +19 -0
- package/dist/workspace/load.d.ts +45 -0
- package/dist/workspace/load.js +155 -0
- package/dist/workspace/local-state.d.ts +37 -0
- package/dist/workspace/local-state.js +59 -0
- package/dist/workspace/migrate.d.ts +38 -0
- package/dist/workspace/migrate.js +50 -0
- package/dist/workspace/model.d.ts +86 -0
- package/dist/workspace/model.js +54 -0
- package/dist/workspace/paths.d.ts +64 -0
- package/dist/workspace/paths.js +97 -0
- package/dist/workspace/reidentify.d.ts +22 -0
- package/dist/workspace/reidentify.js +122 -0
- package/dist/workspace/save.d.ts +31 -0
- package/dist/workspace/save.js +84 -0
- package/dist/workspace/schema.d.ts +93 -0
- package/dist/workspace/schema.js +115 -0
- package/dist/workspace/serialize.d.ts +24 -0
- package/dist/workspace/serialize.js +60 -0
- package/dist/workspace/share.d.ts +52 -0
- package/dist/workspace/share.js +89 -0
- package/dist/ws/browser.d.ts +13 -0
- package/dist/ws/browser.js +11 -0
- package/dist/ws/call.d.ts +53 -0
- package/dist/ws/call.js +106 -0
- package/dist/ws/command.d.ts +19 -0
- package/dist/ws/command.js +28 -0
- package/dist/ws/expand.d.ts +38 -0
- package/dist/ws/expand.js +76 -0
- package/dist/ws/model.d.ts +191 -0
- package/dist/ws/model.js +83 -0
- package/dist/ws/pretty.d.ts +12 -0
- package/dist/ws/pretty.js +25 -0
- package/dist/ws/session.d.ts +50 -0
- package/dist/ws/session.js +333 -0
- package/dist/ws/shape.d.ts +18 -0
- package/dist/ws/shape.js +28 -0
- package/dist/ws/transcript.d.ts +14 -0
- package/dist/ws/transcript.js +29 -0
- package/dist/ws/url.d.ts +3 -0
- package/dist/ws/url.js +44 -0
- package/dist/wsa/headers.d.ts +78 -0
- package/dist/wsa/headers.js +244 -0
- package/dist/wsa/model.d.ts +66 -0
- package/dist/wsa/model.js +52 -0
- package/dist/wsa/policy-detect.d.ts +81 -0
- package/dist/wsa/policy-detect.js +245 -0
- package/dist/wsdl/cache-naming.d.ts +39 -0
- package/dist/wsdl/cache-naming.js +90 -0
- package/dist/wsdl/cache.d.ts +48 -0
- package/dist/wsdl/cache.js +141 -0
- package/dist/wsdl/docs-generator.d.ts +47 -0
- package/dist/wsdl/docs-generator.js +439 -0
- package/dist/wsdl/dom-utils.d.ts +15 -0
- package/dist/wsdl/dom-utils.js +50 -0
- package/dist/wsdl/export-definition.d.ts +38 -0
- package/dist/wsdl/export-definition.js +100 -0
- package/dist/wsdl/fetch.d.ts +13 -0
- package/dist/wsdl/fetch.js +60 -0
- package/dist/wsdl/merge.d.ts +17 -0
- package/dist/wsdl/merge.js +57 -0
- package/dist/wsdl/model.d.ts +176 -0
- package/dist/wsdl/model.js +17 -0
- package/dist/wsdl/parse-binding.d.ts +6 -0
- package/dist/wsdl/parse-binding.js +150 -0
- package/dist/wsdl/parse-wsdl.d.ts +47 -0
- package/dist/wsdl/parse-wsdl.js +161 -0
- package/dist/wsdl/qname.d.ts +28 -0
- package/dist/wsdl/qname.js +41 -0
- package/dist/wsdl/ref-policy.d.ts +54 -0
- package/dist/wsdl/ref-policy.js +87 -0
- package/dist/wsdl/resolver.d.ts +81 -0
- package/dist/wsdl/resolver.js +276 -0
- package/dist/wsdl/update-definition.d.ts +106 -0
- package/dist/wsdl/update-definition.js +314 -0
- package/dist/wss/apply.d.ts +40 -0
- package/dist/wss/apply.js +212 -0
- package/dist/wss/c14n-prefixes.d.ts +27 -0
- package/dist/wss/c14n-prefixes.js +95 -0
- package/dist/wss/incoming/decrypt.d.ts +35 -0
- package/dist/wss/incoming/decrypt.js +57 -0
- package/dist/wss/incoming/index.d.ts +56 -0
- package/dist/wss/incoming/index.js +189 -0
- package/dist/wss/incoming/verify.d.ts +74 -0
- package/dist/wss/incoming/verify.js +440 -0
- package/dist/wss/key-identifiers.d.ts +76 -0
- package/dist/wss/key-identifiers.js +139 -0
- package/dist/wss/keystore/certificate.d.ts +45 -0
- package/dist/wss/keystore/certificate.js +134 -0
- package/dist/wss/keystore/index.d.ts +50 -0
- package/dist/wss/keystore/index.js +80 -0
- package/dist/wss/keystore/model.d.ts +83 -0
- package/dist/wss/keystore/model.js +27 -0
- package/dist/wss/keystore/pem.d.ts +21 -0
- package/dist/wss/keystore/pem.js +140 -0
- package/dist/wss/keystore/pkcs12.d.ts +21 -0
- package/dist/wss/keystore/pkcs12.js +125 -0
- package/dist/wss/model.d.ts +160 -0
- package/dist/wss/model.js +37 -0
- package/dist/wss/outgoing/encryption.d.ts +76 -0
- package/dist/wss/outgoing/encryption.js +618 -0
- package/dist/wss/outgoing/signature.d.ts +73 -0
- package/dist/wss/outgoing/signature.js +239 -0
- package/dist/wss/outgoing/timestamp.d.ts +29 -0
- package/dist/wss/outgoing/timestamp.js +39 -0
- package/dist/wss/outgoing/username-token.d.ts +36 -0
- package/dist/wss/outgoing/username-token.js +68 -0
- package/dist/wss/security-header.d.ts +31 -0
- package/dist/wss/security-header.js +83 -0
- package/dist/xml/index.d.ts +7 -0
- package/dist/xml/index.js +7 -0
- package/dist/xml/namespaces.d.ts +36 -0
- package/dist/xml/namespaces.js +60 -0
- package/dist/xml/parse.d.ts +79 -0
- package/dist/xml/parse.js +109 -0
- package/dist/xml/positions.d.ts +26 -0
- package/dist/xml/positions.js +71 -0
- package/dist/xml/pretty.d.ts +37 -0
- package/dist/xml/pretty.js +137 -0
- package/dist/xml/serialize.d.ts +6 -0
- package/dist/xml/serialize.js +8 -0
- package/dist/xml/tolerant-tree.d.ts +56 -0
- package/dist/xml/tolerant-tree.js +134 -0
- package/dist/xpath/evaluate-async.d.ts +31 -0
- package/dist/xpath/evaluate-async.js +81 -0
- package/dist/xpath/evaluate.d.ts +98 -0
- package/dist/xpath/evaluate.js +340 -0
- package/dist/xpath/jsonpath.d.ts +40 -0
- package/dist/xpath/jsonpath.js +109 -0
- package/dist/xpath/namespaces.d.ts +29 -0
- package/dist/xpath/namespaces.js +101 -0
- package/dist/xpath/worker.d.ts +7 -0
- package/dist/xpath/worker.js +26 -0
- package/dist/xsd/builtins.d.ts +36 -0
- package/dist/xsd/builtins.js +108 -0
- package/dist/xsd/check-references.d.ts +25 -0
- package/dist/xsd/check-references.js +145 -0
- package/dist/xsd/form-edits.d.ts +57 -0
- package/dist/xsd/form-edits.js +153 -0
- package/dist/xsd/form-model.d.ts +153 -0
- package/dist/xsd/form-model.js +691 -0
- package/dist/xsd/locate.d.ts +42 -0
- package/dist/xsd/locate.js +249 -0
- package/dist/xsd/model.d.ts +249 -0
- package/dist/xsd/model.js +1 -0
- package/dist/xsd/parse-particles.d.ts +48 -0
- package/dist/xsd/parse-particles.js +320 -0
- package/dist/xsd/parse-schema.d.ts +21 -0
- package/dist/xsd/parse-schema.js +143 -0
- package/dist/xsd/resolve-content.d.ts +18 -0
- package/dist/xsd/resolve-content.js +242 -0
- package/dist/xsd/sample-generator.d.ts +51 -0
- package/dist/xsd/sample-generator.js +291 -0
- package/dist/xsd/sample-types.d.ts +21 -0
- package/dist/xsd/sample-types.js +69 -0
- package/dist/xsd/sample-values.d.ts +54 -0
- package/dist/xsd/sample-values.js +267 -0
- package/dist/xsd/schema-set.d.ts +51 -0
- package/dist/xsd/schema-set.js +203 -0
- package/dist/xsd/xml-scan.d.ts +64 -0
- package/dist/xsd/xml-scan.js +286 -0
- package/dist/xsd/xml-writer.d.ts +56 -0
- package/dist/xsd/xml-writer.js +103 -0
- package/package.json +69 -0
|
@@ -0,0 +1,435 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sending one gRPC call over HTTP/2 with Node's `http2` module.
|
|
3
|
+
*
|
|
4
|
+
* gRPC is HTTP/2 with a fixed shape: a `POST` to `/<service>/<method>`, `content-type:
|
|
5
|
+
* application/grpc`, `te: trailers`, each message length-prefixed in the body, and the outcome in
|
|
6
|
+
* `grpc-status`/`grpc-message` trailers (or in the headers, for a "trailers-only" response). The
|
|
7
|
+
* REST transport's HTTP client hides trailers and buffers bodies, which is exactly what a server
|
|
8
|
+
* stream must not have, so this module speaks HTTP/2 directly. It knows nothing about protobuf:
|
|
9
|
+
* messages arrive and leave as bytes, and `call.ts` is where the codec meets the wire.
|
|
10
|
+
*
|
|
11
|
+
* A non-`OK` status is a result, not an error — the user asked what the server would say, and it
|
|
12
|
+
* said `NOT_FOUND`. Only a failure to get an answer at all (connection, TLS, an abort, a malformed
|
|
13
|
+
* stream) throws.
|
|
14
|
+
*/
|
|
15
|
+
import { Buffer } from 'node:buffer';
|
|
16
|
+
import http2 from 'node:http2';
|
|
17
|
+
import { gunzipSync, inflateSync } from 'node:zlib';
|
|
18
|
+
import { GrpcError } from '../errors.js';
|
|
19
|
+
import { toHttpError } from '../http/errors.js';
|
|
20
|
+
import { captureSslInfo } from '../http/tls.js';
|
|
21
|
+
import { encodeGrpcFrame, GrpcFrameParser } from './framing.js';
|
|
22
|
+
import { grpcMethodPath } from './model.js';
|
|
23
|
+
import { decodeGrpcMessage, formatGrpcTimeout, grpcStatusName } from './status.js';
|
|
24
|
+
import { parseGrpcTarget } from './target.js';
|
|
25
|
+
export { parseGrpcTarget } from './target.js';
|
|
26
|
+
/** Headers no metadata row may set: the protocol owns them. */
|
|
27
|
+
const RESERVED_HEADERS = new Set(['te', 'content-type', 'grpc-timeout', 'grpc-encoding', 'grpc-accept-encoding']);
|
|
28
|
+
/** The `authorization` or custom header credentials become, as the HTTP transport spells them. */
|
|
29
|
+
function authHeaders(auth) {
|
|
30
|
+
if (auth === undefined) {
|
|
31
|
+
return {};
|
|
32
|
+
}
|
|
33
|
+
switch (auth.type) {
|
|
34
|
+
case 'bearer':
|
|
35
|
+
return { authorization: `${auth.scheme ?? 'Bearer'} ${auth.token}` };
|
|
36
|
+
case 'oauth2':
|
|
37
|
+
return { authorization: `Bearer ${auth.accessToken}` };
|
|
38
|
+
case 'api-key':
|
|
39
|
+
return { [auth.name.toLowerCase()]: auth.value };
|
|
40
|
+
case 'basic':
|
|
41
|
+
return { authorization: `Basic ${Buffer.from(`${auth.username}:${auth.password}`, 'utf8').toString('base64')}` };
|
|
42
|
+
default:
|
|
43
|
+
throw new GrpcError('grpc-auth-unsupported', 'NTLM cannot authenticate a gRPC call; it is an HTTP/1.1 connection handshake.', {
|
|
44
|
+
details: { type: auth.type },
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/** Builds the request headers: protocol first, then host defaults, credentials, and the user's rows last. */
|
|
49
|
+
export function buildGrpcHeaders(input, target) {
|
|
50
|
+
const headers = {
|
|
51
|
+
':method': 'POST',
|
|
52
|
+
':scheme': target.tls ? 'https' : 'http',
|
|
53
|
+
':authority': target.authority,
|
|
54
|
+
':path': grpcMethodPath(input.service, input.method),
|
|
55
|
+
'content-type': 'application/grpc+proto',
|
|
56
|
+
te: 'trailers',
|
|
57
|
+
'grpc-accept-encoding': 'identity,gzip,deflate',
|
|
58
|
+
'grpc-timeout': formatGrpcTimeout(input.timeoutMs),
|
|
59
|
+
};
|
|
60
|
+
for (const [name, value] of Object.entries(input.defaultMetadata ?? {})) {
|
|
61
|
+
headers[name.toLowerCase()] = value;
|
|
62
|
+
}
|
|
63
|
+
for (const [name, value] of Object.entries(authHeaders(input.auth))) {
|
|
64
|
+
headers[name] = value;
|
|
65
|
+
}
|
|
66
|
+
for (const row of input.metadata) {
|
|
67
|
+
if (!row.enabled || row.name.trim() === '') {
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
70
|
+
const name = row.name.trim().toLowerCase();
|
|
71
|
+
if (name.startsWith(':') || RESERVED_HEADERS.has(name)) {
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
headers[name] = row.value;
|
|
75
|
+
}
|
|
76
|
+
return headers;
|
|
77
|
+
}
|
|
78
|
+
function headerText(headers) {
|
|
79
|
+
return `${Object.entries(headers)
|
|
80
|
+
.map(([name, value]) => `${name}: ${value}`)
|
|
81
|
+
.join('\r\n')}\r\n\r\n`;
|
|
82
|
+
}
|
|
83
|
+
/** Flattens Node's incoming headers to one string per name, dropping pseudo-headers. */
|
|
84
|
+
function flatten(headers) {
|
|
85
|
+
const out = {};
|
|
86
|
+
for (const [name, value] of Object.entries(headers)) {
|
|
87
|
+
if (name.startsWith(':') || value === undefined) {
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
out[name] = Array.isArray(value) ? value.join(', ') : String(value);
|
|
91
|
+
}
|
|
92
|
+
return out;
|
|
93
|
+
}
|
|
94
|
+
/** The gRPC status the specification says an HTTP status without a `grpc-status` maps to. */
|
|
95
|
+
function statusFromHttp(httpStatus) {
|
|
96
|
+
switch (httpStatus) {
|
|
97
|
+
case 400:
|
|
98
|
+
return 13;
|
|
99
|
+
case 401:
|
|
100
|
+
return 16;
|
|
101
|
+
case 403:
|
|
102
|
+
return 7;
|
|
103
|
+
case 404:
|
|
104
|
+
return 12;
|
|
105
|
+
case 429:
|
|
106
|
+
case 502:
|
|
107
|
+
case 503:
|
|
108
|
+
case 504:
|
|
109
|
+
return 14;
|
|
110
|
+
default:
|
|
111
|
+
return 2;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
function decompress(payload, encoding) {
|
|
115
|
+
switch ((encoding ?? 'identity').toLowerCase()) {
|
|
116
|
+
case 'identity':
|
|
117
|
+
return payload;
|
|
118
|
+
case 'gzip':
|
|
119
|
+
return new Uint8Array(gunzipSync(payload));
|
|
120
|
+
case 'deflate':
|
|
121
|
+
return new Uint8Array(inflateSync(payload));
|
|
122
|
+
default:
|
|
123
|
+
throw new GrpcError('grpc-encoding-unsupported', `The server compressed the response with "${encoding ?? ''}", which this client cannot read`, {
|
|
124
|
+
details: { encoding },
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
function concat(parts) {
|
|
129
|
+
const total = parts.reduce((sum, part) => sum + part.byteLength, 0);
|
|
130
|
+
const out = new Uint8Array(total);
|
|
131
|
+
let offset = 0;
|
|
132
|
+
for (const part of parts) {
|
|
133
|
+
out.set(part, offset);
|
|
134
|
+
offset += part.byteLength;
|
|
135
|
+
}
|
|
136
|
+
return out;
|
|
137
|
+
}
|
|
138
|
+
function connectOptions(input, target) {
|
|
139
|
+
const tls = input.tlsOptions;
|
|
140
|
+
return {
|
|
141
|
+
...(input.localAddress !== undefined ? { localAddress: input.localAddress } : {}),
|
|
142
|
+
...(target.tls
|
|
143
|
+
? {
|
|
144
|
+
...(tls?.rejectUnauthorized !== undefined ? { rejectUnauthorized: tls.rejectUnauthorized } : {}),
|
|
145
|
+
...(tls?.ca !== undefined ? { ca: [...tls.ca] } : {}),
|
|
146
|
+
...(tls?.cert !== undefined ? { cert: tls.cert } : {}),
|
|
147
|
+
...(tls?.key !== undefined ? { key: tls.key } : {}),
|
|
148
|
+
...(tls?.passphrase !== undefined ? { passphrase: tls.passphrase } : {}),
|
|
149
|
+
...(tls?.minVersion !== undefined ? { minVersion: tls.minVersion } : {}),
|
|
150
|
+
servername: tls?.servername ?? (/^[\d.]+$|:/.test(target.host) ? '' : target.host),
|
|
151
|
+
ALPNProtocols: ['h2'],
|
|
152
|
+
}
|
|
153
|
+
: {}),
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Sends one gRPC call and collects every response message and the final status.
|
|
158
|
+
*
|
|
159
|
+
* Client-streaming and bidirectional methods are sent in "batch" form: every request message is
|
|
160
|
+
* written, the request side is closed, and the responses are read until the server ends the stream.
|
|
161
|
+
* {@link GrpcSendInput.onOpen} turns that into an interactive call instead, where the caller keeps
|
|
162
|
+
* pushing messages until it half-closes.
|
|
163
|
+
*
|
|
164
|
+
* {@link GrpcSendInput.onHeaders} and {@link GrpcSendInput.onMessage} report the initial metadata
|
|
165
|
+
* and each response message as they arrive, for a caller that shows a stream while it runs.
|
|
166
|
+
*
|
|
167
|
+
* @throws HttpError for a connection, DNS, TLS or abort failure, with the HTTP transport's codes;
|
|
168
|
+
* GrpcError `grpc-target-invalid`, `grpc-auth-unsupported`, `grpc-stream-malformed`,
|
|
169
|
+
* `grpc-encoding-unsupported`, `grpc-message-too-large`, `grpc-stream-closed`
|
|
170
|
+
*/
|
|
171
|
+
export async function sendGrpc(input) {
|
|
172
|
+
const target = parseGrpcTarget(input.target, input.tls);
|
|
173
|
+
const now = input.now ?? (() => performance.now());
|
|
174
|
+
const startedAtMs = now();
|
|
175
|
+
const startedAt = new Date().toISOString();
|
|
176
|
+
const requestHeaders = buildGrpcHeaders(input, target);
|
|
177
|
+
// What was actually sent, which in interactive mode grows after the call opens; the exchange
|
|
178
|
+
// reports these rather than `input.messages` so its record and its raw bytes stay the same thing.
|
|
179
|
+
const sent = [...input.messages];
|
|
180
|
+
const sentFrames = sent.map((message) => encodeGrpcFrame(message));
|
|
181
|
+
const origin = `${target.tls ? 'https' : 'http'}://${target.authority}`;
|
|
182
|
+
const session = http2.connect(origin, connectOptions(input, target));
|
|
183
|
+
let connectMs;
|
|
184
|
+
let tlsInfo;
|
|
185
|
+
session.once('connect', () => {
|
|
186
|
+
connectMs = now() - startedAtMs;
|
|
187
|
+
// `session.socket` is a Proxy that answers property reads but not the `in` operator.
|
|
188
|
+
const socket = session.socket;
|
|
189
|
+
if (target.tls && typeof socket?.getPeerCertificate === 'function') {
|
|
190
|
+
tlsInfo = captureSslInfo(socket);
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
return new Promise((resolve, reject) => {
|
|
194
|
+
let settled = false;
|
|
195
|
+
let stream;
|
|
196
|
+
let deadlineHit = false;
|
|
197
|
+
let userAborted = false;
|
|
198
|
+
let headersAt;
|
|
199
|
+
let responseHeaders = {};
|
|
200
|
+
let httpStatus = 0;
|
|
201
|
+
let trailers = {};
|
|
202
|
+
const parser = new GrpcFrameParser();
|
|
203
|
+
let sessionError;
|
|
204
|
+
const rawFrames = [];
|
|
205
|
+
const messages = [];
|
|
206
|
+
let received = 0;
|
|
207
|
+
let truncated = false;
|
|
208
|
+
let encoding;
|
|
209
|
+
const cleanup = () => {
|
|
210
|
+
clearTimeout(deadline);
|
|
211
|
+
input.signal?.removeEventListener('abort', onAbort);
|
|
212
|
+
session.close();
|
|
213
|
+
};
|
|
214
|
+
const fail = (error) => {
|
|
215
|
+
if (settled)
|
|
216
|
+
return;
|
|
217
|
+
settled = true;
|
|
218
|
+
cleanup();
|
|
219
|
+
if (error instanceof GrpcError) {
|
|
220
|
+
reject(error);
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
reject(toHttpError(error, { userAborted, deadlineHit: false, host: target.authority }));
|
|
224
|
+
};
|
|
225
|
+
const finish = (local) => {
|
|
226
|
+
if (settled)
|
|
227
|
+
return;
|
|
228
|
+
settled = true;
|
|
229
|
+
const endMs = now();
|
|
230
|
+
cleanup();
|
|
231
|
+
let status;
|
|
232
|
+
let statusMessage;
|
|
233
|
+
let statusSource;
|
|
234
|
+
const trailerStatus = trailers['grpc-status'];
|
|
235
|
+
const headerStatus = responseHeaders['grpc-status'];
|
|
236
|
+
if (local !== undefined) {
|
|
237
|
+
status = local.status;
|
|
238
|
+
statusMessage = local.message;
|
|
239
|
+
statusSource = 'local';
|
|
240
|
+
}
|
|
241
|
+
else if (trailerStatus !== undefined) {
|
|
242
|
+
status = Number(trailerStatus);
|
|
243
|
+
statusMessage = trailers['grpc-message'];
|
|
244
|
+
statusSource = 'trailers';
|
|
245
|
+
}
|
|
246
|
+
else if (headerStatus !== undefined) {
|
|
247
|
+
status = Number(headerStatus);
|
|
248
|
+
statusMessage = responseHeaders['grpc-message'];
|
|
249
|
+
statusSource = 'headers';
|
|
250
|
+
}
|
|
251
|
+
else if (httpStatus !== 200) {
|
|
252
|
+
status = statusFromHttp(httpStatus);
|
|
253
|
+
statusMessage = `HTTP status ${String(httpStatus)} without a grpc-status`;
|
|
254
|
+
statusSource = 'http';
|
|
255
|
+
}
|
|
256
|
+
else {
|
|
257
|
+
status = 2;
|
|
258
|
+
statusMessage = 'The server ended the stream without a grpc-status';
|
|
259
|
+
statusSource = 'http';
|
|
260
|
+
}
|
|
261
|
+
if (Number.isNaN(status)) {
|
|
262
|
+
status = 2;
|
|
263
|
+
statusMessage = `Unreadable grpc-status "${trailerStatus ?? headerStatus ?? ''}"`;
|
|
264
|
+
}
|
|
265
|
+
const decodedMessage = statusMessage === undefined ? undefined : decodeGrpcMessage(statusMessage);
|
|
266
|
+
const responseText = `HTTP/2 ${String(httpStatus)}\r\n${headerText(responseHeaders)}`;
|
|
267
|
+
const trailerText = Object.keys(trailers).length > 0 ? `\r\n${headerText(trailers)}` : '';
|
|
268
|
+
const totalMs = endMs - startedAtMs;
|
|
269
|
+
resolve({
|
|
270
|
+
request: {
|
|
271
|
+
authority: target.authority,
|
|
272
|
+
path: requestHeaders[':path'] ?? '',
|
|
273
|
+
headers: requestHeaders,
|
|
274
|
+
messages: sent,
|
|
275
|
+
},
|
|
276
|
+
httpStatus,
|
|
277
|
+
headers: responseHeaders,
|
|
278
|
+
trailers,
|
|
279
|
+
status,
|
|
280
|
+
statusName: grpcStatusName(status),
|
|
281
|
+
...(decodedMessage !== undefined && decodedMessage !== '' ? { statusMessage: decodedMessage } : {}),
|
|
282
|
+
statusSource,
|
|
283
|
+
messages,
|
|
284
|
+
...(encoding !== undefined && encoding !== 'identity' ? { encoding } : {}),
|
|
285
|
+
truncated,
|
|
286
|
+
timings: {
|
|
287
|
+
startedAt,
|
|
288
|
+
totalMs,
|
|
289
|
+
...(connectMs !== undefined ? { connectMs } : {}),
|
|
290
|
+
...(headersAt !== undefined ? { ttfbMs: headersAt - startedAtMs, downloadMs: endMs - headersAt } : {}),
|
|
291
|
+
},
|
|
292
|
+
...(tlsInfo !== undefined ? { tls: tlsInfo } : {}),
|
|
293
|
+
rawRequest: concat([new TextEncoder().encode(headerText(requestHeaders)), ...sentFrames]),
|
|
294
|
+
rawResponse: concat([
|
|
295
|
+
new TextEncoder().encode(responseText),
|
|
296
|
+
...rawFrames,
|
|
297
|
+
new TextEncoder().encode(trailerText),
|
|
298
|
+
]),
|
|
299
|
+
durationMs: totalMs,
|
|
300
|
+
});
|
|
301
|
+
};
|
|
302
|
+
const onAbort = () => {
|
|
303
|
+
userAborted = true;
|
|
304
|
+
stream?.close(http2.constants.NGHTTP2_CANCEL);
|
|
305
|
+
fail(new Error('aborted'));
|
|
306
|
+
};
|
|
307
|
+
const deadline = setTimeout(() => {
|
|
308
|
+
deadlineHit = true;
|
|
309
|
+
stream?.close(http2.constants.NGHTTP2_CANCEL);
|
|
310
|
+
finish({
|
|
311
|
+
status: 4,
|
|
312
|
+
message: `Deadline of ${formatGrpcTimeout(input.timeoutMs)} exceeded before the server answered`,
|
|
313
|
+
});
|
|
314
|
+
}, input.timeoutMs);
|
|
315
|
+
if (input.signal?.aborted === true) {
|
|
316
|
+
onAbort();
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
input.signal?.addEventListener('abort', onAbort, { once: true });
|
|
320
|
+
session.on('error', (error) => {
|
|
321
|
+
sessionError = error;
|
|
322
|
+
fail(error);
|
|
323
|
+
});
|
|
324
|
+
session.on('close', () => {
|
|
325
|
+
if (!settled && !deadlineHit) {
|
|
326
|
+
fail(new GrpcError('grpc-stream-malformed', 'The connection closed before the call completed', {
|
|
327
|
+
details: { httpStatus },
|
|
328
|
+
}));
|
|
329
|
+
}
|
|
330
|
+
});
|
|
331
|
+
const outgoing = { ...requestHeaders };
|
|
332
|
+
try {
|
|
333
|
+
stream = session.request(outgoing);
|
|
334
|
+
}
|
|
335
|
+
catch (error) {
|
|
336
|
+
fail(error);
|
|
337
|
+
return;
|
|
338
|
+
}
|
|
339
|
+
// A refused connection or a failed handshake reaches the stream as "the pending stream has been
|
|
340
|
+
// cancelled" as well as the session as the real cause; wait a tick so the cause wins.
|
|
341
|
+
stream.on('error', (error) => {
|
|
342
|
+
setImmediate(() => fail(sessionError ?? error));
|
|
343
|
+
});
|
|
344
|
+
stream.on('response', (headers) => {
|
|
345
|
+
headersAt = now();
|
|
346
|
+
httpStatus = Number(headers[':status'] ?? 0);
|
|
347
|
+
responseHeaders = flatten(headers);
|
|
348
|
+
encoding = responseHeaders['grpc-encoding'];
|
|
349
|
+
const contentType = responseHeaders['content-type'] ?? '';
|
|
350
|
+
if (httpStatus === 200 && !contentType.toLowerCase().startsWith('application/grpc')) {
|
|
351
|
+
fail(new GrpcError('grpc-stream-malformed', `The server answered with "${contentType}" rather than application/grpc; is ${target.authority} a gRPC server?`, {
|
|
352
|
+
details: { contentType, httpStatus },
|
|
353
|
+
}));
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
356
|
+
input.onHeaders?.(responseHeaders, httpStatus);
|
|
357
|
+
});
|
|
358
|
+
stream.on('data', (chunk) => {
|
|
359
|
+
if (settled)
|
|
360
|
+
return;
|
|
361
|
+
rawFrames.push(new Uint8Array(chunk));
|
|
362
|
+
try {
|
|
363
|
+
for (const frame of parser.push(new Uint8Array(chunk))) {
|
|
364
|
+
received += frame.payload.byteLength;
|
|
365
|
+
if (input.maxSizeBytes !== undefined && received > input.maxSizeBytes) {
|
|
366
|
+
truncated = true;
|
|
367
|
+
break;
|
|
368
|
+
}
|
|
369
|
+
const message = frame.compressed ? decompress(frame.payload, encoding) : frame.payload;
|
|
370
|
+
messages.push(message);
|
|
371
|
+
input.onMessage?.(message, messages.length - 1);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
catch (error) {
|
|
375
|
+
fail(error);
|
|
376
|
+
return;
|
|
377
|
+
}
|
|
378
|
+
if (truncated) {
|
|
379
|
+
stream?.close(http2.constants.NGHTTP2_CANCEL);
|
|
380
|
+
finish();
|
|
381
|
+
}
|
|
382
|
+
});
|
|
383
|
+
stream.on('trailers', (headers) => {
|
|
384
|
+
trailers = flatten(headers);
|
|
385
|
+
});
|
|
386
|
+
stream.on('end', () => {
|
|
387
|
+
if (parser.pending > 0 && !truncated) {
|
|
388
|
+
fail(new GrpcError('grpc-stream-malformed', `The stream ended in the middle of a message (${String(parser.pending)} bytes left over)`, {
|
|
389
|
+
details: { pending: parser.pending },
|
|
390
|
+
}));
|
|
391
|
+
return;
|
|
392
|
+
}
|
|
393
|
+
finish();
|
|
394
|
+
});
|
|
395
|
+
for (const frame of sentFrames) {
|
|
396
|
+
stream.write(Buffer.from(frame));
|
|
397
|
+
}
|
|
398
|
+
if (input.onOpen === undefined) {
|
|
399
|
+
stream.end();
|
|
400
|
+
return;
|
|
401
|
+
}
|
|
402
|
+
// Interactive: the request side stays open until the caller half-closes, the deadline passes or
|
|
403
|
+
// the signal aborts. `settled` covers all three, so a handle held past the end is inert rather
|
|
404
|
+
// than writing to a dead stream.
|
|
405
|
+
let halfClosed = false;
|
|
406
|
+
const open = stream;
|
|
407
|
+
try {
|
|
408
|
+
input.onOpen({
|
|
409
|
+
write: (message) => {
|
|
410
|
+
if (settled || halfClosed) {
|
|
411
|
+
throw new GrpcError('grpc-stream-closed', 'The request side of this call is already closed', {
|
|
412
|
+
details: { halfClosed, settled },
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
sent.push(message);
|
|
416
|
+
const frame = encodeGrpcFrame(message);
|
|
417
|
+
sentFrames.push(frame);
|
|
418
|
+
open.write(Buffer.from(frame));
|
|
419
|
+
},
|
|
420
|
+
end: () => {
|
|
421
|
+
if (halfClosed)
|
|
422
|
+
return;
|
|
423
|
+
halfClosed = true;
|
|
424
|
+
if (!settled) {
|
|
425
|
+
open.end();
|
|
426
|
+
}
|
|
427
|
+
},
|
|
428
|
+
isOpen: () => !settled && !halfClosed,
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
catch (error) {
|
|
432
|
+
fail(error);
|
|
433
|
+
}
|
|
434
|
+
});
|
|
435
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The pure shape rules of a gRPC method and target: what a kind means, how a method's `:path` is
|
|
3
|
+
* spelled, and whether an address implies TLS.
|
|
4
|
+
*
|
|
5
|
+
* A leaf on purpose. `model.ts` needs `project/paths.js` for its slugs, and that reaches
|
|
6
|
+
* `node:path`, which a renderer bundle cannot have — so the handful of rules the editor also needs
|
|
7
|
+
* live here, with no imports at all, and `model.ts` re-exports them so nothing else moved.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* The four shapes a gRPC method can take, as the `.proto` declares them with the `stream` keyword.
|
|
11
|
+
* Recorded on the request so the editor knows how many messages to expect on each side even when
|
|
12
|
+
* the definition is not to hand.
|
|
13
|
+
*/
|
|
14
|
+
export type GrpcMethodKind = 'unary' | 'server-streaming' | 'client-streaming' | 'bidi-streaming';
|
|
15
|
+
/** Which server-reflection protocol to speak; `auto` tries v1 and falls back to v1alpha. */
|
|
16
|
+
export type GrpcReflectionVersion = 'auto' | 'v1' | 'v1alpha';
|
|
17
|
+
/** The versions a user can pick, in the order the selector offers them. */
|
|
18
|
+
export declare const GRPC_REFLECTION_VERSIONS: readonly GrpcReflectionVersion[];
|
|
19
|
+
/** The HTTP/2 `:path` of a method call: `/<service>/<method>`. */
|
|
20
|
+
export declare function grpcMethodPath(service: string, method: string): string;
|
|
21
|
+
/** Whether the client side of a method sends a stream, so the message text is an array. */
|
|
22
|
+
export declare function clientStreams(kind: GrpcMethodKind): boolean;
|
|
23
|
+
/** Whether the server side of a method answers with a stream. */
|
|
24
|
+
export declare function serverStreams(kind: GrpcMethodKind): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Whether a target implies TLS when the API has not said: an explicit `grpcs://`/`https://` scheme,
|
|
27
|
+
* or port 443. Anything else defaults to plaintext, as `grpcurl` does.
|
|
28
|
+
*/
|
|
29
|
+
export declare function defaultTlsFor(target: string): boolean;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The pure shape rules of a gRPC method and target: what a kind means, how a method's `:path` is
|
|
3
|
+
* spelled, and whether an address implies TLS.
|
|
4
|
+
*
|
|
5
|
+
* A leaf on purpose. `model.ts` needs `project/paths.js` for its slugs, and that reaches
|
|
6
|
+
* `node:path`, which a renderer bundle cannot have — so the handful of rules the editor also needs
|
|
7
|
+
* live here, with no imports at all, and `model.ts` re-exports them so nothing else moved.
|
|
8
|
+
*/
|
|
9
|
+
/** The versions a user can pick, in the order the selector offers them. */
|
|
10
|
+
export const GRPC_REFLECTION_VERSIONS = ['auto', 'v1', 'v1alpha'];
|
|
11
|
+
/** The HTTP/2 `:path` of a method call: `/<service>/<method>`. */
|
|
12
|
+
export function grpcMethodPath(service, method) {
|
|
13
|
+
return `/${service}/${method}`;
|
|
14
|
+
}
|
|
15
|
+
/** Whether the client side of a method sends a stream, so the message text is an array. */
|
|
16
|
+
export function clientStreams(kind) {
|
|
17
|
+
return kind === 'client-streaming' || kind === 'bidi-streaming';
|
|
18
|
+
}
|
|
19
|
+
/** Whether the server side of a method answers with a stream. */
|
|
20
|
+
export function serverStreams(kind) {
|
|
21
|
+
return kind === 'server-streaming' || kind === 'bidi-streaming';
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Whether a target implies TLS when the API has not said: an explicit `grpcs://`/`https://` scheme,
|
|
25
|
+
* or port 443. Anything else defaults to plaintext, as `grpcurl` does.
|
|
26
|
+
*/
|
|
27
|
+
export function defaultTlsFor(target) {
|
|
28
|
+
const trimmed = target.trim().toLowerCase();
|
|
29
|
+
if (trimmed.startsWith('grpcs://') || trimmed.startsWith('https://')) {
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
if (trimmed.startsWith('grpc://') || trimmed.startsWith('http://')) {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
return /:443$/.test(trimmed);
|
|
36
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* gRPC status codes, as the protocol's status specification numbers and names them, and the
|
|
3
|
+
* `grpc-message` percent-encoding that carries a status message in an HTTP/2 trailer.
|
|
4
|
+
*/
|
|
5
|
+
/** The seventeen status codes. `0` is the only success. */
|
|
6
|
+
export declare const GRPC_STATUS_NAMES: Readonly<Record<number, string>>;
|
|
7
|
+
/** The name of a status code, or `UNKNOWN (n)` for a number the specification does not define. */
|
|
8
|
+
export declare function grpcStatusName(code: number): string;
|
|
9
|
+
/**
|
|
10
|
+
* Decodes a `grpc-message` trailer value. The specification percent-encodes anything outside
|
|
11
|
+
* printable ASCII; a malformed sequence is kept as-is rather than failing the whole response, since
|
|
12
|
+
* the message is for a person to read.
|
|
13
|
+
*/
|
|
14
|
+
export declare function decodeGrpcMessage(value: string): string;
|
|
15
|
+
/** Percent-encodes a status message for a `grpc-message` trailer, as a server would. */
|
|
16
|
+
export declare function encodeGrpcMessage(value: string): string;
|
|
17
|
+
/**
|
|
18
|
+
* Formats a deadline as a `grpc-timeout` header value: the largest unit that keeps the number to
|
|
19
|
+
* at most eight digits, as the specification requires.
|
|
20
|
+
*/
|
|
21
|
+
export declare function formatGrpcTimeout(timeoutMs: number): string;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* gRPC status codes, as the protocol's status specification numbers and names them, and the
|
|
3
|
+
* `grpc-message` percent-encoding that carries a status message in an HTTP/2 trailer.
|
|
4
|
+
*/
|
|
5
|
+
/** The seventeen status codes. `0` is the only success. */
|
|
6
|
+
export const GRPC_STATUS_NAMES = Object.freeze({
|
|
7
|
+
0: 'OK',
|
|
8
|
+
1: 'CANCELLED',
|
|
9
|
+
2: 'UNKNOWN',
|
|
10
|
+
3: 'INVALID_ARGUMENT',
|
|
11
|
+
4: 'DEADLINE_EXCEEDED',
|
|
12
|
+
5: 'NOT_FOUND',
|
|
13
|
+
6: 'ALREADY_EXISTS',
|
|
14
|
+
7: 'PERMISSION_DENIED',
|
|
15
|
+
8: 'RESOURCE_EXHAUSTED',
|
|
16
|
+
9: 'FAILED_PRECONDITION',
|
|
17
|
+
10: 'ABORTED',
|
|
18
|
+
11: 'OUT_OF_RANGE',
|
|
19
|
+
12: 'UNIMPLEMENTED',
|
|
20
|
+
13: 'INTERNAL',
|
|
21
|
+
14: 'UNAVAILABLE',
|
|
22
|
+
15: 'DATA_LOSS',
|
|
23
|
+
16: 'UNAUTHENTICATED',
|
|
24
|
+
});
|
|
25
|
+
/** The name of a status code, or `UNKNOWN (n)` for a number the specification does not define. */
|
|
26
|
+
export function grpcStatusName(code) {
|
|
27
|
+
return GRPC_STATUS_NAMES[code] ?? `UNKNOWN (${String(code)})`;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Decodes a `grpc-message` trailer value. The specification percent-encodes anything outside
|
|
31
|
+
* printable ASCII; a malformed sequence is kept as-is rather than failing the whole response, since
|
|
32
|
+
* the message is for a person to read.
|
|
33
|
+
*/
|
|
34
|
+
export function decodeGrpcMessage(value) {
|
|
35
|
+
try {
|
|
36
|
+
return decodeURIComponent(value);
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return value;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/** Percent-encodes a status message for a `grpc-message` trailer, as a server would. */
|
|
43
|
+
export function encodeGrpcMessage(value) {
|
|
44
|
+
return Array.from(new TextEncoder().encode(value), (byte) => byte >= 0x20 && byte <= 0x7e && byte !== 0x25
|
|
45
|
+
? String.fromCharCode(byte)
|
|
46
|
+
: `%${byte.toString(16).toUpperCase().padStart(2, '0')}`).join('');
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Formats a deadline as a `grpc-timeout` header value: the largest unit that keeps the number to
|
|
50
|
+
* at most eight digits, as the specification requires.
|
|
51
|
+
*/
|
|
52
|
+
export function formatGrpcTimeout(timeoutMs) {
|
|
53
|
+
const ms = Math.max(1, Math.round(timeoutMs));
|
|
54
|
+
if (ms < 100_000_000) {
|
|
55
|
+
return `${String(ms)}m`;
|
|
56
|
+
}
|
|
57
|
+
const seconds = Math.ceil(ms / 1000);
|
|
58
|
+
if (seconds < 100_000_000) {
|
|
59
|
+
return `${String(seconds)}S`;
|
|
60
|
+
}
|
|
61
|
+
return `${String(Math.ceil(seconds / 3600))}H`;
|
|
62
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reading a gRPC target as the user typed it. Pure, so the renderer can show the effective
|
|
3
|
+
* authority beside the field through the browser-safe `@wirebench/engine/grpc` subpath and agree
|
|
4
|
+
* with what the transport connects to.
|
|
5
|
+
*/
|
|
6
|
+
/** A parsed `host:port` target. */
|
|
7
|
+
export interface GrpcTarget {
|
|
8
|
+
readonly host: string;
|
|
9
|
+
readonly port: number;
|
|
10
|
+
/** `host:port`, brackets kept around an IPv6 literal. */
|
|
11
|
+
readonly authority: string;
|
|
12
|
+
readonly tls: boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Parses what the user typed as a target: `host:port`, `[::1]:50051`, or a URL whose scheme
|
|
16
|
+
* (`grpc`, `grpcs`, `http`, `https`, `dns`) settles TLS. Without a port, TLS implies 443 and plain
|
|
17
|
+
* implies 80, which is what an HTTP-shaped target means.
|
|
18
|
+
*
|
|
19
|
+
* @throws GrpcError `grpc-target-invalid`
|
|
20
|
+
*/
|
|
21
|
+
export declare function parseGrpcTarget(target: string, tls: boolean): GrpcTarget;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reading a gRPC target as the user typed it. Pure, so the renderer can show the effective
|
|
3
|
+
* authority beside the field through the browser-safe `@wirebench/engine/grpc` subpath and agree
|
|
4
|
+
* with what the transport connects to.
|
|
5
|
+
*/
|
|
6
|
+
import { GrpcError } from '../errors.js';
|
|
7
|
+
/**
|
|
8
|
+
* Parses what the user typed as a target: `host:port`, `[::1]:50051`, or a URL whose scheme
|
|
9
|
+
* (`grpc`, `grpcs`, `http`, `https`, `dns`) settles TLS. Without a port, TLS implies 443 and plain
|
|
10
|
+
* implies 80, which is what an HTTP-shaped target means.
|
|
11
|
+
*
|
|
12
|
+
* @throws GrpcError `grpc-target-invalid`
|
|
13
|
+
*/
|
|
14
|
+
export function parseGrpcTarget(target, tls) {
|
|
15
|
+
const trimmed = target.trim();
|
|
16
|
+
if (trimmed === '') {
|
|
17
|
+
throw new GrpcError('grpc-target-invalid', 'The target is empty. Enter the server as host:port.');
|
|
18
|
+
}
|
|
19
|
+
let useTls = tls;
|
|
20
|
+
let rest = trimmed;
|
|
21
|
+
const scheme = /^([a-z][a-z0-9+.-]*):\/\//i.exec(trimmed);
|
|
22
|
+
if (scheme !== null) {
|
|
23
|
+
const name = scheme[1].toLowerCase();
|
|
24
|
+
if (name === 'grpcs' || name === 'https') {
|
|
25
|
+
useTls = true;
|
|
26
|
+
}
|
|
27
|
+
else if (name === 'grpc' || name === 'http') {
|
|
28
|
+
useTls = false;
|
|
29
|
+
}
|
|
30
|
+
else if (name !== 'dns') {
|
|
31
|
+
throw new GrpcError('grpc-target-invalid', `"${scheme[1]}" is not a scheme a gRPC target can use`, {
|
|
32
|
+
details: { target },
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
rest = trimmed.slice(scheme[0].length).replace(/^\/+/, '');
|
|
36
|
+
}
|
|
37
|
+
// Cut at the first path, query or fragment character with a scan rather than a regex over the
|
|
38
|
+
// whole remainder.
|
|
39
|
+
for (let index = 0; index < rest.length; index += 1) {
|
|
40
|
+
const char = rest[index];
|
|
41
|
+
if (char === '/' || char === '?' || char === '#') {
|
|
42
|
+
rest = rest.slice(0, index);
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
let url;
|
|
47
|
+
try {
|
|
48
|
+
url = new URL(`http://${rest}`);
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
throw new GrpcError('grpc-target-invalid', `"${target}" is not a host:port target`, {
|
|
52
|
+
cause: error,
|
|
53
|
+
details: { target },
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
if (url.hostname === '' || url.username !== '' || url.password !== '') {
|
|
57
|
+
throw new GrpcError('grpc-target-invalid', `"${target}" is not a host:port target`, { details: { target } });
|
|
58
|
+
}
|
|
59
|
+
const port = url.port === '' ? (useTls ? 443 : 80) : Number(url.port);
|
|
60
|
+
return {
|
|
61
|
+
host: url.hostname.replace(/^\[|\]$/g, ''),
|
|
62
|
+
port,
|
|
63
|
+
authority: `${url.hostname}:${String(port)}`,
|
|
64
|
+
tls: useTls,
|
|
65
|
+
};
|
|
66
|
+
}
|