Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Minor touchups in JS docs and exception messages. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
9e7fc9370dfca121244f7a2941e8de62 |
User & Date: | stephan 2024-04-23 06:36:28 |
Context
2024-04-23
| ||
06:49 | Remove some dead WASM-side code. (check-in: 0a07ee27 user: stephan tags: trunk) | |
06:36 | Minor touchups in JS docs and exception messages. (check-in: 9e7fc937 user: stephan tags: trunk) | |
05:38 | When running the 'dist' target in ext/wasm for an SEE-capable build, ensure that the resulting zip file and directory name include '-see'. (check-in: 04c552b1 user: stephan tags: trunk) | |
Changes
Changes to ext/wasm/api/sqlite3-api-oo1.js.
︙ | ︙ | |||
108 109 110 111 112 113 114 | Internal helper to apply an SEE key to a just-opened database. Requires that db be-a DB object which has just been opened, opt be the options object processed by its ctor, and opt must have either the key, hexkey, or textkey properties, either as a string, an ArrayBuffer, or a Uint8Array. This is a no-op in non-SEE builds. It throws on error and returns | | > | | > > | > > | > > | > > | > | 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | Internal helper to apply an SEE key to a just-opened database. Requires that db be-a DB object which has just been opened, opt be the options object processed by its ctor, and opt must have either the key, hexkey, or textkey properties, either as a string, an ArrayBuffer, or a Uint8Array. This is a no-op in non-SEE builds. It throws on error and returns without side effects if none of the key/textkey/hexkey options are set. It throws if more than one is set or if any are set to values of an invalid type. Returns true if it applies the key, else an unspecified falsy value. */ const dbCtorApplySEEKey = function(db,opt){ if( !capi.sqlite3_key_v2 ) return; let keytype; let key; const check = (opt.key ? 1 : 0) + (opt.hexkey ? 1 : 0) + (opt.textkey ? 1 : 0); if( !check ) return; else if( check>1 ){ toss3(capi.SQLITE_MISUSE, "Only ONE of (key, hexkey, textkey) may be provided."); } if( opt.key ){ /* It is not legal to bind an argument to PRAGMA key=?, so we convert it to a hexkey... */ keytype = 'key'; key = opt.key; if('string'===typeof key){ key = new TextEncoder('utf-8').encode(key); } if((key instanceof ArrayBuffer) || (key instanceof Uint8Array)){ key = byteArrayToHex(key); keytype = 'hexkey'; }else{ toss3(capi.SQLITE_MISUSE, "Invalid value for the 'key' option. Expecting a string,", "ArrayBuffer, or Uint8Array."); return; } }else if( opt.textkey ){ /* For textkey we need it to be in string form, so convert it to a string if it's a byte array... */ keytype = 'textkey'; key = opt.textkey; if(key instanceof ArrayBuffer){ key = new Uint8Array(key); } if(key instanceof Uint8Array){ key = new TextDecoder('utf-8').decode(key); }else if('string'!==typeof key){ toss3(capi.SQLITE_MISUSE, "Invalid value for the 'textkey' option. Expecting a string,", "ArrayBuffer, or Uint8Array."); } }else if( opt.hexkey ){ keytype = 'hexkey'; key = opt.hexkey; if((key instanceof ArrayBuffer) || (key instanceof Uint8Array)){ key = byteArrayToHex(key); }else if('string'!==typeof key){ toss3(capi.SQLITE_MISUSE, "Invalid value for the 'hexkey' option. Expecting a string,", "ArrayBuffer, or Uint8Array."); } /* else assume it's valid hex codes */ }else{ return; } let stmt; try{ |
︙ | ︙ | |||
377 378 379 380 381 382 383 | properties: - `filename`: database file name - `flags`: open-mode flags - `vfs`: the VFS fname //#if enable-see | > | > | | | | | > > > > > > > > | 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 | properties: - `filename`: database file name - `flags`: open-mode flags - `vfs`: the VFS fname //#if enable-see SEE-capable builds optionally support ONE of the following additional options: - `key`, `hexkey`, or `textkey`: encryption key as a string, ArrayBuffer, or Uint8Array. These flags function as documented for the SEE pragmas of the same names. Using a byte array for `hexkey` is equivalent to the same series of hex codes in string form, so `'666f6f'` is equivalent to `Uint8Array([0x66,0x6f,0x6f])`. A `textkey` byte array is assumed to be UTF-8. A `key` string is transformed into a UTF-8 byte array, and a `key` byte array is transformed into a `hexkey` with the same bytes. In non-SEE builds, these options are ignored. In SEE builds, `PRAGMA key/textkey/hexkey=X` is executed immediately after opening the db. If more than one of the options is provided, or any option has an invalid argument type, an exception is thrown. Note that some DB subclasses may run post-initialization SQL code, e.g. to set a busy-handler timeout or tweak the page cache size. Such code is run _after_ the SEE key is applied. If no key is supplied and the database is encrypted, execution of the post-initialization SQL will fail, causing the constructor to throw. //#endif enable-see The `filename` and `vfs` arguments may be either JS strings or C-strings allocated via WASM. `flags` is required to be a JS string (because it's specific to this API, which is specific to JS). |
︙ | ︙ |
Changes to ext/wasm/api/sqlite3-api-prologue.js.
︙ | ︙ | |||
241 242 243 244 245 246 247 | If called with exactly 2 arguments and the 2nd is an object, that object is treated as the 2nd argument to the parent constructor. The exception's message is created by concatenating its arguments with a space between each, except for the | | | 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 | If called with exactly 2 arguments and the 2nd is an object, that object is treated as the 2nd argument to the parent constructor. The exception's message is created by concatenating its arguments with a space between each, except for the two-args-with-an-object form and that the first argument will get coerced to a string, as described above, if it's an integer. If passed an integer first argument, the error object's `resultCode` member will be set to the given integer value, else it will be set to capi.SQLITE_ERROR. */ |
︙ | ︙ |