Skip to content

Commit d9e0e0e

Browse files
authored
🤖 Merge PR DefinitelyTyped#73910 node: v24.10 by @Renegade334
1 parent 61b0377 commit d9e0e0e

File tree

6 files changed

+156
-11
lines changed

6 files changed

+156
-11
lines changed

types/node/console.d.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,9 +431,10 @@ declare module "node:console" {
431431
colorMode?: boolean | "auto" | undefined;
432432
/**
433433
* Specifies options that are passed along to
434-
* [`util.inspect()`](https://nodejs.org/docs/latest-v24.x/api/util.html#utilinspectobject-options).
434+
* `util.inspect()`. Can be an options object or, if different options
435+
* for stdout and stderr are desired, a `Map` from stream objects to options.
435436
*/
436-
inspectOptions?: InspectOptions | undefined;
437+
inspectOptions?: InspectOptions | ReadonlyMap<NodeJS.WritableStream, InspectOptions> | undefined;
437438
/**
438439
* Set group indentation.
439440
* @default 2

types/node/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"private": true,
33
"name": "@types/node",
4-
"version": "24.9.9999",
4+
"version": "24.10.9999",
55
"nonNpm": "conflict",
66
"nonNpmDescription": "Node.js",
77
"projects": [

types/node/sqlite.d.ts

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,64 @@ declare module "node:sqlite" {
329329
func: (...args: SQLOutputValue[]) => SQLInputValue,
330330
): void;
331331
function(name: string, func: (...args: SQLOutputValue[]) => SQLInputValue): void;
332+
/**
333+
* Sets an authorizer callback that SQLite will invoke whenever it attempts to
334+
* access data or modify the database schema through prepared statements.
335+
* This can be used to implement security policies, audit access, or restrict certain operations.
336+
* This method is a wrapper around [`sqlite3_set_authorizer()`](https://sqlite.org/c3ref/set_authorizer.html).
337+
*
338+
* When invoked, the callback receives five arguments:
339+
*
340+
* * `actionCode` {number} The type of operation being performed (e.g.,
341+
* `SQLITE_INSERT`, `SQLITE_UPDATE`, `SQLITE_SELECT`).
342+
* * `arg1` {string|null} The first argument (context-dependent, often a table name).
343+
* * `arg2` {string|null} The second argument (context-dependent, often a column name).
344+
* * `dbName` {string|null} The name of the database.
345+
* * `triggerOrView` {string|null} The name of the trigger or view causing the access.
346+
*
347+
* The callback must return one of the following constants:
348+
*
349+
* * `SQLITE_OK` - Allow the operation.
350+
* * `SQLITE_DENY` - Deny the operation (causes an error).
351+
* * `SQLITE_IGNORE` - Ignore the operation (silently skip).
352+
*
353+
* ```js
354+
* import { DatabaseSync, constants } from 'node:sqlite';
355+
* const db = new DatabaseSync(':memory:');
356+
*
357+
* // Set up an authorizer that denies all table creation
358+
* db.setAuthorizer((actionCode) => {
359+
* if (actionCode === constants.SQLITE_CREATE_TABLE) {
360+
* return constants.SQLITE_DENY;
361+
* }
362+
* return constants.SQLITE_OK;
363+
* });
364+
*
365+
* // This will work
366+
* db.prepare('SELECT 1').get();
367+
*
368+
* // This will throw an error due to authorization denial
369+
* try {
370+
* db.exec('CREATE TABLE blocked (id INTEGER)');
371+
* } catch (err) {
372+
* console.log('Operation blocked:', err.message);
373+
* }
374+
* ```
375+
* @since v24.10.0
376+
* @param callback The authorizer function to set, or `null` to
377+
* clear the current authorizer.
378+
*/
379+
setAuthorizer(
380+
callback:
381+
| ((
382+
actionCode: number,
383+
arg1: string | null,
384+
arg2: string | null,
385+
dbName: string | null,
386+
triggerOrView: string | null,
387+
) => number)
388+
| null,
389+
): void;
332390
/**
333391
* Whether the database is currently open or not.
334392
* @since v22.15.0
@@ -826,5 +884,54 @@ declare module "node:sqlite" {
826884
* @since v22.12.0
827885
*/
828886
const SQLITE_CHANGESET_ABORT: number;
887+
/**
888+
* Deny the operation and cause an error to be returned.
889+
* @since v24.10.0
890+
*/
891+
const SQLITE_DENY: number;
892+
/**
893+
* Ignore the operation and continue as if it had never been requested.
894+
* @since 24.10.0
895+
*/
896+
const SQLITE_IGNORE: number;
897+
/**
898+
* Allow the operation to proceed normally.
899+
* @since v24.10.0
900+
*/
901+
const SQLITE_OK: number;
902+
const SQLITE_CREATE_INDEX: number;
903+
const SQLITE_CREATE_TABLE: number;
904+
const SQLITE_CREATE_TEMP_INDEX: number;
905+
const SQLITE_CREATE_TEMP_TABLE: number;
906+
const SQLITE_CREATE_TEMP_TRIGGER: number;
907+
const SQLITE_CREATE_TEMP_VIEW: number;
908+
const SQLITE_CREATE_TRIGGER: number;
909+
const SQLITE_CREATE_VIEW: number;
910+
const SQLITE_DELETE: number;
911+
const SQLITE_DROP_INDEX: number;
912+
const SQLITE_DROP_TABLE: number;
913+
const SQLITE_DROP_TEMP_INDEX: number;
914+
const SQLITE_DROP_TEMP_TABLE: number;
915+
const SQLITE_DROP_TEMP_TRIGGER: number;
916+
const SQLITE_DROP_TEMP_VIEW: number;
917+
const SQLITE_DROP_TRIGGER: number;
918+
const SQLITE_DROP_VIEW: number;
919+
const SQLITE_INSERT: number;
920+
const SQLITE_PRAGMA: number;
921+
const SQLITE_READ: number;
922+
const SQLITE_SELECT: number;
923+
const SQLITE_TRANSACTION: number;
924+
const SQLITE_UPDATE: number;
925+
const SQLITE_ATTACH: number;
926+
const SQLITE_DETACH: number;
927+
const SQLITE_ALTER_TABLE: number;
928+
const SQLITE_REINDEX: number;
929+
const SQLITE_ANALYZE: number;
930+
const SQLITE_CREATE_VTABLE: number;
931+
const SQLITE_DROP_VTABLE: number;
932+
const SQLITE_FUNCTION: number;
933+
const SQLITE_SAVEPOINT: number;
934+
const SQLITE_COPY: number;
935+
const SQLITE_RECURSIVE: number;
829936
}
830937
}

types/node/test/console.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@ import { createWriteStream } from "node:fs";
1818
colorMode: "auto",
1919
ignoreErrors: true,
2020
groupIndentation: 2,
21+
inspectOptions: { depth: 1 },
2122
};
2223
consoleInstance = new console.Console(opts);
2324
consoleInstance = new console.Console({
2425
stdout: writeStream,
2526
colorMode: false,
27+
inspectOptions: new Map([[writeStream, { depth: 1 }]]),
2628
});
2729
consoleInstance = new console.Console({
2830
stdout: writeStream,

types/node/test/sqlite.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,3 +163,14 @@ import { TextEncoder } from "node:util";
163163
tagStore.db; // $ExpectType DatabaseSync
164164
tagStore.clear();
165165
}
166+
167+
{
168+
const db = new DatabaseSync(":memory:");
169+
170+
db.setAuthorizer((actionCode) => {
171+
if (actionCode === constants.SQLITE_CREATE_TABLE) {
172+
return constants.SQLITE_DENY;
173+
}
174+
return constants.SQLITE_OK;
175+
});
176+
}

types/node/url.d.ts

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,20 +71,44 @@ declare module "url" {
7171
* A `URIError` is thrown if the `auth` property is present but cannot be decoded.
7272
*
7373
* `url.parse()` uses a lenient, non-standard algorithm for parsing URL
74-
* strings. It is prone to security issues such as [host name spoofing](https://hackerone.com/reports/678487) and incorrect handling of usernames and passwords. Do not use with untrusted
75-
* input. CVEs are not issued for `url.parse()` vulnerabilities. Use the `WHATWG URL` API instead.
74+
* strings. It is prone to security issues such as [host name spoofing](https://hackerone.com/reports/678487)
75+
* and incorrect handling of usernames and passwords. Do not use with untrusted
76+
* input. CVEs are not issued for `url.parse()` vulnerabilities. Use the
77+
* [WHATWG URL](https://nodejs.org/docs/latest-v24.x/api/url.html#the-whatwg-url-api) API instead, for example:
78+
*
79+
* ```js
80+
* function getURL(req) {
81+
* const proto = req.headers['x-forwarded-proto'] || 'https';
82+
* const host = req.headers['x-forwarded-host'] || req.headers.host || 'example.com';
83+
* return new URL(req.url || '/', `${proto}://${host}`);
84+
* }
85+
* ```
86+
*
87+
* The example above assumes well-formed headers are forwarded from a reverse
88+
* proxy to your Node.js server. If you are not using a reverse proxy, you should
89+
* use the example below:
90+
*
91+
* ```js
92+
* function getURL(req) {
93+
* return new URL(req.url || '/', 'https://example.com');
94+
* }
95+
* ```
7696
* @since v0.1.25
7797
* @deprecated Use the WHATWG URL API instead.
7898
* @param urlString The URL string to parse.
79-
* @param [parseQueryString=false] If `true`, the `query` property will always be set to an object returned by the {@link querystring} module's `parse()` method. If `false`, the `query` property
80-
* on the returned URL object will be an unparsed, undecoded string.
81-
* @param [slashesDenoteHost=false] If `true`, the first token after the literal string `//` and preceding the next `/` will be interpreted as the `host`. For instance, given `//foo/bar`, the
82-
* result would be `{host: 'foo', pathname: '/bar'}` rather than `{pathname: '//foo/bar'}`.
99+
* @param parseQueryString If `true`, the `query` property will always
100+
* be set to an object returned by the [`querystring`](https://nodejs.org/docs/latest-v24.x/api/querystring.html) module's `parse()`
101+
* method. If `false`, the `query` property on the returned URL object will be an
102+
* unparsed, undecoded string. **Default:** `false`.
103+
* @param slashesDenoteHost If `true`, the first token after the literal
104+
* string `//` and preceding the next `/` will be interpreted as the `host`.
105+
* For instance, given `//foo/bar`, the result would be
106+
* `{host: 'foo', pathname: '/bar'}` rather than `{pathname: '//foo/bar'}`.
107+
* **Default:** `false`.
83108
*/
84-
function parse(urlString: string): UrlWithStringQuery;
85109
function parse(
86110
urlString: string,
87-
parseQueryString: false | undefined,
111+
parseQueryString?: false,
88112
slashesDenoteHost?: boolean,
89113
): UrlWithStringQuery;
90114
function parse(urlString: string, parseQueryString: true, slashesDenoteHost?: boolean): UrlWithParsedQuery;

0 commit comments

Comments
 (0)