@blade-hq/agent-client 1.1.1 → 1.1.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/README.md +48 -25
- package/dist/blade-client.d.ts +2 -14
- package/dist/index.d.ts +5 -2
- package/dist/index.js +212 -106
- package/dist/index.js.map +1 -1
- package/dist/resources/models.d.ts +15 -0
- package/dist/resources/sessions.d.ts +8 -1
- package/dist/session/agent-session.d.ts +10 -0
- package/dist/session/definition.d.ts +49 -0
- package/dist/shared/projection/helpers.d.ts +1 -1
- package/dist/types/rest.d.ts +378 -10
- package/dist/version.d.ts +4 -42
- package/node_modules/@ark/schema/LICENSE +7 -0
- package/node_modules/@ark/schema/README.md +18 -0
- package/node_modules/@ark/schema/out/config.d.ts +58 -0
- package/node_modules/@ark/schema/out/config.js +95 -0
- package/node_modules/@ark/schema/out/constraint.d.ts +67 -0
- package/node_modules/@ark/schema/out/constraint.js +136 -0
- package/node_modules/@ark/schema/out/generic.d.ts +73 -0
- package/node_modules/@ark/schema/out/generic.js +76 -0
- package/node_modules/@ark/schema/out/index.d.ts +47 -0
- package/node_modules/@ark/schema/out/index.js +47 -0
- package/node_modules/@ark/schema/out/intrinsic.d.ts +24 -0
- package/node_modules/@ark/schema/out/intrinsic.js +56 -0
- package/node_modules/@ark/schema/out/kinds.d.ts +73 -0
- package/node_modules/@ark/schema/out/kinds.js +71 -0
- package/node_modules/@ark/schema/out/module.d.ts +24 -0
- package/node_modules/@ark/schema/out/module.js +15 -0
- package/node_modules/@ark/schema/out/node.d.ts +154 -0
- package/node_modules/@ark/schema/out/node.js +438 -0
- package/node_modules/@ark/schema/out/parse.d.ts +52 -0
- package/node_modules/@ark/schema/out/parse.js +215 -0
- package/node_modules/@ark/schema/out/predicate.d.ts +52 -0
- package/node_modules/@ark/schema/out/predicate.js +63 -0
- package/node_modules/@ark/schema/out/refinements/after.d.ts +41 -0
- package/node_modules/@ark/schema/out/refinements/after.js +35 -0
- package/node_modules/@ark/schema/out/refinements/before.d.ts +41 -0
- package/node_modules/@ark/schema/out/refinements/before.js +41 -0
- package/node_modules/@ark/schema/out/refinements/divisor.d.ts +43 -0
- package/node_modules/@ark/schema/out/refinements/divisor.js +58 -0
- package/node_modules/@ark/schema/out/refinements/exactLength.d.ts +49 -0
- package/node_modules/@ark/schema/out/refinements/exactLength.js +55 -0
- package/node_modules/@ark/schema/out/refinements/kinds.d.ts +34 -0
- package/node_modules/@ark/schema/out/refinements/kinds.js +25 -0
- package/node_modules/@ark/schema/out/refinements/max.d.ts +37 -0
- package/node_modules/@ark/schema/out/refinements/max.js +45 -0
- package/node_modules/@ark/schema/out/refinements/maxLength.d.ts +40 -0
- package/node_modules/@ark/schema/out/refinements/maxLength.js +49 -0
- package/node_modules/@ark/schema/out/refinements/min.d.ts +37 -0
- package/node_modules/@ark/schema/out/refinements/min.js +39 -0
- package/node_modules/@ark/schema/out/refinements/minLength.d.ts +40 -0
- package/node_modules/@ark/schema/out/refinements/minLength.js +47 -0
- package/node_modules/@ark/schema/out/refinements/pattern.d.ts +43 -0
- package/node_modules/@ark/schema/out/refinements/pattern.js +52 -0
- package/node_modules/@ark/schema/out/refinements/range.d.ts +106 -0
- package/node_modules/@ark/schema/out/refinements/range.js +103 -0
- package/node_modules/@ark/schema/out/roots/alias.d.ts +45 -0
- package/node_modules/@ark/schema/out/roots/alias.js +115 -0
- package/node_modules/@ark/schema/out/roots/basis.d.ts +12 -0
- package/node_modules/@ark/schema/out/roots/basis.js +26 -0
- package/node_modules/@ark/schema/out/roots/domain.d.ts +45 -0
- package/node_modules/@ark/schema/out/roots/domain.js +72 -0
- package/node_modules/@ark/schema/out/roots/intersection.d.ts +98 -0
- package/node_modules/@ark/schema/out/roots/intersection.js +292 -0
- package/node_modules/@ark/schema/out/roots/morph.d.ts +62 -0
- package/node_modules/@ark/schema/out/roots/morph.js +159 -0
- package/node_modules/@ark/schema/out/roots/proto.d.ts +53 -0
- package/node_modules/@ark/schema/out/roots/proto.js +101 -0
- package/node_modules/@ark/schema/out/roots/root.d.ts +145 -0
- package/node_modules/@ark/schema/out/roots/root.js +455 -0
- package/node_modules/@ark/schema/out/roots/union.d.ts +99 -0
- package/node_modules/@ark/schema/out/roots/union.js +718 -0
- package/node_modules/@ark/schema/out/roots/unit.d.ts +41 -0
- package/node_modules/@ark/schema/out/roots/unit.js +86 -0
- package/node_modules/@ark/schema/out/roots/utils.d.ts +3 -0
- package/node_modules/@ark/schema/out/roots/utils.js +6 -0
- package/node_modules/@ark/schema/out/scope.d.ts +158 -0
- package/node_modules/@ark/schema/out/scope.js +481 -0
- package/node_modules/@ark/schema/out/shared/compile.d.ts +62 -0
- package/node_modules/@ark/schema/out/shared/compile.js +145 -0
- package/node_modules/@ark/schema/out/shared/declare.d.ts +80 -0
- package/node_modules/@ark/schema/out/shared/declare.js +1 -0
- package/node_modules/@ark/schema/out/shared/disjoint.d.ts +41 -0
- package/node_modules/@ark/schema/out/shared/disjoint.js +65 -0
- package/node_modules/@ark/schema/out/shared/errors.d.ts +145 -0
- package/node_modules/@ark/schema/out/shared/errors.js +252 -0
- package/node_modules/@ark/schema/out/shared/implement.d.ts +151 -0
- package/node_modules/@ark/schema/out/shared/implement.js +98 -0
- package/node_modules/@ark/schema/out/shared/intersections.d.ts +10 -0
- package/node_modules/@ark/schema/out/shared/intersections.js +132 -0
- package/node_modules/@ark/schema/out/shared/jsonSchema.d.ts +93 -0
- package/node_modules/@ark/schema/out/shared/jsonSchema.js +1 -0
- package/node_modules/@ark/schema/out/shared/registry.d.ts +7 -0
- package/node_modules/@ark/schema/out/shared/registry.js +10 -0
- package/node_modules/@ark/schema/out/shared/standardSchema.d.ts +122 -0
- package/node_modules/@ark/schema/out/shared/standardSchema.js +2 -0
- package/node_modules/@ark/schema/out/shared/toJsonSchema.d.ts +139 -0
- package/node_modules/@ark/schema/out/shared/toJsonSchema.js +40 -0
- package/node_modules/@ark/schema/out/shared/traversal.d.ts +117 -0
- package/node_modules/@ark/schema/out/shared/traversal.js +226 -0
- package/node_modules/@ark/schema/out/shared/utils.d.ts +34 -0
- package/node_modules/@ark/schema/out/shared/utils.js +8 -0
- package/node_modules/@ark/schema/out/structure/index.d.ts +46 -0
- package/node_modules/@ark/schema/out/structure/index.js +89 -0
- package/node_modules/@ark/schema/out/structure/optional.d.ts +49 -0
- package/node_modules/@ark/schema/out/structure/optional.js +127 -0
- package/node_modules/@ark/schema/out/structure/prop.d.ts +45 -0
- package/node_modules/@ark/schema/out/structure/prop.js +85 -0
- package/node_modules/@ark/schema/out/structure/required.d.ts +39 -0
- package/node_modules/@ark/schema/out/structure/required.js +38 -0
- package/node_modules/@ark/schema/out/structure/sequence.d.ts +110 -0
- package/node_modules/@ark/schema/out/structure/sequence.js +521 -0
- package/node_modules/@ark/schema/out/structure/shared.d.ts +4 -0
- package/node_modules/@ark/schema/out/structure/shared.js +4 -0
- package/node_modules/@ark/schema/out/structure/structure.d.ts +113 -0
- package/node_modules/@ark/schema/out/structure/structure.js +747 -0
- package/node_modules/@ark/schema/package.json +51 -0
- package/node_modules/@ark/util/LICENSE +7 -0
- package/node_modules/@ark/util/out/arrays.d.ts +166 -0
- package/node_modules/@ark/util/out/arrays.js +147 -0
- package/node_modules/@ark/util/out/clone.d.ts +4 -0
- package/node_modules/@ark/util/out/clone.js +33 -0
- package/node_modules/@ark/util/out/describe.d.ts +25 -0
- package/node_modules/@ark/util/out/describe.js +1 -0
- package/node_modules/@ark/util/out/domain.d.ts +48 -0
- package/node_modules/@ark/util/out/domain.js +25 -0
- package/node_modules/@ark/util/out/errors.d.ts +29 -0
- package/node_modules/@ark/util/out/errors.js +17 -0
- package/node_modules/@ark/util/out/flatMorph.d.ts +41 -0
- package/node_modules/@ark/util/out/flatMorph.js +24 -0
- package/node_modules/@ark/util/out/functions.d.ts +33 -0
- package/node_modules/@ark/util/out/functions.js +53 -0
- package/node_modules/@ark/util/out/generics.d.ts +59 -0
- package/node_modules/@ark/util/out/generics.js +5 -0
- package/node_modules/@ark/util/out/get.d.ts +9 -0
- package/node_modules/@ark/util/out/get.js +7 -0
- package/node_modules/@ark/util/out/hkt.d.ts +27 -0
- package/node_modules/@ark/util/out/hkt.js +5 -0
- package/node_modules/@ark/util/out/index.d.ts +24 -0
- package/node_modules/@ark/util/out/index.js +24 -0
- package/node_modules/@ark/util/out/intersections.d.ts +50 -0
- package/node_modules/@ark/util/out/intersections.js +1 -0
- package/node_modules/@ark/util/out/isomorphic.d.ts +5 -0
- package/node_modules/@ark/util/out/isomorphic.js +19 -0
- package/node_modules/@ark/util/out/keys.d.ts +18 -0
- package/node_modules/@ark/util/out/keys.js +1 -0
- package/node_modules/@ark/util/out/lazily.d.ts +1 -0
- package/node_modules/@ark/util/out/lazily.js +16 -0
- package/node_modules/@ark/util/out/numbers.d.ts +72 -0
- package/node_modules/@ark/util/out/numbers.js +138 -0
- package/node_modules/@ark/util/out/objectKinds.d.ts +205 -0
- package/node_modules/@ark/util/out/objectKinds.js +150 -0
- package/node_modules/@ark/util/out/path.d.ts +22 -0
- package/node_modules/@ark/util/out/path.js +65 -0
- package/node_modules/@ark/util/out/primitive.d.ts +16 -0
- package/node_modules/@ark/util/out/primitive.js +3 -0
- package/node_modules/@ark/util/out/records.d.ts +183 -0
- package/node_modules/@ark/util/out/records.js +63 -0
- package/node_modules/@ark/util/out/registry.d.ts +21 -0
- package/node_modules/@ark/util/out/registry.js +49 -0
- package/node_modules/@ark/util/out/scanner.d.ts +44 -0
- package/node_modules/@ark/util/out/scanner.js +87 -0
- package/node_modules/@ark/util/out/serialize.d.ts +34 -0
- package/node_modules/@ark/util/out/serialize.js +150 -0
- package/node_modules/@ark/util/out/strings.d.ts +33 -0
- package/node_modules/@ark/util/out/strings.js +59 -0
- package/node_modules/@ark/util/out/traits.d.ts +89 -0
- package/node_modules/@ark/util/out/traits.js +75 -0
- package/node_modules/@ark/util/out/unionToTuple.d.ts +14 -0
- package/node_modules/@ark/util/out/unionToTuple.js +1 -0
- package/node_modules/@ark/util/package.json +39 -0
- package/node_modules/@ark/util/tsconfig.base.json +18 -0
- package/node_modules/@socket.io/component-emitter/LICENSE +24 -0
- package/node_modules/@socket.io/component-emitter/Readme.md +79 -0
- package/node_modules/@socket.io/component-emitter/lib/cjs/index.d.ts +179 -0
- package/node_modules/@socket.io/component-emitter/lib/cjs/index.js +176 -0
- package/node_modules/@socket.io/component-emitter/lib/cjs/package.json +4 -0
- package/node_modules/@socket.io/component-emitter/lib/esm/index.d.ts +179 -0
- package/node_modules/@socket.io/component-emitter/lib/esm/index.js +169 -0
- package/node_modules/@socket.io/component-emitter/lib/esm/package.json +4 -0
- package/node_modules/@socket.io/component-emitter/package.json +28 -0
- package/node_modules/arkregex/LICENSE +7 -0
- package/node_modules/arkregex/README.md +61 -0
- package/node_modules/arkregex/out/charset.d.ts +15 -0
- package/node_modules/arkregex/out/charset.js +1 -0
- package/node_modules/arkregex/out/escape.d.ts +29 -0
- package/node_modules/arkregex/out/escape.js +10 -0
- package/node_modules/arkregex/out/execArray.d.ts +23 -0
- package/node_modules/arkregex/out/execArray.js +1 -0
- package/node_modules/arkregex/out/group.d.ts +33 -0
- package/node_modules/arkregex/out/group.js +6 -0
- package/node_modules/arkregex/out/index.d.ts +1 -0
- package/node_modules/arkregex/out/index.js +1 -0
- package/node_modules/arkregex/out/parse.d.ts +10 -0
- package/node_modules/arkregex/out/parse.js +1 -0
- package/node_modules/arkregex/out/quantify.d.ts +43 -0
- package/node_modules/arkregex/out/quantify.js +2 -0
- package/node_modules/arkregex/out/regex.d.ts +38 -0
- package/node_modules/arkregex/out/regex.js +2 -0
- package/node_modules/arkregex/out/state.d.ts +359 -0
- package/node_modules/arkregex/out/state.js +2 -0
- package/node_modules/arkregex/package.json +42 -0
- package/node_modules/arktype/LICENSE +7 -0
- package/node_modules/arktype/README.md +157 -0
- package/node_modules/arktype/out/attributes.d.ts +104 -0
- package/node_modules/arktype/out/attributes.js +3 -0
- package/node_modules/arktype/out/config.d.ts +35 -0
- package/node_modules/arktype/out/config.js +3 -0
- package/node_modules/arktype/out/declare.d.ts +35 -0
- package/node_modules/arktype/out/declare.js +1 -0
- package/node_modules/arktype/out/fn.d.ts +61 -0
- package/node_modules/arktype/out/fn.js +54 -0
- package/node_modules/arktype/out/generic.d.ts +118 -0
- package/node_modules/arktype/out/generic.js +37 -0
- package/node_modules/arktype/out/index.d.ts +12 -0
- package/node_modules/arktype/out/index.js +9 -0
- package/node_modules/arktype/out/keywords/Array.d.ts +20 -0
- package/node_modules/arktype/out/keywords/Array.js +21 -0
- package/node_modules/arktype/out/keywords/FormData.d.ts +15 -0
- package/node_modules/arktype/out/keywords/FormData.js +40 -0
- package/node_modules/arktype/out/keywords/TypedArray.d.ts +19 -0
- package/node_modules/arktype/out/keywords/TypedArray.js +16 -0
- package/node_modules/arktype/out/keywords/builtins.d.ts +18 -0
- package/node_modules/arktype/out/keywords/builtins.js +11 -0
- package/node_modules/arktype/out/keywords/constructors.d.ts +31 -0
- package/node_modules/arktype/out/keywords/constructors.js +16 -0
- package/node_modules/arktype/out/keywords/keywords.d.ts +70 -0
- package/node_modules/arktype/out/keywords/keywords.js +48 -0
- package/node_modules/arktype/out/keywords/number.d.ts +23 -0
- package/node_modules/arktype/out/keywords/number.js +49 -0
- package/node_modules/arktype/out/keywords/string.d.ts +334 -0
- package/node_modules/arktype/out/keywords/string.js +463 -0
- package/node_modules/arktype/out/keywords/ts.d.ts +108 -0
- package/node_modules/arktype/out/keywords/ts.js +82 -0
- package/node_modules/arktype/out/match.d.ts +152 -0
- package/node_modules/arktype/out/match.js +95 -0
- package/node_modules/arktype/out/module.d.ts +22 -0
- package/node_modules/arktype/out/module.js +3 -0
- package/node_modules/arktype/out/nary.d.ts +473 -0
- package/node_modules/arktype/out/nary.js +1 -0
- package/node_modules/arktype/out/parser/ast/bounds.d.ts +18 -0
- package/node_modules/arktype/out/parser/ast/bounds.js +1 -0
- package/node_modules/arktype/out/parser/ast/default.d.ts +8 -0
- package/node_modules/arktype/out/parser/ast/default.js +1 -0
- package/node_modules/arktype/out/parser/ast/divisor.d.ts +9 -0
- package/node_modules/arktype/out/parser/ast/divisor.js +1 -0
- package/node_modules/arktype/out/parser/ast/generic.d.ts +17 -0
- package/node_modules/arktype/out/parser/ast/generic.js +1 -0
- package/node_modules/arktype/out/parser/ast/infer.d.ts +25 -0
- package/node_modules/arktype/out/parser/ast/infer.js +1 -0
- package/node_modules/arktype/out/parser/ast/keyof.d.ts +7 -0
- package/node_modules/arktype/out/parser/ast/keyof.js +1 -0
- package/node_modules/arktype/out/parser/ast/utils.d.ts +8 -0
- package/node_modules/arktype/out/parser/ast/utils.js +1 -0
- package/node_modules/arktype/out/parser/ast/validate.d.ts +30 -0
- package/node_modules/arktype/out/parser/ast/validate.js +3 -0
- package/node_modules/arktype/out/parser/definition.d.ts +30 -0
- package/node_modules/arktype/out/parser/definition.js +74 -0
- package/node_modules/arktype/out/parser/objectLiteral.d.ts +70 -0
- package/node_modules/arktype/out/parser/objectLiteral.js +113 -0
- package/node_modules/arktype/out/parser/property.d.ts +34 -0
- package/node_modules/arktype/out/parser/property.js +16 -0
- package/node_modules/arktype/out/parser/reduce/dynamic.d.ts +42 -0
- package/node_modules/arktype/out/parser/reduce/dynamic.js +153 -0
- package/node_modules/arktype/out/parser/reduce/shared.d.ts +39 -0
- package/node_modules/arktype/out/parser/reduce/shared.js +25 -0
- package/node_modules/arktype/out/parser/reduce/static.d.ts +186 -0
- package/node_modules/arktype/out/parser/reduce/static.js +1 -0
- package/node_modules/arktype/out/parser/shift/operand/date.d.ts +11 -0
- package/node_modules/arktype/out/parser/shift/operand/date.js +23 -0
- package/node_modules/arktype/out/parser/shift/operand/enclosed.d.ts +57 -0
- package/node_modules/arktype/out/parser/shift/operand/enclosed.js +78 -0
- package/node_modules/arktype/out/parser/shift/operand/genericArgs.d.ts +27 -0
- package/node_modules/arktype/out/parser/shift/operand/genericArgs.js +16 -0
- package/node_modules/arktype/out/parser/shift/operand/operand.d.ts +8 -0
- package/node_modules/arktype/out/parser/shift/operand/operand.js +16 -0
- package/node_modules/arktype/out/parser/shift/operand/unenclosed.d.ts +43 -0
- package/node_modules/arktype/out/parser/shift/operand/unenclosed.js +59 -0
- package/node_modules/arktype/out/parser/shift/operator/bounds.d.ts +24 -0
- package/node_modules/arktype/out/parser/shift/operator/bounds.js +91 -0
- package/node_modules/arktype/out/parser/shift/operator/brand.d.ts +7 -0
- package/node_modules/arktype/out/parser/shift/operator/brand.js +6 -0
- package/node_modules/arktype/out/parser/shift/operator/default.d.ts +24 -0
- package/node_modules/arktype/out/parser/shift/operator/default.js +15 -0
- package/node_modules/arktype/out/parser/shift/operator/divisor.d.ts +8 -0
- package/node_modules/arktype/out/parser/shift/operator/divisor.js +13 -0
- package/node_modules/arktype/out/parser/shift/operator/operator.d.ts +14 -0
- package/node_modules/arktype/out/parser/shift/operator/operator.js +28 -0
- package/node_modules/arktype/out/parser/shift/tokens.d.ts +33 -0
- package/node_modules/arktype/out/parser/shift/tokens.js +37 -0
- package/node_modules/arktype/out/parser/string.d.ts +30 -0
- package/node_modules/arktype/out/parser/string.js +42 -0
- package/node_modules/arktype/out/parser/tupleExpressions.d.ts +79 -0
- package/node_modules/arktype/out/parser/tupleExpressions.js +75 -0
- package/node_modules/arktype/out/parser/tupleLiteral.d.ts +95 -0
- package/node_modules/arktype/out/parser/tupleLiteral.js +128 -0
- package/node_modules/arktype/out/scope.d.ts +158 -0
- package/node_modules/arktype/out/scope.js +106 -0
- package/node_modules/arktype/out/type.d.ts +144 -0
- package/node_modules/arktype/out/type.js +55 -0
- package/node_modules/arktype/out/variants/array.d.ts +12 -0
- package/node_modules/arktype/out/variants/array.js +1 -0
- package/node_modules/arktype/out/variants/base.d.ts +542 -0
- package/node_modules/arktype/out/variants/base.js +1 -0
- package/node_modules/arktype/out/variants/date.d.ts +10 -0
- package/node_modules/arktype/out/variants/date.js +1 -0
- package/node_modules/arktype/out/variants/instantiate.d.ts +12 -0
- package/node_modules/arktype/out/variants/instantiate.js +1 -0
- package/node_modules/arktype/out/variants/number.d.ts +11 -0
- package/node_modules/arktype/out/variants/number.js +1 -0
- package/node_modules/arktype/out/variants/object.d.ts +107 -0
- package/node_modules/arktype/out/variants/object.js +1 -0
- package/node_modules/arktype/out/variants/string.d.ts +15 -0
- package/node_modules/arktype/out/variants/string.js +1 -0
- package/node_modules/arktype/package.json +57 -0
- package/node_modules/debug/LICENSE +20 -0
- package/node_modules/debug/README.md +481 -0
- package/node_modules/debug/package.json +64 -0
- package/node_modules/debug/src/browser.js +272 -0
- package/node_modules/debug/src/common.js +292 -0
- package/node_modules/debug/src/index.js +10 -0
- package/node_modules/debug/src/node.js +263 -0
- package/node_modules/engine.io-client/LICENSE +22 -0
- package/node_modules/engine.io-client/README.md +331 -0
- package/node_modules/engine.io-client/build/cjs/browser-entrypoint.d.ts +3 -0
- package/node_modules/engine.io-client/build/cjs/browser-entrypoint.js +4 -0
- package/node_modules/engine.io-client/build/cjs/contrib/has-cors.d.ts +1 -0
- package/node_modules/engine.io-client/build/cjs/contrib/has-cors.js +14 -0
- package/node_modules/engine.io-client/build/cjs/contrib/parseqs.d.ts +15 -0
- package/node_modules/engine.io-client/build/cjs/contrib/parseqs.js +38 -0
- package/node_modules/engine.io-client/build/cjs/contrib/parseuri.d.ts +1 -0
- package/node_modules/engine.io-client/build/cjs/contrib/parseuri.js +67 -0
- package/node_modules/engine.io-client/build/cjs/globals.d.ts +4 -0
- package/node_modules/engine.io-client/build/cjs/globals.js +26 -0
- package/node_modules/engine.io-client/build/cjs/globals.node.d.ts +21 -0
- package/node_modules/engine.io-client/build/cjs/globals.node.js +97 -0
- package/node_modules/engine.io-client/build/cjs/index.d.ts +15 -0
- package/node_modules/engine.io-client/build/cjs/index.js +32 -0
- package/node_modules/engine.io-client/build/cjs/package.json +10 -0
- package/node_modules/engine.io-client/build/cjs/socket.d.ts +482 -0
- package/node_modules/engine.io-client/build/cjs/socket.js +765 -0
- package/node_modules/engine.io-client/build/cjs/transport.d.ts +106 -0
- package/node_modules/engine.io-client/build/cjs/transport.js +153 -0
- package/node_modules/engine.io-client/build/cjs/transports/index.d.ts +8 -0
- package/node_modules/engine.io-client/build/cjs/transports/index.js +11 -0
- package/node_modules/engine.io-client/build/cjs/transports/polling-fetch.d.ts +15 -0
- package/node_modules/engine.io-client/build/cjs/transports/polling-fetch.js +60 -0
- package/node_modules/engine.io-client/build/cjs/transports/polling-xhr.d.ts +108 -0
- package/node_modules/engine.io-client/build/cjs/transports/polling-xhr.js +285 -0
- package/node_modules/engine.io-client/build/cjs/transports/polling-xhr.node.d.ts +11 -0
- package/node_modules/engine.io-client/build/cjs/transports/polling-xhr.node.js +44 -0
- package/node_modules/engine.io-client/build/cjs/transports/polling.d.ts +52 -0
- package/node_modules/engine.io-client/build/cjs/transports/polling.js +165 -0
- package/node_modules/engine.io-client/build/cjs/transports/websocket.d.ts +36 -0
- package/node_modules/engine.io-client/build/cjs/transports/websocket.js +136 -0
- package/node_modules/engine.io-client/build/cjs/transports/websocket.node.d.ts +14 -0
- package/node_modules/engine.io-client/build/cjs/transports/websocket.node.js +68 -0
- package/node_modules/engine.io-client/build/cjs/transports/webtransport.d.ts +18 -0
- package/node_modules/engine.io-client/build/cjs/transports/webtransport.js +94 -0
- package/node_modules/engine.io-client/build/cjs/util.d.ts +7 -0
- package/node_modules/engine.io-client/build/cjs/util.js +65 -0
- package/node_modules/engine.io-client/build/esm/browser-entrypoint.d.ts +3 -0
- package/node_modules/engine.io-client/build/esm/browser-entrypoint.js +2 -0
- package/node_modules/engine.io-client/build/esm/contrib/has-cors.d.ts +1 -0
- package/node_modules/engine.io-client/build/esm/contrib/has-cors.js +11 -0
- package/node_modules/engine.io-client/build/esm/contrib/parseqs.d.ts +15 -0
- package/node_modules/engine.io-client/build/esm/contrib/parseqs.js +34 -0
- package/node_modules/engine.io-client/build/esm/contrib/parseuri.d.ts +1 -0
- package/node_modules/engine.io-client/build/esm/contrib/parseuri.js +64 -0
- package/node_modules/engine.io-client/build/esm/globals.d.ts +4 -0
- package/node_modules/engine.io-client/build/esm/globals.js +22 -0
- package/node_modules/engine.io-client/build/esm/globals.node.d.ts +21 -0
- package/node_modules/engine.io-client/build/esm/globals.node.js +91 -0
- package/node_modules/engine.io-client/build/esm/index.d.ts +15 -0
- package/node_modules/engine.io-client/build/esm/index.js +15 -0
- package/node_modules/engine.io-client/build/esm/package.json +10 -0
- package/node_modules/engine.io-client/build/esm/socket.d.ts +482 -0
- package/node_modules/engine.io-client/build/esm/socket.js +727 -0
- package/node_modules/engine.io-client/build/esm/transport.d.ts +106 -0
- package/node_modules/engine.io-client/build/esm/transport.js +142 -0
- package/node_modules/engine.io-client/build/esm/transports/index.d.ts +8 -0
- package/node_modules/engine.io-client/build/esm/transports/index.js +8 -0
- package/node_modules/engine.io-client/build/esm/transports/polling-fetch.d.ts +15 -0
- package/node_modules/engine.io-client/build/esm/transports/polling-fetch.js +56 -0
- package/node_modules/engine.io-client/build/esm/transports/polling-xhr.d.ts +108 -0
- package/node_modules/engine.io-client/build/esm/transports/polling-xhr.js +271 -0
- package/node_modules/engine.io-client/build/esm/transports/polling-xhr.node.d.ts +11 -0
- package/node_modules/engine.io-client/build/esm/transports/polling-xhr.node.js +17 -0
- package/node_modules/engine.io-client/build/esm/transports/polling.d.ts +52 -0
- package/node_modules/engine.io-client/build/esm/transports/polling.js +145 -0
- package/node_modules/engine.io-client/build/esm/transports/websocket.d.ts +36 -0
- package/node_modules/engine.io-client/build/esm/transports/websocket.js +125 -0
- package/node_modules/engine.io-client/build/esm/transports/websocket.node.d.ts +14 -0
- package/node_modules/engine.io-client/build/esm/transports/websocket.node.js +41 -0
- package/node_modules/engine.io-client/build/esm/transports/webtransport.d.ts +18 -0
- package/node_modules/engine.io-client/build/esm/transports/webtransport.js +80 -0
- package/node_modules/engine.io-client/build/esm/util.d.ts +7 -0
- package/node_modules/engine.io-client/build/esm/util.js +59 -0
- package/node_modules/engine.io-client/build/esm-debug/browser-entrypoint.d.ts +3 -0
- package/node_modules/engine.io-client/build/esm-debug/browser-entrypoint.js +2 -0
- package/node_modules/engine.io-client/build/esm-debug/contrib/has-cors.d.ts +1 -0
- package/node_modules/engine.io-client/build/esm-debug/contrib/has-cors.js +11 -0
- package/node_modules/engine.io-client/build/esm-debug/contrib/parseqs.d.ts +15 -0
- package/node_modules/engine.io-client/build/esm-debug/contrib/parseqs.js +34 -0
- package/node_modules/engine.io-client/build/esm-debug/contrib/parseuri.d.ts +1 -0
- package/node_modules/engine.io-client/build/esm-debug/contrib/parseuri.js +64 -0
- package/node_modules/engine.io-client/build/esm-debug/globals.d.ts +4 -0
- package/node_modules/engine.io-client/build/esm-debug/globals.js +22 -0
- package/node_modules/engine.io-client/build/esm-debug/globals.node.d.ts +21 -0
- package/node_modules/engine.io-client/build/esm-debug/globals.node.js +91 -0
- package/node_modules/engine.io-client/build/esm-debug/index.d.ts +15 -0
- package/node_modules/engine.io-client/build/esm-debug/index.js +15 -0
- package/node_modules/engine.io-client/build/esm-debug/package.json +10 -0
- package/node_modules/engine.io-client/build/esm-debug/socket.d.ts +482 -0
- package/node_modules/engine.io-client/build/esm-debug/socket.js +756 -0
- package/node_modules/engine.io-client/build/esm-debug/transport.d.ts +106 -0
- package/node_modules/engine.io-client/build/esm-debug/transport.js +145 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/index.d.ts +8 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/index.js +8 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/polling-fetch.d.ts +15 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/polling-fetch.js +56 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/polling-xhr.d.ts +108 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/polling-xhr.js +276 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/polling-xhr.node.d.ts +11 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/polling-xhr.node.js +17 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/polling.d.ts +52 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/polling.js +158 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/websocket.d.ts +36 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/websocket.js +128 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/websocket.node.d.ts +14 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/websocket.node.js +41 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/webtransport.d.ts +18 -0
- package/node_modules/engine.io-client/build/esm-debug/transports/webtransport.js +87 -0
- package/node_modules/engine.io-client/build/esm-debug/util.d.ts +7 -0
- package/node_modules/engine.io-client/build/esm-debug/util.js +59 -0
- package/node_modules/engine.io-client/dist/engine.io.esm.min.js +7 -0
- package/node_modules/engine.io-client/dist/engine.io.esm.min.js.map +1 -0
- package/node_modules/engine.io-client/dist/engine.io.js +3064 -0
- package/node_modules/engine.io-client/dist/engine.io.js.map +1 -0
- package/node_modules/engine.io-client/dist/engine.io.min.js +7 -0
- package/node_modules/engine.io-client/dist/engine.io.min.js.map +1 -0
- package/node_modules/engine.io-client/package.json +95 -0
- package/node_modules/engine.io-parser/LICENSE +22 -0
- package/node_modules/engine.io-parser/Readme.md +158 -0
- package/node_modules/engine.io-parser/build/cjs/commons.d.ts +14 -0
- package/node_modules/engine.io-parser/build/cjs/commons.js +19 -0
- package/node_modules/engine.io-parser/build/cjs/contrib/base64-arraybuffer.d.ts +2 -0
- package/node_modules/engine.io-parser/build/cjs/contrib/base64-arraybuffer.js +48 -0
- package/node_modules/engine.io-parser/build/cjs/decodePacket.browser.d.ts +2 -0
- package/node_modules/engine.io-parser/build/cjs/decodePacket.browser.js +66 -0
- package/node_modules/engine.io-parser/build/cjs/decodePacket.d.ts +2 -0
- package/node_modules/engine.io-parser/build/cjs/decodePacket.js +59 -0
- package/node_modules/engine.io-parser/build/cjs/encodePacket.browser.d.ts +4 -0
- package/node_modules/engine.io-parser/build/cjs/encodePacket.browser.js +72 -0
- package/node_modules/engine.io-parser/build/cjs/encodePacket.d.ts +3 -0
- package/node_modules/engine.io-parser/build/cjs/encodePacket.js +38 -0
- package/node_modules/engine.io-parser/build/cjs/index.d.ts +9 -0
- package/node_modules/engine.io-parser/build/cjs/index.js +164 -0
- package/node_modules/engine.io-parser/build/cjs/package.json +8 -0
- package/node_modules/engine.io-parser/build/esm/commons.d.ts +14 -0
- package/node_modules/engine.io-parser/build/esm/commons.js +14 -0
- package/node_modules/engine.io-parser/build/esm/contrib/base64-arraybuffer.d.ts +2 -0
- package/node_modules/engine.io-parser/build/esm/contrib/base64-arraybuffer.js +43 -0
- package/node_modules/engine.io-parser/build/esm/decodePacket.browser.d.ts +2 -0
- package/node_modules/engine.io-parser/build/esm/decodePacket.browser.js +62 -0
- package/node_modules/engine.io-parser/build/esm/decodePacket.d.ts +2 -0
- package/node_modules/engine.io-parser/build/esm/decodePacket.js +55 -0
- package/node_modules/engine.io-parser/build/esm/encodePacket.browser.d.ts +4 -0
- package/node_modules/engine.io-parser/build/esm/encodePacket.browser.js +68 -0
- package/node_modules/engine.io-parser/build/esm/encodePacket.d.ts +3 -0
- package/node_modules/engine.io-parser/build/esm/encodePacket.js +33 -0
- package/node_modules/engine.io-parser/build/esm/index.d.ts +9 -0
- package/node_modules/engine.io-parser/build/esm/index.js +156 -0
- package/node_modules/engine.io-parser/build/esm/package.json +8 -0
- package/node_modules/engine.io-parser/package.json +46 -0
- package/node_modules/ms/index.js +162 -0
- package/node_modules/ms/license.md +21 -0
- package/node_modules/ms/package.json +38 -0
- package/node_modules/ms/readme.md +59 -0
- package/node_modules/socket.io-client/LICENSE +21 -0
- package/node_modules/socket.io-client/README.md +29 -0
- package/node_modules/socket.io-client/build/cjs/browser-entrypoint.d.ts +2 -0
- package/node_modules/socket.io-client/build/cjs/browser-entrypoint.js +4 -0
- package/node_modules/socket.io-client/build/cjs/contrib/backo2.d.ts +12 -0
- package/node_modules/socket.io-client/build/cjs/contrib/backo2.js +69 -0
- package/node_modules/socket.io-client/build/cjs/index.d.ts +29 -0
- package/node_modules/socket.io-client/build/cjs/index.js +76 -0
- package/node_modules/socket.io-client/build/cjs/manager.d.ts +295 -0
- package/node_modules/socket.io-client/build/cjs/manager.js +416 -0
- package/node_modules/socket.io-client/build/cjs/on.d.ts +2 -0
- package/node_modules/socket.io-client/build/cjs/on.js +9 -0
- package/node_modules/socket.io-client/build/cjs/socket.d.ts +593 -0
- package/node_modules/socket.io-client/build/cjs/socket.js +909 -0
- package/node_modules/socket.io-client/build/cjs/url.d.ts +33 -0
- package/node_modules/socket.io-client/build/cjs/url.js +69 -0
- package/node_modules/socket.io-client/build/esm/browser-entrypoint.d.ts +2 -0
- package/node_modules/socket.io-client/build/esm/browser-entrypoint.js +2 -0
- package/node_modules/socket.io-client/build/esm/contrib/backo2.d.ts +12 -0
- package/node_modules/socket.io-client/build/esm/contrib/backo2.js +66 -0
- package/node_modules/socket.io-client/build/esm/index.d.ts +29 -0
- package/node_modules/socket.io-client/build/esm/index.js +58 -0
- package/node_modules/socket.io-client/build/esm/manager.d.ts +295 -0
- package/node_modules/socket.io-client/build/esm/manager.js +367 -0
- package/node_modules/socket.io-client/build/esm/on.d.ts +2 -0
- package/node_modules/socket.io-client/build/esm/on.js +6 -0
- package/node_modules/socket.io-client/build/esm/package.json +5 -0
- package/node_modules/socket.io-client/build/esm/socket.d.ts +593 -0
- package/node_modules/socket.io-client/build/esm/socket.js +880 -0
- package/node_modules/socket.io-client/build/esm/url.d.ts +33 -0
- package/node_modules/socket.io-client/build/esm/url.js +59 -0
- package/node_modules/socket.io-client/build/esm-debug/browser-entrypoint.d.ts +2 -0
- package/node_modules/socket.io-client/build/esm-debug/browser-entrypoint.js +2 -0
- package/node_modules/socket.io-client/build/esm-debug/contrib/backo2.d.ts +12 -0
- package/node_modules/socket.io-client/build/esm-debug/contrib/backo2.js +66 -0
- package/node_modules/socket.io-client/build/esm-debug/index.d.ts +29 -0
- package/node_modules/socket.io-client/build/esm-debug/index.js +62 -0
- package/node_modules/socket.io-client/build/esm-debug/manager.d.ts +295 -0
- package/node_modules/socket.io-client/build/esm-debug/manager.js +386 -0
- package/node_modules/socket.io-client/build/esm-debug/on.d.ts +2 -0
- package/node_modules/socket.io-client/build/esm-debug/on.js +6 -0
- package/node_modules/socket.io-client/build/esm-debug/package.json +5 -0
- package/node_modules/socket.io-client/build/esm-debug/socket.d.ts +593 -0
- package/node_modules/socket.io-client/build/esm-debug/socket.js +902 -0
- package/node_modules/socket.io-client/build/esm-debug/url.d.ts +33 -0
- package/node_modules/socket.io-client/build/esm-debug/url.js +63 -0
- package/node_modules/socket.io-client/dist/socket.io.esm.min.js +7 -0
- package/node_modules/socket.io-client/dist/socket.io.esm.min.js.map +1 -0
- package/node_modules/socket.io-client/dist/socket.io.js +4955 -0
- package/node_modules/socket.io-client/dist/socket.io.js.map +1 -0
- package/node_modules/socket.io-client/dist/socket.io.min.js +7 -0
- package/node_modules/socket.io-client/dist/socket.io.min.js.map +1 -0
- package/node_modules/socket.io-client/dist/socket.io.msgpack.min.js +7 -0
- package/node_modules/socket.io-client/dist/socket.io.msgpack.min.js.map +1 -0
- package/node_modules/socket.io-client/package.json +101 -0
- package/node_modules/socket.io-parser/LICENSE +20 -0
- package/node_modules/socket.io-parser/Readme.md +81 -0
- package/node_modules/socket.io-parser/build/cjs/binary.d.ts +20 -0
- package/node_modules/socket.io-parser/build/cjs/binary.js +87 -0
- package/node_modules/socket.io-parser/build/cjs/index.d.ts +91 -0
- package/node_modules/socket.io-parser/build/cjs/index.js +359 -0
- package/node_modules/socket.io-parser/build/cjs/is-binary.d.ts +7 -0
- package/node_modules/socket.io-parser/build/cjs/is-binary.js +54 -0
- package/node_modules/socket.io-parser/build/cjs/package.json +3 -0
- package/node_modules/socket.io-parser/build/esm/binary.d.ts +20 -0
- package/node_modules/socket.io-parser/build/esm/binary.js +83 -0
- package/node_modules/socket.io-parser/build/esm/index.d.ts +91 -0
- package/node_modules/socket.io-parser/build/esm/index.js +348 -0
- package/node_modules/socket.io-parser/build/esm/is-binary.d.ts +7 -0
- package/node_modules/socket.io-parser/build/esm/is-binary.js +50 -0
- package/node_modules/socket.io-parser/build/esm/package.json +3 -0
- package/node_modules/socket.io-parser/build/esm-debug/binary.d.ts +20 -0
- package/node_modules/socket.io-parser/build/esm-debug/binary.js +83 -0
- package/node_modules/socket.io-parser/build/esm-debug/index.d.ts +91 -0
- package/node_modules/socket.io-parser/build/esm-debug/index.js +353 -0
- package/node_modules/socket.io-parser/build/esm-debug/is-binary.d.ts +7 -0
- package/node_modules/socket.io-parser/build/esm-debug/is-binary.js +50 -0
- package/node_modules/socket.io-parser/build/esm-debug/package.json +3 -0
- package/node_modules/socket.io-parser/package.json +44 -0
- package/node_modules/ws/LICENSE +20 -0
- package/node_modules/ws/README.md +548 -0
- package/node_modules/ws/browser.js +8 -0
- package/node_modules/ws/index.js +13 -0
- package/node_modules/ws/lib/buffer-util.js +131 -0
- package/node_modules/ws/lib/constants.js +18 -0
- package/node_modules/ws/lib/event-target.js +292 -0
- package/node_modules/ws/lib/extension.js +203 -0
- package/node_modules/ws/lib/limiter.js +55 -0
- package/node_modules/ws/lib/permessage-deflate.js +528 -0
- package/node_modules/ws/lib/receiver.js +706 -0
- package/node_modules/ws/lib/sender.js +602 -0
- package/node_modules/ws/lib/stream.js +161 -0
- package/node_modules/ws/lib/subprotocol.js +62 -0
- package/node_modules/ws/lib/validation.js +152 -0
- package/node_modules/ws/lib/websocket-server.js +550 -0
- package/node_modules/ws/lib/websocket.js +1388 -0
- package/node_modules/ws/package.json +69 -0
- package/node_modules/ws/wrapper.mjs +8 -0
- package/node_modules/xmlhttprequest-ssl/LICENSE +22 -0
- package/node_modules/xmlhttprequest-ssl/README.md +67 -0
- package/node_modules/xmlhttprequest-ssl/lib/XMLHttpRequest.js +689 -0
- package/node_modules/xmlhttprequest-ssl/package.json +40 -0
- package/package.json +34 -4
- package/public-api.md +85 -23
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.decode = exports.encode = void 0;
|
|
4
|
+
// imported from https://github.com/socketio/base64-arraybuffer
|
|
5
|
+
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
6
|
+
// Use a lookup table to find the index.
|
|
7
|
+
const lookup = typeof Uint8Array === 'undefined' ? [] : new Uint8Array(256);
|
|
8
|
+
for (let i = 0; i < chars.length; i++) {
|
|
9
|
+
lookup[chars.charCodeAt(i)] = i;
|
|
10
|
+
}
|
|
11
|
+
const encode = (arraybuffer) => {
|
|
12
|
+
let bytes = new Uint8Array(arraybuffer), i, len = bytes.length, base64 = '';
|
|
13
|
+
for (i = 0; i < len; i += 3) {
|
|
14
|
+
base64 += chars[bytes[i] >> 2];
|
|
15
|
+
base64 += chars[((bytes[i] & 3) << 4) | (bytes[i + 1] >> 4)];
|
|
16
|
+
base64 += chars[((bytes[i + 1] & 15) << 2) | (bytes[i + 2] >> 6)];
|
|
17
|
+
base64 += chars[bytes[i + 2] & 63];
|
|
18
|
+
}
|
|
19
|
+
if (len % 3 === 2) {
|
|
20
|
+
base64 = base64.substring(0, base64.length - 1) + '=';
|
|
21
|
+
}
|
|
22
|
+
else if (len % 3 === 1) {
|
|
23
|
+
base64 = base64.substring(0, base64.length - 2) + '==';
|
|
24
|
+
}
|
|
25
|
+
return base64;
|
|
26
|
+
};
|
|
27
|
+
exports.encode = encode;
|
|
28
|
+
const decode = (base64) => {
|
|
29
|
+
let bufferLength = base64.length * 0.75, len = base64.length, i, p = 0, encoded1, encoded2, encoded3, encoded4;
|
|
30
|
+
if (base64[base64.length - 1] === '=') {
|
|
31
|
+
bufferLength--;
|
|
32
|
+
if (base64[base64.length - 2] === '=') {
|
|
33
|
+
bufferLength--;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const arraybuffer = new ArrayBuffer(bufferLength), bytes = new Uint8Array(arraybuffer);
|
|
37
|
+
for (i = 0; i < len; i += 4) {
|
|
38
|
+
encoded1 = lookup[base64.charCodeAt(i)];
|
|
39
|
+
encoded2 = lookup[base64.charCodeAt(i + 1)];
|
|
40
|
+
encoded3 = lookup[base64.charCodeAt(i + 2)];
|
|
41
|
+
encoded4 = lookup[base64.charCodeAt(i + 3)];
|
|
42
|
+
bytes[p++] = (encoded1 << 2) | (encoded2 >> 4);
|
|
43
|
+
bytes[p++] = ((encoded2 & 15) << 4) | (encoded3 >> 2);
|
|
44
|
+
bytes[p++] = ((encoded3 & 3) << 6) | (encoded4 & 63);
|
|
45
|
+
}
|
|
46
|
+
return arraybuffer;
|
|
47
|
+
};
|
|
48
|
+
exports.decode = decode;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.decodePacket = void 0;
|
|
4
|
+
const commons_js_1 = require("./commons.js");
|
|
5
|
+
const base64_arraybuffer_js_1 = require("./contrib/base64-arraybuffer.js");
|
|
6
|
+
const withNativeArrayBuffer = typeof ArrayBuffer === "function";
|
|
7
|
+
const decodePacket = (encodedPacket, binaryType) => {
|
|
8
|
+
if (typeof encodedPacket !== "string") {
|
|
9
|
+
return {
|
|
10
|
+
type: "message",
|
|
11
|
+
data: mapBinary(encodedPacket, binaryType),
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
const type = encodedPacket.charAt(0);
|
|
15
|
+
if (type === "b") {
|
|
16
|
+
return {
|
|
17
|
+
type: "message",
|
|
18
|
+
data: decodeBase64Packet(encodedPacket.substring(1), binaryType),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
const packetType = commons_js_1.PACKET_TYPES_REVERSE[type];
|
|
22
|
+
if (!packetType) {
|
|
23
|
+
return commons_js_1.ERROR_PACKET;
|
|
24
|
+
}
|
|
25
|
+
return encodedPacket.length > 1
|
|
26
|
+
? {
|
|
27
|
+
type: commons_js_1.PACKET_TYPES_REVERSE[type],
|
|
28
|
+
data: encodedPacket.substring(1),
|
|
29
|
+
}
|
|
30
|
+
: {
|
|
31
|
+
type: commons_js_1.PACKET_TYPES_REVERSE[type],
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
exports.decodePacket = decodePacket;
|
|
35
|
+
const decodeBase64Packet = (data, binaryType) => {
|
|
36
|
+
if (withNativeArrayBuffer) {
|
|
37
|
+
const decoded = (0, base64_arraybuffer_js_1.decode)(data);
|
|
38
|
+
return mapBinary(decoded, binaryType);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
return { base64: true, data }; // fallback for old browsers
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
const mapBinary = (data, binaryType) => {
|
|
45
|
+
switch (binaryType) {
|
|
46
|
+
case "blob":
|
|
47
|
+
if (data instanceof Blob) {
|
|
48
|
+
// from WebSocket + binaryType "blob"
|
|
49
|
+
return data;
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
// from HTTP long-polling or WebTransport
|
|
53
|
+
return new Blob([data]);
|
|
54
|
+
}
|
|
55
|
+
case "arraybuffer":
|
|
56
|
+
default:
|
|
57
|
+
if (data instanceof ArrayBuffer) {
|
|
58
|
+
// from HTTP long-polling (base64) or WebSocket + binaryType "arraybuffer"
|
|
59
|
+
return data;
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
// from WebTransport (Uint8Array)
|
|
63
|
+
return data.buffer;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.decodePacket = void 0;
|
|
4
|
+
const commons_js_1 = require("./commons.js");
|
|
5
|
+
const decodePacket = (encodedPacket, binaryType) => {
|
|
6
|
+
if (typeof encodedPacket !== "string") {
|
|
7
|
+
return {
|
|
8
|
+
type: "message",
|
|
9
|
+
data: mapBinary(encodedPacket, binaryType),
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
const type = encodedPacket.charAt(0);
|
|
13
|
+
if (type === "b") {
|
|
14
|
+
const buffer = Buffer.from(encodedPacket.substring(1), "base64");
|
|
15
|
+
return {
|
|
16
|
+
type: "message",
|
|
17
|
+
data: mapBinary(buffer, binaryType),
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
if (!commons_js_1.PACKET_TYPES_REVERSE[type]) {
|
|
21
|
+
return commons_js_1.ERROR_PACKET;
|
|
22
|
+
}
|
|
23
|
+
return encodedPacket.length > 1
|
|
24
|
+
? {
|
|
25
|
+
type: commons_js_1.PACKET_TYPES_REVERSE[type],
|
|
26
|
+
data: encodedPacket.substring(1),
|
|
27
|
+
}
|
|
28
|
+
: {
|
|
29
|
+
type: commons_js_1.PACKET_TYPES_REVERSE[type],
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
exports.decodePacket = decodePacket;
|
|
33
|
+
const mapBinary = (data, binaryType) => {
|
|
34
|
+
switch (binaryType) {
|
|
35
|
+
case "arraybuffer":
|
|
36
|
+
if (data instanceof ArrayBuffer) {
|
|
37
|
+
// from WebSocket & binaryType "arraybuffer"
|
|
38
|
+
return data;
|
|
39
|
+
}
|
|
40
|
+
else if (Buffer.isBuffer(data)) {
|
|
41
|
+
// from HTTP long-polling
|
|
42
|
+
return data.buffer.slice(data.byteOffset, data.byteOffset + data.byteLength);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
// from WebTransport (Uint8Array)
|
|
46
|
+
return data.buffer;
|
|
47
|
+
}
|
|
48
|
+
case "nodebuffer":
|
|
49
|
+
default:
|
|
50
|
+
if (Buffer.isBuffer(data)) {
|
|
51
|
+
// from HTTP long-polling or WebSocket & binaryType "nodebuffer" (default)
|
|
52
|
+
return data;
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
// from WebTransport (Uint8Array)
|
|
56
|
+
return Buffer.from(data);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Packet, RawData } from "./commons.js";
|
|
2
|
+
declare const encodePacket: ({ type, data }: Packet, supportsBinary: boolean, callback: (encodedPacket: RawData) => void) => void;
|
|
3
|
+
export declare function encodePacketToBinary(packet: Packet, callback: (encodedPacket: RawData) => void): void | Promise<void>;
|
|
4
|
+
export { encodePacket };
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.encodePacket = void 0;
|
|
4
|
+
exports.encodePacketToBinary = encodePacketToBinary;
|
|
5
|
+
const commons_js_1 = require("./commons.js");
|
|
6
|
+
const withNativeBlob = typeof Blob === "function" ||
|
|
7
|
+
(typeof Blob !== "undefined" &&
|
|
8
|
+
Object.prototype.toString.call(Blob) === "[object BlobConstructor]");
|
|
9
|
+
const withNativeArrayBuffer = typeof ArrayBuffer === "function";
|
|
10
|
+
// ArrayBuffer.isView method is not defined in IE10
|
|
11
|
+
const isView = (obj) => {
|
|
12
|
+
return typeof ArrayBuffer.isView === "function"
|
|
13
|
+
? ArrayBuffer.isView(obj)
|
|
14
|
+
: obj && obj.buffer instanceof ArrayBuffer;
|
|
15
|
+
};
|
|
16
|
+
const encodePacket = ({ type, data }, supportsBinary, callback) => {
|
|
17
|
+
if (withNativeBlob && data instanceof Blob) {
|
|
18
|
+
if (supportsBinary) {
|
|
19
|
+
return callback(data);
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
return encodeBlobAsBase64(data, callback);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
else if (withNativeArrayBuffer &&
|
|
26
|
+
(data instanceof ArrayBuffer || isView(data))) {
|
|
27
|
+
if (supportsBinary) {
|
|
28
|
+
return callback(data);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
return encodeBlobAsBase64(new Blob([data]), callback);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
// plain string
|
|
35
|
+
return callback(commons_js_1.PACKET_TYPES[type] + (data || ""));
|
|
36
|
+
};
|
|
37
|
+
exports.encodePacket = encodePacket;
|
|
38
|
+
const encodeBlobAsBase64 = (data, callback) => {
|
|
39
|
+
const fileReader = new FileReader();
|
|
40
|
+
fileReader.onload = function () {
|
|
41
|
+
const content = fileReader.result.split(",")[1];
|
|
42
|
+
callback("b" + (content || ""));
|
|
43
|
+
};
|
|
44
|
+
return fileReader.readAsDataURL(data);
|
|
45
|
+
};
|
|
46
|
+
function toArray(data) {
|
|
47
|
+
if (data instanceof Uint8Array) {
|
|
48
|
+
return data;
|
|
49
|
+
}
|
|
50
|
+
else if (data instanceof ArrayBuffer) {
|
|
51
|
+
return new Uint8Array(data);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
return new Uint8Array(data.buffer, data.byteOffset, data.byteLength);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
let TEXT_ENCODER;
|
|
58
|
+
function encodePacketToBinary(packet, callback) {
|
|
59
|
+
if (withNativeBlob && packet.data instanceof Blob) {
|
|
60
|
+
return packet.data.arrayBuffer().then(toArray).then(callback);
|
|
61
|
+
}
|
|
62
|
+
else if (withNativeArrayBuffer &&
|
|
63
|
+
(packet.data instanceof ArrayBuffer || isView(packet.data))) {
|
|
64
|
+
return callback(toArray(packet.data));
|
|
65
|
+
}
|
|
66
|
+
encodePacket(packet, false, (encoded) => {
|
|
67
|
+
if (!TEXT_ENCODER) {
|
|
68
|
+
TEXT_ENCODER = new TextEncoder();
|
|
69
|
+
}
|
|
70
|
+
callback(TEXT_ENCODER.encode(encoded));
|
|
71
|
+
});
|
|
72
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { Packet, RawData } from "./commons.js";
|
|
2
|
+
export declare const encodePacket: ({ type, data }: Packet, supportsBinary: boolean, callback: (encodedPacket: RawData) => void) => void;
|
|
3
|
+
export declare function encodePacketToBinary(packet: Packet, callback: (encodedPacket: RawData) => void): void;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.encodePacket = void 0;
|
|
4
|
+
exports.encodePacketToBinary = encodePacketToBinary;
|
|
5
|
+
const commons_js_1 = require("./commons.js");
|
|
6
|
+
const encodePacket = ({ type, data }, supportsBinary, callback) => {
|
|
7
|
+
if (data instanceof ArrayBuffer || ArrayBuffer.isView(data)) {
|
|
8
|
+
return callback(supportsBinary ? data : "b" + toBuffer(data, true).toString("base64"));
|
|
9
|
+
}
|
|
10
|
+
// plain string
|
|
11
|
+
return callback(commons_js_1.PACKET_TYPES[type] + (data || ""));
|
|
12
|
+
};
|
|
13
|
+
exports.encodePacket = encodePacket;
|
|
14
|
+
const toBuffer = (data, forceBufferConversion) => {
|
|
15
|
+
if (Buffer.isBuffer(data) ||
|
|
16
|
+
(data instanceof Uint8Array && !forceBufferConversion)) {
|
|
17
|
+
return data;
|
|
18
|
+
}
|
|
19
|
+
else if (data instanceof ArrayBuffer) {
|
|
20
|
+
return Buffer.from(data);
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
return Buffer.from(data.buffer, data.byteOffset, data.byteLength);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
let TEXT_ENCODER;
|
|
27
|
+
function encodePacketToBinary(packet, callback) {
|
|
28
|
+
if (packet.data instanceof ArrayBuffer || ArrayBuffer.isView(packet.data)) {
|
|
29
|
+
return callback(toBuffer(packet.data, false));
|
|
30
|
+
}
|
|
31
|
+
(0, exports.encodePacket)(packet, true, (encoded) => {
|
|
32
|
+
if (!TEXT_ENCODER) {
|
|
33
|
+
// lazily created for compatibility with Node.js 10
|
|
34
|
+
TEXT_ENCODER = new TextEncoder();
|
|
35
|
+
}
|
|
36
|
+
callback(TEXT_ENCODER.encode(encoded));
|
|
37
|
+
});
|
|
38
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { encodePacket } from "./encodePacket.js";
|
|
2
|
+
import { decodePacket } from "./decodePacket.js";
|
|
3
|
+
import { Packet, PacketType, RawData, BinaryType } from "./commons.js";
|
|
4
|
+
declare const encodePayload: (packets: Packet[], callback: (encodedPayload: string) => void) => void;
|
|
5
|
+
declare const decodePayload: (encodedPayload: string, binaryType?: BinaryType) => Packet[];
|
|
6
|
+
export declare function createPacketEncoderStream(): any;
|
|
7
|
+
export declare function createPacketDecoderStream(maxPayload: number, binaryType: BinaryType): any;
|
|
8
|
+
export declare const protocol = 4;
|
|
9
|
+
export { encodePacket, encodePayload, decodePacket, decodePayload, Packet, PacketType, RawData, BinaryType, };
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.decodePayload = exports.decodePacket = exports.encodePayload = exports.encodePacket = exports.protocol = void 0;
|
|
4
|
+
exports.createPacketEncoderStream = createPacketEncoderStream;
|
|
5
|
+
exports.createPacketDecoderStream = createPacketDecoderStream;
|
|
6
|
+
const encodePacket_js_1 = require("./encodePacket.js");
|
|
7
|
+
Object.defineProperty(exports, "encodePacket", { enumerable: true, get: function () { return encodePacket_js_1.encodePacket; } });
|
|
8
|
+
const decodePacket_js_1 = require("./decodePacket.js");
|
|
9
|
+
Object.defineProperty(exports, "decodePacket", { enumerable: true, get: function () { return decodePacket_js_1.decodePacket; } });
|
|
10
|
+
const commons_js_1 = require("./commons.js");
|
|
11
|
+
const SEPARATOR = String.fromCharCode(30); // see https://en.wikipedia.org/wiki/Delimiter#ASCII_delimited_text
|
|
12
|
+
const encodePayload = (packets, callback) => {
|
|
13
|
+
// some packets may be added to the array while encoding, so the initial length must be saved
|
|
14
|
+
const length = packets.length;
|
|
15
|
+
const encodedPackets = new Array(length);
|
|
16
|
+
let count = 0;
|
|
17
|
+
packets.forEach((packet, i) => {
|
|
18
|
+
// force base64 encoding for binary packets
|
|
19
|
+
(0, encodePacket_js_1.encodePacket)(packet, false, (encodedPacket) => {
|
|
20
|
+
encodedPackets[i] = encodedPacket;
|
|
21
|
+
if (++count === length) {
|
|
22
|
+
callback(encodedPackets.join(SEPARATOR));
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
exports.encodePayload = encodePayload;
|
|
28
|
+
const decodePayload = (encodedPayload, binaryType) => {
|
|
29
|
+
const encodedPackets = encodedPayload.split(SEPARATOR);
|
|
30
|
+
const packets = [];
|
|
31
|
+
for (let i = 0; i < encodedPackets.length; i++) {
|
|
32
|
+
const decodedPacket = (0, decodePacket_js_1.decodePacket)(encodedPackets[i], binaryType);
|
|
33
|
+
packets.push(decodedPacket);
|
|
34
|
+
if (decodedPacket.type === "error") {
|
|
35
|
+
break;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return packets;
|
|
39
|
+
};
|
|
40
|
+
exports.decodePayload = decodePayload;
|
|
41
|
+
function createPacketEncoderStream() {
|
|
42
|
+
return new TransformStream({
|
|
43
|
+
transform(packet, controller) {
|
|
44
|
+
(0, encodePacket_js_1.encodePacketToBinary)(packet, (encodedPacket) => {
|
|
45
|
+
const payloadLength = encodedPacket.length;
|
|
46
|
+
let header;
|
|
47
|
+
// inspired by the WebSocket format: https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API/Writing_WebSocket_servers#decoding_payload_length
|
|
48
|
+
if (payloadLength < 126) {
|
|
49
|
+
header = new Uint8Array(1);
|
|
50
|
+
new DataView(header.buffer).setUint8(0, payloadLength);
|
|
51
|
+
}
|
|
52
|
+
else if (payloadLength < 65536) {
|
|
53
|
+
header = new Uint8Array(3);
|
|
54
|
+
const view = new DataView(header.buffer);
|
|
55
|
+
view.setUint8(0, 126);
|
|
56
|
+
view.setUint16(1, payloadLength);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
header = new Uint8Array(9);
|
|
60
|
+
const view = new DataView(header.buffer);
|
|
61
|
+
view.setUint8(0, 127);
|
|
62
|
+
view.setBigUint64(1, BigInt(payloadLength));
|
|
63
|
+
}
|
|
64
|
+
// first bit indicates whether the payload is plain text (0) or binary (1)
|
|
65
|
+
if (packet.data && typeof packet.data !== "string") {
|
|
66
|
+
header[0] |= 0x80;
|
|
67
|
+
}
|
|
68
|
+
controller.enqueue(header);
|
|
69
|
+
controller.enqueue(encodedPacket);
|
|
70
|
+
});
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
let TEXT_DECODER;
|
|
75
|
+
function totalLength(chunks) {
|
|
76
|
+
return chunks.reduce((acc, chunk) => acc + chunk.length, 0);
|
|
77
|
+
}
|
|
78
|
+
function concatChunks(chunks, size) {
|
|
79
|
+
if (chunks[0].length === size) {
|
|
80
|
+
return chunks.shift();
|
|
81
|
+
}
|
|
82
|
+
const buffer = new Uint8Array(size);
|
|
83
|
+
let j = 0;
|
|
84
|
+
for (let i = 0; i < size; i++) {
|
|
85
|
+
buffer[i] = chunks[0][j++];
|
|
86
|
+
if (j === chunks[0].length) {
|
|
87
|
+
chunks.shift();
|
|
88
|
+
j = 0;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
if (chunks.length && j < chunks[0].length) {
|
|
92
|
+
chunks[0] = chunks[0].slice(j);
|
|
93
|
+
}
|
|
94
|
+
return buffer;
|
|
95
|
+
}
|
|
96
|
+
function createPacketDecoderStream(maxPayload, binaryType) {
|
|
97
|
+
if (!TEXT_DECODER) {
|
|
98
|
+
TEXT_DECODER = new TextDecoder();
|
|
99
|
+
}
|
|
100
|
+
const chunks = [];
|
|
101
|
+
let state = 0 /* State.READ_HEADER */;
|
|
102
|
+
let expectedLength = -1;
|
|
103
|
+
let isBinary = false;
|
|
104
|
+
return new TransformStream({
|
|
105
|
+
transform(chunk, controller) {
|
|
106
|
+
chunks.push(chunk);
|
|
107
|
+
while (true) {
|
|
108
|
+
if (state === 0 /* State.READ_HEADER */) {
|
|
109
|
+
if (totalLength(chunks) < 1) {
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
const header = concatChunks(chunks, 1);
|
|
113
|
+
isBinary = (header[0] & 0x80) === 0x80;
|
|
114
|
+
expectedLength = header[0] & 0x7f;
|
|
115
|
+
if (expectedLength < 126) {
|
|
116
|
+
state = 3 /* State.READ_PAYLOAD */;
|
|
117
|
+
}
|
|
118
|
+
else if (expectedLength === 126) {
|
|
119
|
+
state = 1 /* State.READ_EXTENDED_LENGTH_16 */;
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
state = 2 /* State.READ_EXTENDED_LENGTH_64 */;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
else if (state === 1 /* State.READ_EXTENDED_LENGTH_16 */) {
|
|
126
|
+
if (totalLength(chunks) < 2) {
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
const headerArray = concatChunks(chunks, 2);
|
|
130
|
+
expectedLength = new DataView(headerArray.buffer, headerArray.byteOffset, headerArray.length).getUint16(0);
|
|
131
|
+
state = 3 /* State.READ_PAYLOAD */;
|
|
132
|
+
}
|
|
133
|
+
else if (state === 2 /* State.READ_EXTENDED_LENGTH_64 */) {
|
|
134
|
+
if (totalLength(chunks) < 8) {
|
|
135
|
+
break;
|
|
136
|
+
}
|
|
137
|
+
const headerArray = concatChunks(chunks, 8);
|
|
138
|
+
const view = new DataView(headerArray.buffer, headerArray.byteOffset, headerArray.length);
|
|
139
|
+
const n = view.getUint32(0);
|
|
140
|
+
if (n > Math.pow(2, 53 - 32) - 1) {
|
|
141
|
+
// the maximum safe integer in JavaScript is 2^53 - 1
|
|
142
|
+
controller.enqueue(commons_js_1.ERROR_PACKET);
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
expectedLength = n * Math.pow(2, 32) + view.getUint32(4);
|
|
146
|
+
state = 3 /* State.READ_PAYLOAD */;
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
if (totalLength(chunks) < expectedLength) {
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
const data = concatChunks(chunks, expectedLength);
|
|
153
|
+
controller.enqueue((0, decodePacket_js_1.decodePacket)(isBinary ? data : TEXT_DECODER.decode(data), binaryType));
|
|
154
|
+
state = 0 /* State.READ_HEADER */;
|
|
155
|
+
}
|
|
156
|
+
if (expectedLength === 0 || expectedLength > maxPayload) {
|
|
157
|
+
controller.enqueue(commons_js_1.ERROR_PACKET);
|
|
158
|
+
break;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
exports.protocol = 4;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare const PACKET_TYPES: any;
|
|
2
|
+
declare const PACKET_TYPES_REVERSE: any;
|
|
3
|
+
declare const ERROR_PACKET: Packet;
|
|
4
|
+
export { PACKET_TYPES, PACKET_TYPES_REVERSE, ERROR_PACKET };
|
|
5
|
+
export type PacketType = "open" | "close" | "ping" | "pong" | "message" | "upgrade" | "noop" | "error";
|
|
6
|
+
export type RawData = any;
|
|
7
|
+
export interface Packet {
|
|
8
|
+
type: PacketType;
|
|
9
|
+
options?: {
|
|
10
|
+
compress: boolean;
|
|
11
|
+
};
|
|
12
|
+
data?: RawData;
|
|
13
|
+
}
|
|
14
|
+
export type BinaryType = "nodebuffer" | "arraybuffer" | "blob";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const PACKET_TYPES = Object.create(null); // no Map = no polyfill
|
|
2
|
+
PACKET_TYPES["open"] = "0";
|
|
3
|
+
PACKET_TYPES["close"] = "1";
|
|
4
|
+
PACKET_TYPES["ping"] = "2";
|
|
5
|
+
PACKET_TYPES["pong"] = "3";
|
|
6
|
+
PACKET_TYPES["message"] = "4";
|
|
7
|
+
PACKET_TYPES["upgrade"] = "5";
|
|
8
|
+
PACKET_TYPES["noop"] = "6";
|
|
9
|
+
const PACKET_TYPES_REVERSE = Object.create(null);
|
|
10
|
+
Object.keys(PACKET_TYPES).forEach((key) => {
|
|
11
|
+
PACKET_TYPES_REVERSE[PACKET_TYPES[key]] = key;
|
|
12
|
+
});
|
|
13
|
+
const ERROR_PACKET = { type: "error", data: "parser error" };
|
|
14
|
+
export { PACKET_TYPES, PACKET_TYPES_REVERSE, ERROR_PACKET };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// imported from https://github.com/socketio/base64-arraybuffer
|
|
2
|
+
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
|
|
3
|
+
// Use a lookup table to find the index.
|
|
4
|
+
const lookup = typeof Uint8Array === 'undefined' ? [] : new Uint8Array(256);
|
|
5
|
+
for (let i = 0; i < chars.length; i++) {
|
|
6
|
+
lookup[chars.charCodeAt(i)] = i;
|
|
7
|
+
}
|
|
8
|
+
export const encode = (arraybuffer) => {
|
|
9
|
+
let bytes = new Uint8Array(arraybuffer), i, len = bytes.length, base64 = '';
|
|
10
|
+
for (i = 0; i < len; i += 3) {
|
|
11
|
+
base64 += chars[bytes[i] >> 2];
|
|
12
|
+
base64 += chars[((bytes[i] & 3) << 4) | (bytes[i + 1] >> 4)];
|
|
13
|
+
base64 += chars[((bytes[i + 1] & 15) << 2) | (bytes[i + 2] >> 6)];
|
|
14
|
+
base64 += chars[bytes[i + 2] & 63];
|
|
15
|
+
}
|
|
16
|
+
if (len % 3 === 2) {
|
|
17
|
+
base64 = base64.substring(0, base64.length - 1) + '=';
|
|
18
|
+
}
|
|
19
|
+
else if (len % 3 === 1) {
|
|
20
|
+
base64 = base64.substring(0, base64.length - 2) + '==';
|
|
21
|
+
}
|
|
22
|
+
return base64;
|
|
23
|
+
};
|
|
24
|
+
export const decode = (base64) => {
|
|
25
|
+
let bufferLength = base64.length * 0.75, len = base64.length, i, p = 0, encoded1, encoded2, encoded3, encoded4;
|
|
26
|
+
if (base64[base64.length - 1] === '=') {
|
|
27
|
+
bufferLength--;
|
|
28
|
+
if (base64[base64.length - 2] === '=') {
|
|
29
|
+
bufferLength--;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const arraybuffer = new ArrayBuffer(bufferLength), bytes = new Uint8Array(arraybuffer);
|
|
33
|
+
for (i = 0; i < len; i += 4) {
|
|
34
|
+
encoded1 = lookup[base64.charCodeAt(i)];
|
|
35
|
+
encoded2 = lookup[base64.charCodeAt(i + 1)];
|
|
36
|
+
encoded3 = lookup[base64.charCodeAt(i + 2)];
|
|
37
|
+
encoded4 = lookup[base64.charCodeAt(i + 3)];
|
|
38
|
+
bytes[p++] = (encoded1 << 2) | (encoded2 >> 4);
|
|
39
|
+
bytes[p++] = ((encoded2 & 15) << 4) | (encoded3 >> 2);
|
|
40
|
+
bytes[p++] = ((encoded3 & 3) << 6) | (encoded4 & 63);
|
|
41
|
+
}
|
|
42
|
+
return arraybuffer;
|
|
43
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { ERROR_PACKET, PACKET_TYPES_REVERSE, } from "./commons.js";
|
|
2
|
+
import { decode } from "./contrib/base64-arraybuffer.js";
|
|
3
|
+
const withNativeArrayBuffer = typeof ArrayBuffer === "function";
|
|
4
|
+
export const decodePacket = (encodedPacket, binaryType) => {
|
|
5
|
+
if (typeof encodedPacket !== "string") {
|
|
6
|
+
return {
|
|
7
|
+
type: "message",
|
|
8
|
+
data: mapBinary(encodedPacket, binaryType),
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
const type = encodedPacket.charAt(0);
|
|
12
|
+
if (type === "b") {
|
|
13
|
+
return {
|
|
14
|
+
type: "message",
|
|
15
|
+
data: decodeBase64Packet(encodedPacket.substring(1), binaryType),
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
const packetType = PACKET_TYPES_REVERSE[type];
|
|
19
|
+
if (!packetType) {
|
|
20
|
+
return ERROR_PACKET;
|
|
21
|
+
}
|
|
22
|
+
return encodedPacket.length > 1
|
|
23
|
+
? {
|
|
24
|
+
type: PACKET_TYPES_REVERSE[type],
|
|
25
|
+
data: encodedPacket.substring(1),
|
|
26
|
+
}
|
|
27
|
+
: {
|
|
28
|
+
type: PACKET_TYPES_REVERSE[type],
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
const decodeBase64Packet = (data, binaryType) => {
|
|
32
|
+
if (withNativeArrayBuffer) {
|
|
33
|
+
const decoded = decode(data);
|
|
34
|
+
return mapBinary(decoded, binaryType);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
return { base64: true, data }; // fallback for old browsers
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
const mapBinary = (data, binaryType) => {
|
|
41
|
+
switch (binaryType) {
|
|
42
|
+
case "blob":
|
|
43
|
+
if (data instanceof Blob) {
|
|
44
|
+
// from WebSocket + binaryType "blob"
|
|
45
|
+
return data;
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
// from HTTP long-polling or WebTransport
|
|
49
|
+
return new Blob([data]);
|
|
50
|
+
}
|
|
51
|
+
case "arraybuffer":
|
|
52
|
+
default:
|
|
53
|
+
if (data instanceof ArrayBuffer) {
|
|
54
|
+
// from HTTP long-polling (base64) or WebSocket + binaryType "arraybuffer"
|
|
55
|
+
return data;
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
// from WebTransport (Uint8Array)
|
|
59
|
+
return data.buffer;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
};
|