Skip to content

v0.3.5

Choose a tag to compare

@github-actions github-actions released this 16 Nov 01:55
8faaff0

This version adds a guard for the SQL text of a caller, and a function that gives each statement of a text. The change is backward compatible.

  • confineToFile(db) keeps the SQL of a node:sqlite connection on its file. It refuses ATTACH of a file, VACUUM INTO, the pragmas temp_store_directory and data_store_directory, and the function load_extension.
  • Each other statement runs as before. A plain VACUUM and clearDatabase also work.
  • The guard does not limit the time or the size of the work of a caller. An ATTACH '' can fill the temporary folder until the close. The host sets these limits.
  • The guard is the authorizer of SQLite, so it sees the statement after the parse. Comments, case and quotes do not change the result.
  • The guard needs setAuthorizer of Node.js 24.10 or later. On an earlier Node.js, confineToFile throws the new ConfineUnavailableError (code: "CONFINE_UNAVAILABLE"). The package still runs on Node.js 22.13.
  • The type ConfinableDatabase is the part of a connection that the guard uses.
  • eachStatement(db, sql) gives each statement of a SQL text in order. The function prepare of node:sqlite compiles only the first statement, and it ignores the rest with no error.
  • eachStatement compiles the next statement after the run of the statement before it. Thus a script can make a table and then write to it.
  • The types SourcedStatement and StatementSource are the parts of a statement and a connection that eachStatement uses.

Runtime dependencies: none.