bun-types 1.1.10 → 1.1.11

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.
Files changed (2) hide show
  1. package/bun.d.ts +191 -3
  2. package/package.json +1 -1
package/bun.d.ts CHANGED
@@ -15,7 +15,11 @@
15
15
  */
16
16
  declare module "bun" {
17
17
  import type { Encoding as CryptoEncoding } from "crypto";
18
-
18
+ import type {
19
+ CipherNameAndProtocol,
20
+ EphemeralKeyInfo,
21
+ PeerCertificate,
22
+ } from "tls";
19
23
  interface Env {
20
24
  NODE_ENV?: string;
21
25
  /**
@@ -3339,7 +3343,8 @@ declare module "bun" {
3339
3343
  *
3340
3344
  * @param hashInto `TypedArray` to write the hash into. Faster than creating a new one each time
3341
3345
  */
3342
- digest(hashInto?: NodeJS.TypedArray): NodeJS.TypedArray;
3346
+ digest(): Buffer;
3347
+ digest(hashInto: NodeJS.TypedArray): NodeJS.TypedArray;
3343
3348
 
3344
3349
  /**
3345
3350
  * Run the hash over the given data
@@ -3351,7 +3356,11 @@ declare module "bun" {
3351
3356
  static hash(
3352
3357
  algorithm: SupportedCryptoAlgorithms,
3353
3358
  input: Bun.BlobOrStringOrBuffer,
3354
- hashInto?: NodeJS.TypedArray,
3359
+ ): Buffer;
3360
+ static hash(
3361
+ algorithm: SupportedCryptoAlgorithms,
3362
+ input: Bun.BlobOrStringOrBuffer,
3363
+ hashInto: NodeJS.TypedArray,
3355
3364
  ): NodeJS.TypedArray;
3356
3365
 
3357
3366
  /**
@@ -4079,6 +4088,185 @@ declare module "bun" {
4079
4088
  * local port connected to the socket
4080
4089
  */
4081
4090
  readonly localPort: number;
4091
+
4092
+ /**
4093
+ * This property is `true` if the peer certificate was signed by one of the CAs
4094
+ * specified when creating the `Socket` instance, otherwise `false`.
4095
+ */
4096
+ readonly authorized: boolean;
4097
+
4098
+ /**
4099
+ * String containing the selected ALPN protocol.
4100
+ * Before a handshake has completed, this value is always null.
4101
+ * When a handshake is completed but not ALPN protocol was selected, socket.alpnProtocol equals false.
4102
+ */
4103
+ readonly alpnProtocol: string | false | null;
4104
+
4105
+ /**
4106
+ * Disables TLS renegotiation for this `Socket` instance. Once called, attempts
4107
+ * to renegotiate will trigger an `error` handler on the `Socket`.
4108
+ *
4109
+ * There is no support for renegotiation as a server. (Attempts by clients will result in a fatal alert so that ClientHello messages cannot be used to flood a server and escape higher-level limits.)
4110
+ */
4111
+ disableRenegotiation(): void;
4112
+
4113
+ /**
4114
+ * Keying material is used for validations to prevent different kind of attacks in
4115
+ * network protocols, for example in the specifications of IEEE 802.1X.
4116
+ *
4117
+ * Example
4118
+ *
4119
+ * ```js
4120
+ * const keyingMaterial = socket.exportKeyingMaterial(
4121
+ * 128,
4122
+ * 'client finished');
4123
+ *
4124
+ * /*
4125
+ * Example return value of keyingMaterial:
4126
+ * <Buffer 76 26 af 99 c5 56 8e 42 09 91 ef 9f 93 cb ad 6c 7b 65 f8 53 f1 d8 d9
4127
+ * 12 5a 33 b8 b5 25 df 7b 37 9f e0 e2 4f b8 67 83 a3 2f cd 5d 41 42 4c 91
4128
+ * 74 ef 2c ... 78 more bytes>
4129
+ *
4130
+ * ```
4131
+ *
4132
+ * @param length number of bytes to retrieve from keying material
4133
+ * @param label an application specific label, typically this will be a value from the [IANA Exporter Label
4134
+ * Registry](https://www.iana.org/assignments/tls-parameters/tls-parameters.xhtml#exporter-labels).
4135
+ * @param context Optionally provide a context.
4136
+ * @return requested bytes of the keying material
4137
+ */
4138
+ exportKeyingMaterial(
4139
+ length: number,
4140
+ label: string,
4141
+ context: Buffer,
4142
+ ): Buffer;
4143
+
4144
+ /**
4145
+ * Returns the reason why the peer's certificate was not been verified. This
4146
+ * property is set only when `socket.authorized === false`.
4147
+ */
4148
+ getAuthorizationError(): Error | null;
4149
+
4150
+ /**
4151
+ * Returns an object representing the local certificate. The returned object has
4152
+ * some properties corresponding to the fields of the certificate.
4153
+ *
4154
+ * If there is no local certificate, an empty object will be returned. If the
4155
+ * socket has been destroyed, `null` will be returned.
4156
+ */
4157
+ getCertificate(): PeerCertificate | object | null;
4158
+
4159
+ /**
4160
+ * Returns an object containing information on the negotiated cipher suite.
4161
+ *
4162
+ * For example, a TLSv1.2 protocol with AES256-SHA cipher:
4163
+ *
4164
+ * ```json
4165
+ * {
4166
+ * "name": "AES256-SHA",
4167
+ * "standardName": "TLS_RSA_WITH_AES_256_CBC_SHA",
4168
+ * "version": "SSLv3"
4169
+ * }
4170
+ * ```
4171
+ *
4172
+ */
4173
+ getCipher(): CipherNameAndProtocol;
4174
+
4175
+ /**
4176
+ * Returns an object representing the type, name, and size of parameter of
4177
+ * an ephemeral key exchange in `perfect forward secrecy` on a client
4178
+ * connection. It returns an empty object when the key exchange is not
4179
+ * ephemeral. As this is only supported on a client socket; `null` is returned
4180
+ * if called on a server socket. The supported types are `'DH'` and `'ECDH'`. The`name` property is available only when type is `'ECDH'`.
4181
+ *
4182
+ * For example: `{ type: 'ECDH', name: 'prime256v1', size: 256 }`.
4183
+ */
4184
+ getEphemeralKeyInfo(): EphemeralKeyInfo | object | null;
4185
+
4186
+ /**
4187
+ * Returns an object representing the peer's certificate. If the peer does not
4188
+ * provide a certificate, an empty object will be returned. If the socket has been
4189
+ * destroyed, `null` will be returned.
4190
+ *
4191
+ * If the full certificate chain was requested, each certificate will include an`issuerCertificate` property containing an object representing its issuer's
4192
+ * certificate.
4193
+ * @return A certificate object.
4194
+ */
4195
+ getPeerCertificate(): PeerCertificate;
4196
+
4197
+ /**
4198
+ * See [SSL\_get\_shared\_sigalgs](https://www.openssl.org/docs/man1.1.1/man3/SSL_get_shared_sigalgs.html) for more information.
4199
+ * @since v12.11.0
4200
+ * @return List of signature algorithms shared between the server and the client in the order of decreasing preference.
4201
+ */
4202
+ getSharedSigalgs(): string[];
4203
+
4204
+ /**
4205
+ * As the `Finished` messages are message digests of the complete handshake
4206
+ * (with a total of 192 bits for TLS 1.0 and more for SSL 3.0), they can
4207
+ * be used for external authentication procedures when the authentication
4208
+ * provided by SSL/TLS is not desired or is not enough.
4209
+ *
4210
+ * @return The latest `Finished` message that has been sent to the socket as part of a SSL/TLS handshake, or `undefined` if no `Finished` message has been sent yet.
4211
+ */
4212
+ getTLSFinishedMessage(): Buffer | undefined;
4213
+
4214
+ /**
4215
+ * As the `Finished` messages are message digests of the complete handshake
4216
+ * (with a total of 192 bits for TLS 1.0 and more for SSL 3.0), they can
4217
+ * be used for external authentication procedures when the authentication
4218
+ * provided by SSL/TLS is not desired or is not enough.
4219
+ *
4220
+ * @return The latest `Finished` message that is expected or has actually been received from the socket as part of a SSL/TLS handshake, or `undefined` if there is no `Finished` message so
4221
+ * far.
4222
+ */
4223
+ getTLSPeerFinishedMessage(): Buffer | undefined;
4224
+
4225
+ /**
4226
+ * For a client, returns the TLS session ticket if one is available, or`undefined`. For a server, always returns `undefined`.
4227
+ *
4228
+ * It may be useful for debugging.
4229
+ *
4230
+ * See `Session Resumption` for more information.
4231
+ */
4232
+ getTLSTicket(): Buffer | undefined;
4233
+
4234
+ /**
4235
+ * Returns a string containing the negotiated SSL/TLS protocol version of the
4236
+ * current connection. The value `'unknown'` will be returned for connected
4237
+ * sockets that have not completed the handshaking process. The value `null` will
4238
+ * be returned for server sockets or disconnected client sockets.
4239
+ *
4240
+ * Protocol versions are:
4241
+ *
4242
+ * * `'SSLv3'`
4243
+ * * `'TLSv1'`
4244
+ * * `'TLSv1.1'`
4245
+ * * `'TLSv1.2'`
4246
+ * * `'TLSv1.3'`
4247
+ *
4248
+ */
4249
+ getTLSVersion(): string;
4250
+
4251
+ /**
4252
+ * See `Session Resumption` for more information.
4253
+ * @return `true` if the session was reused, `false` otherwise.
4254
+ */
4255
+ isSessionReused(): boolean;
4256
+
4257
+ /**
4258
+ * The `socket.setMaxSendFragment()` method sets the maximum TLS fragment size.
4259
+ * Returns `true` if setting the limit succeeded; `false` otherwise.
4260
+ *
4261
+ * Smaller fragment sizes decrease the buffering latency on the client: larger
4262
+ * fragments are buffered by the TLS layer until the entire fragment is received
4263
+ * and its integrity is verified; large fragments can span multiple roundtrips
4264
+ * and their processing can be delayed due to packet loss or reordering. However,
4265
+ * smaller fragments add extra TLS framing bytes and CPU overhead, which may
4266
+ * decrease overall server throughput.
4267
+ * @param [size=16384] The maximum TLS fragment size. The maximum value is `16384`.
4268
+ */
4269
+ setMaxSendFragment(size: number): boolean;
4082
4270
  }
4083
4271
 
4084
4272
  interface SocketListener<Data = undefined> {
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.1.10",
2
+ "version": "1.1.11",
3
3
  "name": "bun-types",
4
4
  "license": "MIT",
5
5
  "main": "",