bun-types 1.2.21-canary.20250821T140634 → 1.2.21-canary.20250823T140535

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.
@@ -21,7 +21,7 @@ Here's what the output of a typical test run looks like. In this case, there are
21
21
 
22
22
  ```sh
23
23
  $ bun test
24
- bun test v1.2.21-canary.20250821T140634 (9c68abdb)
24
+ bun test v1.2.21-canary.20250823T140535 (9c68abdb)
25
25
 
26
26
  test.test.js:
27
27
  ✓ add [0.87ms]
@@ -47,7 +47,7 @@ To only run certain test files, pass a positional argument to `bun test`. The ru
47
47
 
48
48
  ```sh
49
49
  $ bun test test3
50
- bun test v1.2.21-canary.20250821T140634 (9c68abdb)
50
+ bun test v1.2.21-canary.20250823T140535 (9c68abdb)
51
51
 
52
52
  test3.test.js:
53
53
  ✓ add [1.40ms]
@@ -85,7 +85,7 @@ Adding `-t add` will only run tests with "add" in the name. This works with test
85
85
 
86
86
  ```sh
87
87
  $ bun test -t add
88
- bun test v1.2.21-canary.20250821T140634 (9c68abdb)
88
+ bun test v1.2.21-canary.20250823T140535 (9c68abdb)
89
89
 
90
90
  test.test.js:
91
91
  ✓ add [1.79ms]
@@ -18,7 +18,7 @@ The first time this test is executed, Bun will evaluate the value passed into `e
18
18
 
19
19
  ```sh
20
20
  $ bun test test/snap
21
- bun test v1.2.21-canary.20250821T140634 (9c68abdb)
21
+ bun test v1.2.21-canary.20250823T140535 (9c68abdb)
22
22
 
23
23
  test/snap.test.ts:
24
24
  ✓ snapshot [1.48ms]
@@ -61,7 +61,7 @@ Later, when this test file is executed again, Bun will read the snapshot file an
61
61
 
62
62
  ```sh
63
63
  $ bun test
64
- bun test v1.2.21-canary.20250821T140634 (9c68abdb)
64
+ bun test v1.2.21-canary.20250823T140535 (9c68abdb)
65
65
 
66
66
  test/snap.test.ts:
67
67
  ✓ snapshot [1.05ms]
@@ -78,7 +78,7 @@ To update snapshots, use the `--update-snapshots` flag.
78
78
 
79
79
  ```sh
80
80
  $ bun test --update-snapshots
81
- bun test v1.2.21-canary.20250821T140634 (9c68abdb)
81
+ bun test v1.2.21-canary.20250823T140535 (9c68abdb)
82
82
 
83
83
  test/snap.test.ts:
84
84
  ✓ snapshot [0.86ms]
@@ -29,7 +29,7 @@ To regenerate snapshots, use the `--update-snapshots` flag.
29
29
 
30
30
  ```sh
31
31
  $ bun test --update-snapshots
32
- bun test v1.2.21-canary.20250821T140634 (9c68abdb)
32
+ bun test v1.2.21-canary.20250823T140535 (9c68abdb)
33
33
 
34
34
  test/snap.test.ts:
35
35
  ✓ snapshot [0.86ms]
@@ -5,7 +5,7 @@ name: Get the current Bun version
5
5
  Get the current version of Bun in a semver format.
6
6
 
7
7
  ```ts#index.ts
8
- Bun.version; // => "1.2.21-canary.20250821T140634"
8
+ Bun.version; // => "1.2.21-canary.20250823T140535"
9
9
  ```
10
10
 
11
11
  ---
@@ -0,0 +1,81 @@
1
+ Bun's package manager can scan packages for security vulnerabilities before installation, helping protect your applications from supply chain attacks and known vulnerabilities.
2
+
3
+ ## Quick Start
4
+
5
+ Configure a security scanner in your `bunfig.toml`:
6
+
7
+ ```toml
8
+ [install.security]
9
+ scanner = "@acme/bun-security-scanner"
10
+ ```
11
+
12
+ When configured, Bun will:
13
+
14
+ - Scan all packages before installation
15
+ - Display security warnings and advisories
16
+ - Cancel installation if critical vulnerabilities are found
17
+ - Automatically disable auto-install for security
18
+
19
+ ## How It Works
20
+
21
+ Security scanners analyze packages during `bun install`, `bun add`, and other package operations. They can detect:
22
+
23
+ - Known security vulnerabilities (CVEs)
24
+ - Malicious packages
25
+ - License compliance issues
26
+ - ...and more!
27
+
28
+ ### Security Levels
29
+
30
+ Scanners report issues at two severity levels:
31
+
32
+ - **`fatal`** - Installation stops immediately, exits with non-zero code
33
+ - **`warn`** - In interactive terminals, prompts to continue; in CI, exits immediately
34
+
35
+ ## Using Pre-built Scanners
36
+
37
+ Many security companies publish Bun security scanners as npm packages that you can install and use immediately.
38
+
39
+ ### Installing a Scanner
40
+
41
+ Install a security scanner from npm:
42
+
43
+ ```bash
44
+ $ bun add -d @acme/bun-security-scanner
45
+ ```
46
+
47
+ > **Note:** Consult your security scanner's documentation for their specific package name and installation instructions. Most scanners will be installed with `bun add`.
48
+
49
+ ### Configuring the Scanner
50
+
51
+ After installation, configure it in your `bunfig.toml`:
52
+
53
+ ```toml
54
+ [install.security]
55
+ scanner = "@acme/bun-security-scanner"
56
+ ```
57
+
58
+ ### Enterprise Configuration
59
+
60
+ Some enterprise scanners might support authentication and/or configuration through environment variables:
61
+
62
+ ```bash
63
+ # This might go in ~/.bashrc, for example
64
+ export SECURITY_API_KEY="your-api-key"
65
+
66
+ # The scanner will now use these credentials automatically
67
+ bun install
68
+ ```
69
+
70
+ Consult your security scanner's documentation to learn which environment variables to set and if any additional configuration is required.
71
+
72
+ ### Authoring your own scanner
73
+
74
+ For a complete example with tests and CI setup, see the official template:
75
+ [github.com/oven-sh/security-scanner-template](https://github.com/oven-sh/security-scanner-template)
76
+
77
+ ## Related
78
+
79
+ - [Configuration (bunfig.toml)](/docs/runtime/bunfig#installsecurityscanner)
80
+ - [Package Manager](/docs/install)
81
+ - [Security Scanner Template](https://github.com/oven-sh/security-scanner-template)
@@ -14,7 +14,7 @@ Kernel version 5.6 or higher is strongly recommended, but the minimum is 5.1. Us
14
14
  ```bash#macOS/Linux_(curl)
15
15
  $ curl -fsSL https://bun.com/install | bash # for macOS, Linux, and WSL
16
16
  # to install a specific version
17
- $ curl -fsSL https://bun.com/install | bash -s "bun-v1.2.21-canary.20250821T140634"
17
+ $ curl -fsSL https://bun.com/install | bash -s "bun-v1.2.21-canary.20250823T140535"
18
18
  ```
19
19
 
20
20
  ```bash#npm
@@ -189,10 +189,10 @@ Since Bun is a single binary, you can install older versions of Bun by re-runnin
189
189
 
190
190
  ### Installing a specific version of Bun on Linux/Mac
191
191
 
192
- To install a specific version of Bun, you can pass the git tag of the version you want to install to the install script, such as `bun-v1.2.0` or `bun-v1.2.21-canary.20250821T140634`.
192
+ To install a specific version of Bun, you can pass the git tag of the version you want to install to the install script, such as `bun-v1.2.0` or `bun-v1.2.21-canary.20250823T140535`.
193
193
 
194
194
  ```sh
195
- $ curl -fsSL https://bun.com/install | bash -s "bun-v1.2.21-canary.20250821T140634"
195
+ $ curl -fsSL https://bun.com/install | bash -s "bun-v1.2.21-canary.20250823T140535"
196
196
  ```
197
197
 
198
198
  ### Installing a specific version of Bun on Windows
@@ -201,7 +201,7 @@ On Windows, you can install a specific version of Bun by passing the version num
201
201
 
202
202
  ```sh
203
203
  # PowerShell:
204
- $ iex "& {$(irm https://bun.com/install.ps1)} -Version 1.2.21-canary.20250821T140634"
204
+ $ iex "& {$(irm https://bun.com/install.ps1)} -Version 1.2.21-canary.20250823T140535"
205
205
  ```
206
206
 
207
207
  ## Downloading Bun binaries directly
@@ -200,7 +200,7 @@ Click the link in the right column to jump to the associated documentation.
200
200
  ---
201
201
 
202
202
  - Low-level / Internals
203
- - `Bun.mmap`, `Bun.gc`, `Bun.generateHeapSnapshot`, [`bun:jsc`](https://bun.com/docs/api/bun-jsc)
203
+ - `Bun.mmap`, `Bun.gc`, `Bun.generateHeapSnapshot`, [`bun:jsc`](https://bun.com/reference/bun/jsc)
204
204
 
205
205
  ---
206
206
 
@@ -496,6 +496,32 @@ Whether to generate a non-Bun lockfile alongside `bun.lock`. (A `bun.lock` will
496
496
  print = "yarn"
497
497
  ```
498
498
 
499
+ ### `install.security.scanner`
500
+
501
+ Configure a security scanner to scan packages for vulnerabilities before installation.
502
+
503
+ First, install a security scanner from npm:
504
+
505
+ ```bash
506
+ $ bun add -d @acme/bun-security-scanner
507
+ ```
508
+
509
+ Then configure it in your `bunfig.toml`:
510
+
511
+ ```toml
512
+ [install.security]
513
+ scanner = "@acme/bun-security-scanner"
514
+ ```
515
+
516
+ When a security scanner is configured:
517
+
518
+ - Auto-install is automatically disabled for security
519
+ - Packages are scanned before installation
520
+ - Installation is cancelled if fatal issues are found
521
+ - Security warnings are displayed during installation
522
+
523
+ Learn more about [using and writing security scanners](/docs/install/security).
524
+
499
525
  ### `install.linker`
500
526
 
501
527
  Configure the default linker strategy. Default `"hoisted"`.
@@ -124,11 +124,11 @@ await fetch("https://example.com", {
124
124
  This prints the `fetch` request as a single-line `curl` command to let you copy-paste into your terminal to replicate the request.
125
125
 
126
126
  ```sh
127
- [fetch] $ curl --http1.1 "https://example.com/" -X POST -H "content-type: application/json" -H "Connection: keep-alive" -H "User-Agent: Bun/1.2.21-canary.20250821T140634" -H "Accept: */*" -H "Host: example.com" -H "Accept-Encoding: gzip, deflate, br" --compressed -H "Content-Length: 13" --data-raw "{\"foo\":\"bar\"}"
127
+ [fetch] $ curl --http1.1 "https://example.com/" -X POST -H "content-type: application/json" -H "Connection: keep-alive" -H "User-Agent: Bun/1.2.21-canary.20250823T140535" -H "Accept: */*" -H "Host: example.com" -H "Accept-Encoding: gzip, deflate, br" --compressed -H "Content-Length: 13" --data-raw "{\"foo\":\"bar\"}"
128
128
  [fetch] > HTTP/1.1 POST https://example.com/
129
129
  [fetch] > content-type: application/json
130
130
  [fetch] > Connection: keep-alive
131
- [fetch] > User-Agent: Bun/1.2.21-canary.20250821T140634
131
+ [fetch] > User-Agent: Bun/1.2.21-canary.20250823T140535
132
132
  [fetch] > Accept: */*
133
133
  [fetch] > Host: example.com
134
134
  [fetch] > Accept-Encoding: gzip, deflate, br
@@ -170,7 +170,7 @@ This prints the following to the console:
170
170
  [fetch] > HTTP/1.1 POST https://example.com/
171
171
  [fetch] > content-type: application/json
172
172
  [fetch] > Connection: keep-alive
173
- [fetch] > User-Agent: Bun/1.2.21-canary.20250821T140634
173
+ [fetch] > User-Agent: Bun/1.2.21-canary.20250823T140535
174
174
  [fetch] > Accept: */*
175
175
  [fetch] > Host: example.com
176
176
  [fetch] > Accept-Encoding: gzip, deflate, br
package/docs/test/dom.md CHANGED
@@ -55,7 +55,7 @@ Let's run this test with `bun test`:
55
55
 
56
56
  ```bash
57
57
  $ bun test
58
- bun test v1.2.21-canary.20250821T140634
58
+ bun test v1.2.21-canary.20250823T140535
59
59
 
60
60
  dom.test.ts:
61
61
  ✓ dom test [0.82ms]
package/extensions.d.ts CHANGED
@@ -8,6 +8,16 @@ declare module "*.toml" {
8
8
  export = contents;
9
9
  }
10
10
 
11
+ declare module "*.yaml" {
12
+ var contents: any;
13
+ export = contents;
14
+ }
15
+
16
+ declare module "*.yml" {
17
+ var contents: any;
18
+ export = contents;
19
+ }
20
+
11
21
  declare module "*.jsonc" {
12
22
  var contents: any;
13
23
  export = contents;
package/index.d.ts CHANGED
@@ -22,6 +22,7 @@
22
22
  /// <reference path="./shell.d.ts" />
23
23
  /// <reference path="./experimental.d.ts" />
24
24
  /// <reference path="./sql.d.ts" />
25
+ /// <reference path="./security.d.ts" />
25
26
 
26
27
  /// <reference path="./bun.ns.d.ts" />
27
28
 
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.2.21-canary.20250821T140634",
2
+ "version": "1.2.21-canary.20250823T140535",
3
3
  "name": "bun-types",
4
4
  "license": "MIT",
5
5
  "types": "./index.d.ts",
package/security.d.ts ADDED
@@ -0,0 +1,101 @@
1
+ declare module "bun" {
2
+ /**
3
+ * `bun install` security related declarations
4
+ */
5
+ export namespace Security {
6
+ export interface Package {
7
+ /**
8
+ * The name of the package
9
+ */
10
+ name: string;
11
+
12
+ /**
13
+ * The resolved version to be installed that matches the requested range.
14
+ *
15
+ * This is the exact version string, **not** a range.
16
+ */
17
+ version: string;
18
+
19
+ /**
20
+ * The URL of the tgz of this package that Bun will download
21
+ */
22
+ tarball: string;
23
+
24
+ /**
25
+ * The range that was requested by the command
26
+ *
27
+ * This could be a tag like `beta` or a semver range like `>=4.0.0`
28
+ */
29
+ requestedRange: string;
30
+ }
31
+
32
+ /**
33
+ * Advisory represents the result of a security scan result of a package
34
+ */
35
+ export interface Advisory {
36
+ /**
37
+ * Level represents the degree of danger for a security advisory
38
+ *
39
+ * Bun behaves differently depending on the values returned from the
40
+ * {@link Scanner.scan `scan()`} hook:
41
+ *
42
+ * > In any case, Bun *always* pretty prints *all* the advisories,
43
+ * > but...
44
+ * >
45
+ * > → if any **fatal**, Bun will immediately cancel the installation
46
+ * > and quit with a non-zero exit code
47
+ * >
48
+ * > → else if any **warn**, Bun will either ask the user if they'd like
49
+ * > to continue with the install if in a TTY environment, or
50
+ * > immediately exit if not.
51
+ */
52
+ level: "fatal" | "warn";
53
+
54
+ /**
55
+ * The name of the package attempting to be installed.
56
+ */
57
+ package: string;
58
+
59
+ /**
60
+ * If available, this is a url linking to a CVE or report online so
61
+ * users can learn more about the advisory.
62
+ */
63
+ url: string | null;
64
+
65
+ /**
66
+ * If available, this is a brief description of the advisory that Bun
67
+ * will print to the user.
68
+ */
69
+ description: string | null;
70
+ }
71
+
72
+ export interface Scanner {
73
+ /**
74
+ * This is the version of the scanner implementation. It may change in
75
+ * future versions, so we will use this version to discriminate between
76
+ * such versions. It's entirely possible this API changes in the future
77
+ * so much that version 1 would no longer be supported.
78
+ *
79
+ * The version is required because third-party scanner package versions
80
+ * are inherently unrelated to Bun versions
81
+ */
82
+ version: "1";
83
+
84
+ /**
85
+ * Perform an advisory check when a user ran `bun add <package>
86
+ * [...packages]` or other related/similar commands.
87
+ *
88
+ * If this function throws an error, Bun will immediately stop the
89
+ * install process and print the error to the user.
90
+ *
91
+ * @param info An object containing an array of packages to be added.
92
+ * The package array will contain all proposed dependencies, including
93
+ * transitive ones. More simply, that means it will include dependencies
94
+ * of the packages the user wants to add.
95
+ *
96
+ * @returns A list of advisories.
97
+ */
98
+ scan: (info: { packages: Package[] }) => Promise<Advisory[]>;
99
+ }
100
+ }
101
+ }
package/sql.d.ts CHANGED
@@ -82,6 +82,13 @@ declare module "bun" {
82
82
  );
83
83
  }
84
84
 
85
+ class MySQLError extends SQLError {
86
+ public readonly code: string;
87
+ public readonly errno: number | undefined;
88
+ public readonly sqlState: string | undefined;
89
+ constructor(message: string, options: { code: string; errno: number | undefined; sqlState: string | undefined });
90
+ }
91
+
85
92
  class SQLiteError extends SQLError {
86
93
  public readonly code: string;
87
94
  public readonly errno: number;
@@ -128,7 +135,7 @@ declare module "bun" {
128
135
  onclose?: ((err: Error | null) => void) | undefined;
129
136
  }
130
137
 
131
- interface PostgresOptions {
138
+ interface PostgresOrMySQLOptions {
132
139
  /**
133
140
  * Connection URL (can be string or URL object)
134
141
  */
@@ -196,7 +203,7 @@ declare module "bun" {
196
203
  * Database adapter/driver to use
197
204
  * @default "postgres"
198
205
  */
199
- adapter?: "postgres";
206
+ adapter?: "postgres" | "mysql" | "mariadb";
200
207
 
201
208
  /**
202
209
  * Maximum time in seconds to wait for connection to become available
@@ -265,14 +272,11 @@ declare module "bun" {
265
272
  */
266
273
  ssl?: TLSOptions | boolean | undefined;
267
274
 
268
- // `.path` is currently unsupported in Bun, the implementation is
269
- // incomplete.
270
- //
271
- // /**
272
- // * Unix domain socket path for connection
273
- // * @default ""
274
- // */
275
- // path?: string | undefined;
275
+ /**
276
+ * Unix domain socket path for connection
277
+ * @default undefined
278
+ */
279
+ path?: string | undefined;
276
280
 
277
281
  /**
278
282
  * Callback executed when a connection attempt completes
@@ -332,7 +336,7 @@ declare module "bun" {
332
336
  * };
333
337
  * ```
334
338
  */
335
- type Options = SQLiteOptions | PostgresOptions;
339
+ type Options = SQLiteOptions | PostgresOrMySQLOptions;
336
340
 
337
341
  /**
338
342
  * Represents a SQL query that can be executed, with additional control