@ac-kit/format-websocket 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @ac-kit/format-websocket
2
2
 
3
+ ## 0.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 99ca4b9: `WebSocketCloseCode`: the close codes of RFC 6455 §7.4.1 and the IANA registry,
8
+ `NORMAL_CLOSURE` (1000) to `TLS_HANDSHAKE` (1015), by name.
9
+
10
+ ### Patch Changes
11
+
12
+ - Updated dependencies [99ca4b9]
13
+ - @ac-kit/core@0.8.0
14
+ - @ac-kit/format-core@0.3.1
15
+
3
16
  ## 0.2.0
4
17
 
5
18
  ### Minor Changes
package/README.md CHANGED
@@ -23,7 +23,8 @@ const [header, payload] = codec.encode({
23
23
  - `maskWebSocketPayload` and `createWebSocketMaskStream` — masking and
24
24
  unmasking, whole or as a payload streams in.
25
25
  - `encodeWebSocketClosePayload`, `decodeWebSocketClosePayload` and
26
- `isWebSocketCloseCodeSendable` — the close frame's code and reason.
26
+ `isWebSocketCloseCodeSendable` — the close frame's code and reason, and
27
+ `WebSocketCloseCode`, the registered codes by name.
27
28
  - `WebSocketFrameError` — a violation, carrying the close code the endpoint
28
29
  must fail the connection with.
29
30
 
@@ -0,0 +1,44 @@
1
+ /**
2
+ * The close codes RFC 6455 §7.4.1 defines and the IANA WebSocket Close Code
3
+ * Number Registry adds, named as the registry names them. An application closes
4
+ * with `NORMAL_CLOSURE`, `GOING_AWAY`, `POLICY_VIOLATION`, `INTERNAL_ERROR`,
5
+ * `SERVICE_RESTART` or `TRY_AGAIN_LATER`, or with one of its own in
6
+ * `3000`–`4999`; the protocol failures are an endpoint's to send.
7
+ *
8
+ * `NO_STATUS_RECEIVED`, `ABNORMAL_CLOSURE` and `TLS_HANDSHAKE` only report what
9
+ * happened locally and never go on the wire — see
10
+ * {@link isWebSocketCloseCodeSendable}. `1004` is reserved, and has no name.
11
+ */
12
+ export declare enum WebSocketCloseCode {
13
+ /** The purpose the connection was opened for is fulfilled. */
14
+ NORMAL_CLOSURE = 1000,
15
+ /** The endpoint is going away: a server stopping, a page navigated off. */
16
+ GOING_AWAY = 1001,
17
+ /** The peer broke the protocol. */
18
+ PROTOCOL_ERROR = 1002,
19
+ /** A message of a type the endpoint cannot take: binary to a text-only one. */
20
+ UNSUPPORTED_DATA = 1003,
21
+ /** Reported when a close frame carried no code; never sent. */
22
+ NO_STATUS_RECEIVED = 1005,
23
+ /** Reported when the connection dropped without a close frame; never sent. */
24
+ ABNORMAL_CLOSURE = 1006,
25
+ /** A message's data did not match its type: text that is not UTF-8. */
26
+ INVALID_FRAME_PAYLOAD_DATA = 1007,
27
+ /** A message broke the endpoint's policy, when no other code fits. */
28
+ POLICY_VIOLATION = 1008,
29
+ /** A message too big to process. */
30
+ MESSAGE_TOO_BIG = 1009,
31
+ /** Sent by a client: the server did not negotiate an extension it needs. */
32
+ MANDATORY_EXTENSION = 1010,
33
+ /** Sent by a server: a condition it could not handle. */
34
+ INTERNAL_ERROR = 1011,
35
+ /** The server is restarting; a client may reconnect after a short delay. */
36
+ SERVICE_RESTART = 1012,
37
+ /** The server is overloaded; a client may reconnect later. */
38
+ TRY_AGAIN_LATER = 1013,
39
+ /** A gateway or proxy got an invalid response from its upstream server. */
40
+ BAD_GATEWAY = 1014,
41
+ /** Reported when the TLS handshake failed; never sent. */
42
+ TLS_HANDSHAKE = 1015
43
+ }
44
+ //# sourceMappingURL=websocket-close-code.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"websocket-close-code.d.ts","sourceRoot":"","sources":["../../src/close/websocket-close-code.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,oBAAY,kBAAkB;IAC7B,8DAA8D;IAC9D,cAAc,OAAO;IACrB,2EAA2E;IAC3E,UAAU,OAAO;IACjB,mCAAmC;IACnC,cAAc,OAAO;IACrB,+EAA+E;IAC/E,gBAAgB,OAAO;IACvB,+DAA+D;IAC/D,kBAAkB,OAAO;IACzB,8EAA8E;IAC9E,gBAAgB,OAAO;IACvB,uEAAuE;IACvE,0BAA0B,OAAO;IACjC,sEAAsE;IACtE,gBAAgB,OAAO;IACvB,oCAAoC;IACpC,eAAe,OAAO;IACtB,4EAA4E;IAC5E,mBAAmB,OAAO;IAC1B,yDAAyD;IACzD,cAAc,OAAO;IACrB,4EAA4E;IAC5E,eAAe,OAAO;IACtB,8DAA8D;IAC9D,eAAe,OAAO;IACtB,2EAA2E;IAC3E,WAAW,OAAO;IAClB,0DAA0D;IAC1D,aAAa,OAAO;CACpB"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * The close codes RFC 6455 §7.4.1 defines and the IANA WebSocket Close Code
3
+ * Number Registry adds, named as the registry names them. An application closes
4
+ * with `NORMAL_CLOSURE`, `GOING_AWAY`, `POLICY_VIOLATION`, `INTERNAL_ERROR`,
5
+ * `SERVICE_RESTART` or `TRY_AGAIN_LATER`, or with one of its own in
6
+ * `3000`–`4999`; the protocol failures are an endpoint's to send.
7
+ *
8
+ * `NO_STATUS_RECEIVED`, `ABNORMAL_CLOSURE` and `TLS_HANDSHAKE` only report what
9
+ * happened locally and never go on the wire — see
10
+ * {@link isWebSocketCloseCodeSendable}. `1004` is reserved, and has no name.
11
+ */
12
+ export var WebSocketCloseCode;
13
+ (function (WebSocketCloseCode) {
14
+ /** The purpose the connection was opened for is fulfilled. */
15
+ WebSocketCloseCode[WebSocketCloseCode["NORMAL_CLOSURE"] = 1000] = "NORMAL_CLOSURE";
16
+ /** The endpoint is going away: a server stopping, a page navigated off. */
17
+ WebSocketCloseCode[WebSocketCloseCode["GOING_AWAY"] = 1001] = "GOING_AWAY";
18
+ /** The peer broke the protocol. */
19
+ WebSocketCloseCode[WebSocketCloseCode["PROTOCOL_ERROR"] = 1002] = "PROTOCOL_ERROR";
20
+ /** A message of a type the endpoint cannot take: binary to a text-only one. */
21
+ WebSocketCloseCode[WebSocketCloseCode["UNSUPPORTED_DATA"] = 1003] = "UNSUPPORTED_DATA";
22
+ /** Reported when a close frame carried no code; never sent. */
23
+ WebSocketCloseCode[WebSocketCloseCode["NO_STATUS_RECEIVED"] = 1005] = "NO_STATUS_RECEIVED";
24
+ /** Reported when the connection dropped without a close frame; never sent. */
25
+ WebSocketCloseCode[WebSocketCloseCode["ABNORMAL_CLOSURE"] = 1006] = "ABNORMAL_CLOSURE";
26
+ /** A message's data did not match its type: text that is not UTF-8. */
27
+ WebSocketCloseCode[WebSocketCloseCode["INVALID_FRAME_PAYLOAD_DATA"] = 1007] = "INVALID_FRAME_PAYLOAD_DATA";
28
+ /** A message broke the endpoint's policy, when no other code fits. */
29
+ WebSocketCloseCode[WebSocketCloseCode["POLICY_VIOLATION"] = 1008] = "POLICY_VIOLATION";
30
+ /** A message too big to process. */
31
+ WebSocketCloseCode[WebSocketCloseCode["MESSAGE_TOO_BIG"] = 1009] = "MESSAGE_TOO_BIG";
32
+ /** Sent by a client: the server did not negotiate an extension it needs. */
33
+ WebSocketCloseCode[WebSocketCloseCode["MANDATORY_EXTENSION"] = 1010] = "MANDATORY_EXTENSION";
34
+ /** Sent by a server: a condition it could not handle. */
35
+ WebSocketCloseCode[WebSocketCloseCode["INTERNAL_ERROR"] = 1011] = "INTERNAL_ERROR";
36
+ /** The server is restarting; a client may reconnect after a short delay. */
37
+ WebSocketCloseCode[WebSocketCloseCode["SERVICE_RESTART"] = 1012] = "SERVICE_RESTART";
38
+ /** The server is overloaded; a client may reconnect later. */
39
+ WebSocketCloseCode[WebSocketCloseCode["TRY_AGAIN_LATER"] = 1013] = "TRY_AGAIN_LATER";
40
+ /** A gateway or proxy got an invalid response from its upstream server. */
41
+ WebSocketCloseCode[WebSocketCloseCode["BAD_GATEWAY"] = 1014] = "BAD_GATEWAY";
42
+ /** Reported when the TLS handshake failed; never sent. */
43
+ WebSocketCloseCode[WebSocketCloseCode["TLS_HANDSHAKE"] = 1015] = "TLS_HANDSHAKE";
44
+ })(WebSocketCloseCode || (WebSocketCloseCode = {}));
45
+ //# sourceMappingURL=websocket-close-code.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"websocket-close-code.js","sourceRoot":"","sources":["../../src/close/websocket-close-code.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,CAAN,IAAY,kBA+BX;AA/BD,WAAY,kBAAkB;IAC7B,8DAA8D;IAC9D,kFAAqB,CAAA;IACrB,2EAA2E;IAC3E,0EAAiB,CAAA;IACjB,mCAAmC;IACnC,kFAAqB,CAAA;IACrB,+EAA+E;IAC/E,sFAAuB,CAAA;IACvB,+DAA+D;IAC/D,0FAAyB,CAAA;IACzB,8EAA8E;IAC9E,sFAAuB,CAAA;IACvB,uEAAuE;IACvE,0GAAiC,CAAA;IACjC,sEAAsE;IACtE,sFAAuB,CAAA;IACvB,oCAAoC;IACpC,oFAAsB,CAAA;IACtB,4EAA4E;IAC5E,4FAA0B,CAAA;IAC1B,yDAAyD;IACzD,kFAAqB,CAAA;IACrB,4EAA4E;IAC5E,oFAAsB,CAAA;IACtB,8DAA8D;IAC9D,oFAAsB,CAAA;IACtB,2EAA2E;IAC3E,4EAAkB,CAAA;IAClB,0DAA0D;IAC1D,gFAAoB,CAAA;AACrB,CAAC,EA/BW,kBAAkB,KAAlB,kBAAkB,QA+B7B"}
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ export * from "./close/websocket-close-code.js";
1
2
  export * from "./close/websocket-close.js";
2
3
  export * from "./errors.js";
3
4
  export * from "./frame/mask.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,kCAAkC,CAAC;AACjD,cAAc,4BAA4B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC;AAChD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,kCAAkC,CAAC;AACjD,cAAc,4BAA4B,CAAC"}
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ export * from "./close/websocket-close-code.js";
1
2
  export * from "./close/websocket-close.js";
2
3
  export * from "./errors.js";
3
4
  export * from "./frame/mask.js";
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,kCAAkC,CAAC;AACjD,cAAc,4BAA4B,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC;AAChD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,aAAa,CAAC;AAC5B,cAAc,iBAAiB,CAAC;AAChC,cAAc,kCAAkC,CAAC;AACjD,cAAc,4BAA4B,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ac-kit/format-websocket",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "The WebSocket wire format (RFC 6455): frame codec with streamed payloads, masking, close codes and the close payload.",
5
5
  "keywords": [
6
6
  "rfc6455",
@@ -43,12 +43,12 @@
43
43
  "prepack": "yarn build"
44
44
  },
45
45
  "dependencies": {
46
- "@ac-kit/core": "^0.7.0",
47
- "@ac-kit/format-core": "^0.3.0",
48
- "@types/web": "^0.0.362"
46
+ "@ac-kit/core": "^0.8.0",
47
+ "@ac-kit/format-core": "^0.3.1",
48
+ "@types/web": "^0.0.367"
49
49
  },
50
50
  "devDependencies": {
51
- "@ac-kit/math-random": "0.1.6",
51
+ "@ac-kit/math-random": "0.1.7",
52
52
  "@ac-kit/tsconfig": "0.1.0",
53
53
  "@ac-kit/typedoc-config": "0.1.0",
54
54
  "@ac-kit/vitest-config": "0.1.1",