better-sqlite3-multiple-ciphers 7.6.3-beta.0 → 8.0.0

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.
@@ -3,7 +3,7 @@
3
3
  ** Purpose: Header file for SQLite3 Multiple Ciphers support
4
4
  ** Author: Ulrich Telle
5
5
  ** Created: 2020-03-01
6
- ** Copyright: (c) 2019-2021 Ulrich Telle
6
+ ** Copyright: (c) 2019-2022 Ulrich Telle
7
7
  ** License: MIT
8
8
  */
9
9
 
@@ -30,10 +30,10 @@
30
30
  #define SQLITE3MC_VERSION_H_
31
31
 
32
32
  #define SQLITE3MC_VERSION_MAJOR 1
33
- #define SQLITE3MC_VERSION_MINOR 4
34
- #define SQLITE3MC_VERSION_RELEASE 8
33
+ #define SQLITE3MC_VERSION_MINOR 5
34
+ #define SQLITE3MC_VERSION_RELEASE 4
35
35
  #define SQLITE3MC_VERSION_SUBRELEASE 0
36
- #define SQLITE3MC_VERSION_STRING "SQLite3 Multiple Ciphers 1.4.8"
36
+ #define SQLITE3MC_VERSION_STRING "SQLite3 Multiple Ciphers 1.5.4"
37
37
 
38
38
  #endif /* SQLITE3MC_VERSION_H_ */
39
39
  /*** End of #include "sqlite3mc_version.h" ***/
@@ -192,9 +192,9 @@ extern "C" {
192
192
  ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
193
193
  ** [sqlite_version()] and [sqlite_source_id()].
194
194
  */
195
- #define SQLITE_VERSION "3.39.2"
196
- #define SQLITE_VERSION_NUMBER 3039002
197
- #define SQLITE_SOURCE_ID "2022-07-21 15:24:47 698edb77537b67c41adc68f9b892db56bcf9a55e00371a61420f3ddd668e6603"
195
+ #define SQLITE_VERSION "3.40.0"
196
+ #define SQLITE_VERSION_NUMBER 3040000
197
+ #define SQLITE_SOURCE_ID "2022-11-16 12:10:08 89c459e766ea7e9165d0beeb124708b955a4950d0f4792f457465d71b158d318"
198
198
 
199
199
  /*
200
200
  ** CAPI3REF: Run-Time Library Version Numbers
@@ -716,13 +716,17 @@ SQLITE_API int sqlite3_exec(
716
716
  **
717
717
  ** SQLite uses one of these integer values as the second
718
718
  ** argument to calls it makes to the xLock() and xUnlock() methods
719
- ** of an [sqlite3_io_methods] object.
719
+ ** of an [sqlite3_io_methods] object. These values are ordered from
720
+ ** lest restrictive to most restrictive.
721
+ **
722
+ ** The argument to xLock() is always SHARED or higher. The argument to
723
+ ** xUnlock is either SHARED or NONE.
720
724
  */
721
- #define SQLITE_LOCK_NONE 0
722
- #define SQLITE_LOCK_SHARED 1
723
- #define SQLITE_LOCK_RESERVED 2
724
- #define SQLITE_LOCK_PENDING 3
725
- #define SQLITE_LOCK_EXCLUSIVE 4
725
+ #define SQLITE_LOCK_NONE 0 /* xUnlock() only */
726
+ #define SQLITE_LOCK_SHARED 1 /* xLock() or xUnlock() */
727
+ #define SQLITE_LOCK_RESERVED 2 /* xLock() only */
728
+ #define SQLITE_LOCK_PENDING 3 /* xLock() only */
729
+ #define SQLITE_LOCK_EXCLUSIVE 4 /* xLock() only */
726
730
 
727
731
  /*
728
732
  ** CAPI3REF: Synchronization Type Flags
@@ -800,7 +804,14 @@ struct sqlite3_file {
800
804
  ** <li> [SQLITE_LOCK_PENDING], or
801
805
  ** <li> [SQLITE_LOCK_EXCLUSIVE].
802
806
  ** </ul>
803
- ** xLock() increases the lock. xUnlock() decreases the lock.
807
+ ** xLock() upgrades the database file lock. In other words, xLock() moves the
808
+ ** database file lock in the direction NONE toward EXCLUSIVE. The argument to
809
+ ** xLock() is always on of SHARED, RESERVED, PENDING, or EXCLUSIVE, never
810
+ ** SQLITE_LOCK_NONE. If the database file lock is already at or above the
811
+ ** requested lock, then the call to xLock() is a no-op.
812
+ ** xUnlock() downgrades the database file lock to either SHARED or NONE.
813
+ * If the lock is already at or below the requested lock state, then the call
814
+ ** to xUnlock() is a no-op.
804
815
  ** The xCheckReservedLock() method checks whether any database connection,
805
816
  ** either in this process or in some other process, is holding a RESERVED,
806
817
  ** PENDING, or EXCLUSIVE lock on the file. It returns true
@@ -905,9 +916,8 @@ struct sqlite3_io_methods {
905
916
  ** opcode causes the xFileControl method to write the current state of
906
917
  ** the lock (one of [SQLITE_LOCK_NONE], [SQLITE_LOCK_SHARED],
907
918
  ** [SQLITE_LOCK_RESERVED], [SQLITE_LOCK_PENDING], or [SQLITE_LOCK_EXCLUSIVE])
908
- ** into an integer that the pArg argument points to. This capability
909
- ** is used during testing and is only available when the SQLITE_TEST
910
- ** compile-time option is used.
919
+ ** into an integer that the pArg argument points to.
920
+ ** This capability is only available if SQLite is compiled with [SQLITE_DEBUG].
911
921
  **
912
922
  ** <li>[[SQLITE_FCNTL_SIZE_HINT]]
913
923
  ** The [SQLITE_FCNTL_SIZE_HINT] opcode is used by SQLite to give the VFS
@@ -1299,6 +1309,26 @@ typedef struct sqlite3_mutex sqlite3_mutex;
1299
1309
  */
1300
1310
  typedef struct sqlite3_api_routines sqlite3_api_routines;
1301
1311
 
1312
+ /*
1313
+ ** CAPI3REF: File Name
1314
+ **
1315
+ ** Type [sqlite3_filename] is used by SQLite to pass filenames to the
1316
+ ** xOpen method of a [VFS]. It may be cast to (const char*) and treated
1317
+ ** as a normal, nul-terminated, UTF-8 buffer containing the filename, but
1318
+ ** may also be passed to special APIs such as:
1319
+ **
1320
+ ** <ul>
1321
+ ** <li> sqlite3_filename_database()
1322
+ ** <li> sqlite3_filename_journal()
1323
+ ** <li> sqlite3_filename_wal()
1324
+ ** <li> sqlite3_uri_parameter()
1325
+ ** <li> sqlite3_uri_boolean()
1326
+ ** <li> sqlite3_uri_int64()
1327
+ ** <li> sqlite3_uri_key()
1328
+ ** </ul>
1329
+ */
1330
+ typedef const char *sqlite3_filename;
1331
+
1302
1332
  /*
1303
1333
  ** CAPI3REF: OS Interface Object
1304
1334
  **
@@ -1477,7 +1507,7 @@ struct sqlite3_vfs {
1477
1507
  sqlite3_vfs *pNext; /* Next registered VFS */
1478
1508
  const char *zName; /* Name of this virtual file system */
1479
1509
  void *pAppData; /* Pointer to application-specific data */
1480
- int (*xOpen)(sqlite3_vfs*, const char *zName, sqlite3_file*,
1510
+ int (*xOpen)(sqlite3_vfs*, sqlite3_filename zName, sqlite3_file*,
1481
1511
  int flags, int *pOutFlags);
1482
1512
  int (*xDelete)(sqlite3_vfs*, const char *zName, int syncDir);
1483
1513
  int (*xAccess)(sqlite3_vfs*, const char *zName, int flags, int *pResOut);
@@ -2355,6 +2385,7 @@ struct sqlite3_mem_methods {
2355
2385
  ** <ul>
2356
2386
  ** <li> The [PRAGMA writable_schema=ON] statement.
2357
2387
  ** <li> The [PRAGMA journal_mode=OFF] statement.
2388
+ ** <li> The [PRAGMA schema_version=N] statement.
2358
2389
  ** <li> Writes to the [sqlite_dbpage] virtual table.
2359
2390
  ** <li> Direct writes to [shadow tables].
2360
2391
  ** </ul>
@@ -3470,6 +3501,9 @@ SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
3470
3501
  ** <dd>The database is opened [shared cache] enabled, overriding
3471
3502
  ** the default shared cache setting provided by
3472
3503
  ** [sqlite3_enable_shared_cache()].)^
3504
+ ** The [use of shared cache mode is discouraged] and hence shared cache
3505
+ ** capabilities may be omitted from many builds of SQLite. In such cases,
3506
+ ** this option is a no-op.
3473
3507
  **
3474
3508
  ** ^(<dt>[SQLITE_OPEN_PRIVATECACHE]</dt>
3475
3509
  ** <dd>The database is opened [shared cache] disabled, overriding
@@ -3485,7 +3519,7 @@ SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
3485
3519
  ** to return an extended result code.</dd>
3486
3520
  **
3487
3521
  ** [[OPEN_NOFOLLOW]] ^(<dt>[SQLITE_OPEN_NOFOLLOW]</dt>
3488
- ** <dd>The database filename is not allowed to be a symbolic link</dd>
3522
+ ** <dd>The database filename is not allowed to contain a symbolic link</dd>
3489
3523
  ** </dl>)^
3490
3524
  **
3491
3525
  ** If the 3rd parameter to sqlite3_open_v2() is not one of the
@@ -3744,10 +3778,10 @@ SQLITE_API int sqlite3_open_v2(
3744
3778
  **
3745
3779
  ** See the [URI filename] documentation for additional information.
3746
3780
  */
3747
- SQLITE_API const char *sqlite3_uri_parameter(const char *zFilename, const char *zParam);
3748
- SQLITE_API int sqlite3_uri_boolean(const char *zFile, const char *zParam, int bDefault);
3749
- SQLITE_API sqlite3_int64 sqlite3_uri_int64(const char*, const char*, sqlite3_int64);
3750
- SQLITE_API const char *sqlite3_uri_key(const char *zFilename, int N);
3781
+ SQLITE_API const char *sqlite3_uri_parameter(sqlite3_filename z, const char *zParam);
3782
+ SQLITE_API int sqlite3_uri_boolean(sqlite3_filename z, const char *zParam, int bDefault);
3783
+ SQLITE_API sqlite3_int64 sqlite3_uri_int64(sqlite3_filename, const char*, sqlite3_int64);
3784
+ SQLITE_API const char *sqlite3_uri_key(sqlite3_filename z, int N);
3751
3785
 
3752
3786
  /*
3753
3787
  ** CAPI3REF: Translate filenames
@@ -3776,9 +3810,9 @@ SQLITE_API const char *sqlite3_uri_key(const char *zFilename, int N);
3776
3810
  ** return value from [sqlite3_db_filename()], then the result is
3777
3811
  ** undefined and is likely a memory access violation.
3778
3812
  */
3779
- SQLITE_API const char *sqlite3_filename_database(const char*);
3780
- SQLITE_API const char *sqlite3_filename_journal(const char*);
3781
- SQLITE_API const char *sqlite3_filename_wal(const char*);
3813
+ SQLITE_API const char *sqlite3_filename_database(sqlite3_filename);
3814
+ SQLITE_API const char *sqlite3_filename_journal(sqlite3_filename);
3815
+ SQLITE_API const char *sqlite3_filename_wal(sqlite3_filename);
3782
3816
 
3783
3817
  /*
3784
3818
  ** CAPI3REF: Database File Corresponding To A Journal
@@ -3844,14 +3878,14 @@ SQLITE_API sqlite3_file *sqlite3_database_file_object(const char*);
3844
3878
  ** then the corresponding [sqlite3_module.xClose() method should also be
3845
3879
  ** invoked prior to calling sqlite3_free_filename(Y).
3846
3880
  */
3847
- SQLITE_API char *sqlite3_create_filename(
3881
+ SQLITE_API sqlite3_filename sqlite3_create_filename(
3848
3882
  const char *zDatabase,
3849
3883
  const char *zJournal,
3850
3884
  const char *zWal,
3851
3885
  int nParam,
3852
3886
  const char **azParam
3853
3887
  );
3854
- SQLITE_API void sqlite3_free_filename(char*);
3888
+ SQLITE_API void sqlite3_free_filename(sqlite3_filename);
3855
3889
 
3856
3890
  /*
3857
3891
  ** CAPI3REF: Error Codes And Messages
@@ -5554,6 +5588,16 @@ SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int6
5554
5588
  ** then the conversion is performed. Otherwise no conversion occurs.
5555
5589
  ** The [SQLITE_INTEGER | datatype] after conversion is returned.)^
5556
5590
  **
5591
+ ** ^(The sqlite3_value_encoding(X) interface returns one of [SQLITE_UTF8],
5592
+ ** [SQLITE_UTF16BE], or [SQLITE_UTF16LE] according to the current encoding
5593
+ ** of the value X, assuming that X has type TEXT.)^ If sqlite3_value_type(X)
5594
+ ** returns something other than SQLITE_TEXT, then the return value from
5595
+ ** sqlite3_value_encoding(X) is meaningless. ^Calls to
5596
+ ** sqlite3_value_text(X), sqlite3_value_text16(X), sqlite3_value_text16be(X),
5597
+ ** sqlite3_value_text16le(X), sqlite3_value_bytes(X), or
5598
+ ** sqlite3_value_bytes16(X) might change the encoding of the value X and
5599
+ ** thus change the return from subsequent calls to sqlite3_value_encoding(X).
5600
+ **
5557
5601
  ** ^Within the [xUpdate] method of a [virtual table], the
5558
5602
  ** sqlite3_value_nochange(X) interface returns true if and only if
5559
5603
  ** the column corresponding to X is unchanged by the UPDATE operation
@@ -5618,6 +5662,7 @@ SQLITE_API int sqlite3_value_type(sqlite3_value*);
5618
5662
  SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*);
5619
5663
  SQLITE_API int sqlite3_value_nochange(sqlite3_value*);
5620
5664
  SQLITE_API int sqlite3_value_frombind(sqlite3_value*);
5665
+ SQLITE_API int sqlite3_value_encoding(sqlite3_value*);
5621
5666
 
5622
5667
  /*
5623
5668
  ** CAPI3REF: Finding The Subtype Of SQL Values
@@ -5671,7 +5716,7 @@ SQLITE_API void sqlite3_value_free(sqlite3_value*);
5671
5716
  **
5672
5717
  ** ^The sqlite3_aggregate_context(C,N) routine returns a NULL pointer
5673
5718
  ** when first called if N is less than or equal to zero or if a memory
5674
- ** allocate error occurs.
5719
+ ** allocation error occurs.
5675
5720
  **
5676
5721
  ** ^(The amount of space allocated by sqlite3_aggregate_context(C,N) is
5677
5722
  ** determined by the N parameter on first successful call. Changing the
@@ -5876,9 +5921,10 @@ typedef void (*sqlite3_destructor_type)(void*);
5876
5921
  ** of [SQLITE_UTF8], [SQLITE_UTF16], [SQLITE_UTF16BE], or [SQLITE_UTF16LE].
5877
5922
  ** ^SQLite takes the text result from the application from
5878
5923
  ** the 2nd parameter of the sqlite3_result_text* interfaces.
5879
- ** ^If the 3rd parameter to the sqlite3_result_text* interfaces
5880
- ** is negative, then SQLite takes result text from the 2nd parameter
5881
- ** through the first zero character.
5924
+ ** ^If the 3rd parameter to any of the sqlite3_result_text* interfaces
5925
+ ** other than sqlite3_result_text64() is negative, then SQLite computes
5926
+ ** the string length itself by searching the 2nd parameter for the first
5927
+ ** zero character.
5882
5928
  ** ^If the 3rd parameter to the sqlite3_result_text* interfaces
5883
5929
  ** is non-negative, then as many bytes (not characters) of the text
5884
5930
  ** pointed to by the 2nd parameter are taken as the application-defined
@@ -6374,7 +6420,7 @@ SQLITE_API const char *sqlite3_db_name(sqlite3 *db, int N);
6374
6420
  ** <li> [sqlite3_filename_wal()]
6375
6421
  ** </ul>
6376
6422
  */
6377
- SQLITE_API const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName);
6423
+ SQLITE_API sqlite3_filename sqlite3_db_filename(sqlite3 *db, const char *zDbName);
6378
6424
 
6379
6425
  /*
6380
6426
  ** CAPI3REF: Determine if a database is read-only
@@ -6511,7 +6557,7 @@ SQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
6511
6557
  ** function C that is invoked prior to each autovacuum of the database
6512
6558
  ** file. ^The callback is passed a copy of the generic data pointer (P),
6513
6559
  ** the schema-name of the attached database that is being autovacuumed,
6514
- ** the the size of the database file in pages, the number of free pages,
6560
+ ** the size of the database file in pages, the number of free pages,
6515
6561
  ** and the number of bytes per page, respectively. The callback should
6516
6562
  ** return the number of free pages that should be removed by the
6517
6563
  ** autovacuum. ^If the callback returns zero, then no autovacuum happens.
@@ -6632,6 +6678,11 @@ SQLITE_API void *sqlite3_update_hook(
6632
6678
  ** to the same database. Sharing is enabled if the argument is true
6633
6679
  ** and disabled if the argument is false.)^
6634
6680
  **
6681
+ ** This interface is omitted if SQLite is compiled with
6682
+ ** [-DSQLITE_OMIT_SHARED_CACHE]. The [-DSQLITE_OMIT_SHARED_CACHE]
6683
+ ** compile-time option is recommended because the
6684
+ ** [use of shared cache mode is discouraged].
6685
+ **
6635
6686
  ** ^Cache sharing is enabled and disabled for an entire process.
6636
6687
  ** This is a change as of SQLite [version 3.5.0] ([dateof:3.5.0]).
6637
6688
  ** In prior versions of SQLite,
@@ -6730,7 +6781,7 @@ SQLITE_API int sqlite3_db_release_memory(sqlite3*);
6730
6781
  ** ^The soft heap limit may not be greater than the hard heap limit.
6731
6782
  ** ^If the hard heap limit is enabled and if sqlite3_soft_heap_limit(N)
6732
6783
  ** is invoked with a value of N that is greater than the hard heap limit,
6733
- ** the the soft heap limit is set to the value of the hard heap limit.
6784
+ ** the soft heap limit is set to the value of the hard heap limit.
6734
6785
  ** ^The soft heap limit is automatically enabled whenever the hard heap
6735
6786
  ** limit is enabled. ^When sqlite3_hard_heap_limit64(N) is invoked and
6736
6787
  ** the soft heap limit is outside the range of 1..N, then the soft heap
@@ -9025,7 +9076,7 @@ typedef struct sqlite3_backup sqlite3_backup;
9025
9076
  ** if the application incorrectly accesses the destination [database connection]
9026
9077
  ** and so no error code is reported, but the operations may malfunction
9027
9078
  ** nevertheless. Use of the destination database connection while a
9028
- ** backup is in progress might also also cause a mutex deadlock.
9079
+ ** backup is in progress might also cause a mutex deadlock.
9029
9080
  **
9030
9081
  ** If running in [shared cache mode], the application must
9031
9082
  ** guarantee that the shared cache used by the destination database
@@ -9453,7 +9504,7 @@ SQLITE_API int sqlite3_wal_checkpoint_v2(
9453
9504
  */
9454
9505
  #define SQLITE_CHECKPOINT_PASSIVE 0 /* Do as much as possible w/o blocking */
9455
9506
  #define SQLITE_CHECKPOINT_FULL 1 /* Wait for writers, then checkpoint */
9456
- #define SQLITE_CHECKPOINT_RESTART 2 /* Like FULL but wait for for readers */
9507
+ #define SQLITE_CHECKPOINT_RESTART 2 /* Like FULL but wait for readers */
9457
9508
  #define SQLITE_CHECKPOINT_TRUNCATE 3 /* Like RESTART but also truncate WAL */
9458
9509
 
9459
9510
  /*
@@ -12989,13 +13040,13 @@ int sqlite3_user_delete(
12989
13040
  /*
12990
13041
  ** Symbols for ciphers
12991
13042
  */
12992
- #define CODEC_TYPE_UNKNOWN 0
12993
- #define CODEC_TYPE_AES128 1
12994
- #define CODEC_TYPE_AES256 2
12995
- #define CODEC_TYPE_CHACHA20 3
12996
- #define CODEC_TYPE_SQLCIPHER 4
12997
- #define CODEC_TYPE_RC4 5
12998
- #define CODEC_TYPE_MAX 5
13043
+ #define CODEC_TYPE_UNKNOWN 0
13044
+ #define CODEC_TYPE_AES128 1
13045
+ #define CODEC_TYPE_AES256 2
13046
+ #define CODEC_TYPE_CHACHA20 3
13047
+ #define CODEC_TYPE_SQLCIPHER 4
13048
+ #define CODEC_TYPE_RC4 5
13049
+ #define CODEC_TYPE_MAX_BUILTIN 5
12999
13050
 
13000
13051
  /*
13001
13052
  ** Definition of API functions
@@ -13064,6 +13115,9 @@ SQLITE_API void sqlite3_activate_see(const char* zPassPhrase);
13064
13115
  /*
13065
13116
  ** Define functions for the configuration of the wxSQLite3 encryption extension
13066
13117
  */
13118
+ SQLITE_API int sqlite3mc_cipher_count();
13119
+ SQLITE_API int sqlite3mc_cipher_index(const char* cipherName);
13120
+ SQLITE_API const char* sqlite3mc_cipher_name(int cipherIndex);
13067
13121
  SQLITE_API int sqlite3mc_config(sqlite3* db, const char* paramName, int newValue);
13068
13122
  SQLITE_API int sqlite3mc_config_cipher(sqlite3* db, const char* cipherName, const char* paramName, int newValue);
13069
13123
  SQLITE_API unsigned char* sqlite3mc_codec_data(sqlite3* db, const char* zDbName, const char* paramName);
@@ -13075,6 +13129,88 @@ SQLITE_API int wxsqlite3_config_cipher(sqlite3* db, const char* cipherName, cons
13075
13129
  SQLITE_API unsigned char* wxsqlite3_codec_data(sqlite3* db, const char* zDbName, const char* paramName);
13076
13130
  #endif
13077
13131
 
13132
+ /*
13133
+ ** Structures and functions to dynamically register a cipher
13134
+ */
13135
+
13136
+ /*
13137
+ ** Structure for a single cipher configuration parameter
13138
+ **
13139
+ ** Components:
13140
+ ** m_name - name of parameter (1st char = alpha, rest = alphanumeric or underscore, max 63 characters)
13141
+ ** m_value - current/transient parameter value
13142
+ ** m_default - default parameter value
13143
+ ** m_minValue - minimum valid parameter value
13144
+ ** m_maxValue - maximum valid parameter value
13145
+ */
13146
+ typedef struct _CipherParams
13147
+ {
13148
+ char* m_name;
13149
+ int m_value;
13150
+ int m_default;
13151
+ int m_minValue;
13152
+ int m_maxValue;
13153
+ } CipherParams;
13154
+
13155
+ /*
13156
+ ** Structure for a cipher API
13157
+ **
13158
+ ** Components:
13159
+ ** m_name - name of cipher (1st char = alpha, rest = alphanumeric or underscore, max 63 characters)
13160
+ ** m_allocateCipher - Function pointer for function AllocateCipher
13161
+ ** m_freeCipher - Function pointer for function FreeCipher
13162
+ ** m_cloneCipher - Function pointer for function CloneCipher
13163
+ ** m_getLegacy - Function pointer for function GetLegacy
13164
+ ** m_getPageSize - Function pointer for function GetPageSize
13165
+ ** m_getReserved - Function pointer for function GetReserved
13166
+ ** m_getSalt - Function pointer for function GetSalt
13167
+ ** m_generateKey - Function pointer for function GenerateKey
13168
+ ** m_encryptPage - Function pointer for function EncryptPage
13169
+ ** m_decryptPage - Function pointer for function DecryptPage
13170
+ */
13171
+
13172
+ typedef struct BtShared BtSharedMC;
13173
+
13174
+ typedef void* (*AllocateCipher_t)(sqlite3* db);
13175
+ typedef void (*FreeCipher_t)(void* cipher);
13176
+ typedef void (*CloneCipher_t)(void* cipherTo, void* cipherFrom);
13177
+ typedef int (*GetLegacy_t)(void* cipher);
13178
+ typedef int (*GetPageSize_t)(void* cipher);
13179
+ typedef int (*GetReserved_t)(void* cipher);
13180
+ typedef unsigned char* (*GetSalt_t)(void* cipher);
13181
+ typedef void (*GenerateKey_t)(void* cipher, BtSharedMC* pBt, char* userPassword, int passwordLength, int rekey, unsigned char* cipherSalt);
13182
+ typedef int (*EncryptPage_t)(void* cipher, int page, unsigned char* data, int len, int reserved);
13183
+ typedef int (*DecryptPage_t)(void* cipher, int page, unsigned char* data, int len, int reserved, int hmacCheck);
13184
+
13185
+ typedef struct _CipherDescriptor
13186
+ {
13187
+ char* m_name;
13188
+ AllocateCipher_t m_allocateCipher;
13189
+ FreeCipher_t m_freeCipher;
13190
+ CloneCipher_t m_cloneCipher;
13191
+ GetLegacy_t m_getLegacy;
13192
+ GetPageSize_t m_getPageSize;
13193
+ GetReserved_t m_getReserved;
13194
+ GetSalt_t m_getSalt;
13195
+ GenerateKey_t m_generateKey;
13196
+ EncryptPage_t m_encryptPage;
13197
+ DecryptPage_t m_decryptPage;
13198
+ } CipherDescriptor;
13199
+
13200
+ /*
13201
+ ** Register a cipher
13202
+ **
13203
+ ** Arguments:
13204
+ ** desc - Cipher descriptor structure
13205
+ ** params - Cipher configuration parameter table
13206
+ ** makeDefault - flag whether to make the cipher the default cipher
13207
+ **
13208
+ ** Returns:
13209
+ ** SQLITE_OK - the cipher could be registered successfully
13210
+ ** SQLITE_ERROR - the cipher could not be registered
13211
+ */
13212
+ SQLITE_API int sqlite3mc_register_cipher(const CipherDescriptor* desc, const CipherParams* params, int makeDefault);
13213
+
13078
13214
  #ifdef __cplusplus
13079
13215
  }
13080
13216
  #endif
@@ -331,9 +331,9 @@ struct sqlite3_api_routines {
331
331
  const char *(*filename_journal)(const char*);
332
332
  const char *(*filename_wal)(const char*);
333
333
  /* Version 3.32.0 and later */
334
- char *(*create_filename)(const char*,const char*,const char*,
334
+ const char *(*create_filename)(const char*,const char*,const char*,
335
335
  int,const char**);
336
- void (*free_filename)(char*);
336
+ void (*free_filename)(const char*);
337
337
  sqlite3_file *(*database_file_object)(const char*);
338
338
  /* Version 3.34.0 and later */
339
339
  int (*txn_state)(sqlite3*,const char*);
@@ -357,6 +357,8 @@ struct sqlite3_api_routines {
357
357
  unsigned char *(*serialize)(sqlite3*,const char *,sqlite3_int64*,
358
358
  unsigned int);
359
359
  const char *(*db_name)(sqlite3*,int);
360
+ /* Version 3.40.0 and later */
361
+ int (*value_encoding)(sqlite3_value*);
360
362
  };
361
363
 
362
364
  /*
@@ -681,6 +683,8 @@ typedef int (*sqlite3_loadext_entry)(
681
683
  #define sqlite3_serialize sqlite3_api->serialize
682
684
  #endif
683
685
  #define sqlite3_db_name sqlite3_api->db_name
686
+ /* Version 3.40.0 and later */
687
+ #define sqlite3_value_encoding sqlite3_api->value_encoding
684
688
  #endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */
685
689
 
686
690
  #if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "better-sqlite3-multiple-ciphers",
3
- "version": "7.6.3-beta.0",
3
+ "version": "8.0.0",
4
4
  "description": "better-sqlite3 with multiple-cipher encryption support",
5
5
  "homepage": "https://github.com/m4heshd/better-sqlite3-multiple-ciphers",
6
6
  "author": "Mahesh Bandara Wijerathna (m4heshd) <m4heshd@gmail.com>",
@@ -9,6 +9,7 @@
9
9
  "url": "git://github.com/m4heshd/better-sqlite3-multiple-ciphers.git"
10
10
  },
11
11
  "main": "lib/index.js",
12
+ "types": "index.d.ts",
12
13
  "files": [
13
14
  "binding.gyp",
14
15
  "src/*.[ch]pp",
@@ -24,13 +25,20 @@
24
25
  "cli-color": "^2.0.2",
25
26
  "fs-extra": "^10.1.0",
26
27
  "mocha": "^8.3.2",
28
+ "node-gyp": "8.4.1",
27
29
  "nodemark": "^0.3.0",
28
30
  "prebuild": "^11.0.4",
29
31
  "sqlite": "^4.1.1",
30
- "sqlite3": "^5.0.8"
32
+ "sqlite3": "^5.0.8",
33
+ "@types/better-sqlite3": "latest"
34
+ },
35
+ "overrides": {
36
+ "prebuild": {
37
+ "node-gyp": "$node-gyp"
38
+ }
31
39
  },
32
40
  "scripts": {
33
- "install": "prebuild-install || npm run build-release",
41
+ "install": "prebuild-install || node-gyp rebuild --release",
34
42
  "build-release": "node-gyp rebuild --release",
35
43
  "build-debug": "node-gyp rebuild --debug",
36
44
  "rebuild-release": "npm run lzz && npm run build-release",
@@ -2,6 +2,21 @@
2
2
  //
3
3
 
4
4
  #include "better_sqlite3.hpp"
5
+ #line 39 "./src/util/binder.lzz"
6
+ static bool IsPlainObject(v8::Isolate* isolate, v8::Local<v8::Object> obj) {
7
+ v8::Local<v8::Value> proto = obj->GetPrototype();
8
+
9
+ #if defined NODE_MODULE_VERSION && NODE_MODULE_VERSION < 93
10
+ v8::Local<v8::Context> ctx = obj->CreationContext();
11
+ #else
12
+ v8::Local<v8::Context> ctx = obj->GetCreationContext().ToLocalChecked();
13
+ #endif
14
+
15
+ ctx->Enter();
16
+ v8::Local<v8::Value> baseProto = v8::Object::New(isolate)->GetPrototype();
17
+ ctx->Exit();
18
+ return proto->StrictEquals(baseProto) || proto->StrictEquals(v8::Null(isolate));
19
+ }
5
20
  #line 67 "./src/better_sqlite3.lzz"
6
21
  NODE_MODULE_INIT(/* exports, context */) {
7
22
  v8::Isolate* isolate = context->GetIsolate();
@@ -104,8 +119,7 @@ void SetPrototypeGetter (v8::Isolate * isolate, v8::Local <v8::External> data, v
104
119
  0,
105
120
  data,
106
121
  v8::AccessControl::DEFAULT,
107
- v8::PropertyAttribute::None,
108
- v8::AccessorSignature::New(isolate, recv)
122
+ v8::PropertyAttribute::None
109
123
  );
110
124
  }
111
125
  #line 4 "./src/util/constants.lzz"
@@ -1748,6 +1762,13 @@ int CustomTable::xBestIndex (sqlite3_vtab * vtab, sqlite3_index_info * output)
1748
1762
  auto item = output->aConstraint[i];
1749
1763
 
1750
1764
 
1765
+
1766
+
1767
+
1768
+ if (item.op == SQLITE_INDEX_CONSTRAINT_LIMIT || item.op == SQLITE_INDEX_CONSTRAINT_OFFSET) {
1769
+ continue;
1770
+ }
1771
+
1751
1772
  if (item.iColumn >= 0 && item.iColumn < parameter_count) {
1752
1773
  if (item.op != SQLITE_INDEX_CONSTRAINT_EQ) {
1753
1774
  sqlite3_free(vtab->zErrMsg);
@@ -1782,9 +1803,9 @@ int CustomTable::xBestIndex (sqlite3_vtab * vtab, sqlite3_index_info * output)
1782
1803
  output->estimatedCost = output->estimatedRows = 1000000000 / (argument_count + 1);
1783
1804
  return SQLITE_OK;
1784
1805
  }
1785
- #line 387 "./src/util/custom-table.lzz"
1806
+ #line 394 "./src/util/custom-table.lzz"
1786
1807
  void CustomTable::PropagateJSError ()
1787
- #line 387 "./src/util/custom-table.lzz"
1808
+ #line 394 "./src/util/custom-table.lzz"
1788
1809
  {
1789
1810
  assert(db->GetState()->was_js_error == false);
1790
1811
  db->GetState()->was_js_error = true;
@@ -1944,20 +1965,9 @@ bool Binder::Bind (v8::FunctionCallbackInfo <v8 :: Value> const & info, int argc
1944
1965
  }
1945
1966
  return success;
1946
1967
  }
1947
- #line 35 "./src/util/binder.lzz"
1948
- bool Binder::IsPlainObject (v8::Isolate * isolate, v8::Local <v8::Object> obj)
1949
- #line 35 "./src/util/binder.lzz"
1950
- {
1951
- v8::Local<v8::Value> proto = obj->GetPrototype();
1952
- v8::Local<v8::Context> ctx = obj->CreationContext();
1953
- ctx->Enter();
1954
- v8::Local<v8::Value> baseProto = v8::Object::New(isolate)->GetPrototype();
1955
- ctx->Exit();
1956
- return proto->StrictEquals(baseProto) || proto->StrictEquals(v8::Null(isolate));
1957
- }
1958
- #line 44 "./src/util/binder.lzz"
1968
+ #line 54 "./src/util/binder.lzz"
1959
1969
  void Binder::Fail (void (* Throw) (char const *), char const * message)
1960
- #line 44 "./src/util/binder.lzz"
1970
+ #line 54 "./src/util/binder.lzz"
1961
1971
  {
1962
1972
  assert(success == true);
1963
1973
  assert((Throw == NULL) == (message == NULL));
@@ -1965,16 +1975,16 @@ void Binder::Fail (void (* Throw) (char const *), char const * message)
1965
1975
  if (Throw) Throw(message);
1966
1976
  success = false;
1967
1977
  }
1968
- #line 52 "./src/util/binder.lzz"
1978
+ #line 62 "./src/util/binder.lzz"
1969
1979
  int Binder::NextAnonIndex ()
1970
- #line 52 "./src/util/binder.lzz"
1980
+ #line 62 "./src/util/binder.lzz"
1971
1981
  {
1972
1982
  while (sqlite3_bind_parameter_name(handle, ++anon_index) != NULL) {}
1973
1983
  return anon_index;
1974
1984
  }
1975
- #line 58 "./src/util/binder.lzz"
1985
+ #line 68 "./src/util/binder.lzz"
1976
1986
  void Binder::BindValue (v8::Isolate * isolate, v8::Local <v8::Value> value, int index)
1977
- #line 58 "./src/util/binder.lzz"
1987
+ #line 68 "./src/util/binder.lzz"
1978
1988
  {
1979
1989
  int status = Data::BindValueFromJS(isolate, handle, index, value);
1980
1990
  if (status != SQLITE_OK) {
@@ -1993,9 +2003,9 @@ void Binder::BindValue (v8::Isolate * isolate, v8::Local <v8::Value> value, int
1993
2003
  assert(false);
1994
2004
  }
1995
2005
  }
1996
- #line 79 "./src/util/binder.lzz"
2006
+ #line 89 "./src/util/binder.lzz"
1997
2007
  int Binder::BindArray (v8::Isolate * isolate, v8::Local <v8::Array> arr)
1998
- #line 79 "./src/util/binder.lzz"
2008
+ #line 89 "./src/util/binder.lzz"
1999
2009
  {
2000
2010
  v8 :: Local < v8 :: Context > ctx = isolate -> GetCurrentContext ( ) ;
2001
2011
  uint32_t length = arr->Length();
@@ -2017,9 +2027,9 @@ int Binder::BindArray (v8::Isolate * isolate, v8::Local <v8::Array> arr)
2017
2027
  }
2018
2028
  return len;
2019
2029
  }
2020
- #line 105 "./src/util/binder.lzz"
2030
+ #line 115 "./src/util/binder.lzz"
2021
2031
  int Binder::BindObject (v8::Isolate * isolate, v8::Local <v8::Object> obj, Statement * stmt)
2022
- #line 105 "./src/util/binder.lzz"
2032
+ #line 115 "./src/util/binder.lzz"
2023
2033
  {
2024
2034
  v8 :: Local < v8 :: Context > ctx = isolate -> GetCurrentContext ( ) ;
2025
2035
  BindMap* bind_map = stmt->GetBindMap(isolate);
@@ -2056,9 +2066,9 @@ int Binder::BindObject (v8::Isolate * isolate, v8::Local <v8::Object> obj, State
2056
2066
 
2057
2067
  return len;
2058
2068
  }
2059
- #line 149 "./src/util/binder.lzz"
2069
+ #line 159 "./src/util/binder.lzz"
2060
2070
  Binder::Result Binder::BindArgs (v8::FunctionCallbackInfo <v8 :: Value> const & info, int argc, Statement * stmt)
2061
- #line 149 "./src/util/binder.lzz"
2071
+ #line 159 "./src/util/binder.lzz"
2062
2072
  {
2063
2073
  v8 :: Isolate * isolate = info . GetIsolate ( ) ;
2064
2074
  int count = 0;