v1.0.0
This commit is contained in:
commit
9d3a85329e
157
.github/workflows/publish.yaml
vendored
Normal file
157
.github/workflows/publish.yaml
vendored
Normal file
@ -0,0 +1,157 @@
|
||||
# Copyright 2025 Signal Messenger, LLC
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
name: Publish
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
dry_run:
|
||||
description: "Just build, don't publish"
|
||||
default: false
|
||||
required: false
|
||||
type: boolean
|
||||
npm_tag:
|
||||
description: 'NPM tag'
|
||||
required: true
|
||||
default: 'latest'
|
||||
|
||||
jobs:
|
||||
prebuild:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [windows-latest, macos-latest]
|
||||
include:
|
||||
- os: macos-latest
|
||||
target: arm64
|
||||
cross-target: x64
|
||||
rust-cross-target: x86_64-apple-darwin
|
||||
- os: windows-latest
|
||||
target: x64
|
||||
cross-target: arm64
|
||||
rust-cross-target: aarch64-pc-windows-msvc
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
timeout-minutes: 30
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
- name: Setup pnpm
|
||||
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0
|
||||
with:
|
||||
version: 10.3.0
|
||||
|
||||
- name: Get Node version from .nvmrc
|
||||
id: get-nvm-version
|
||||
shell: bash
|
||||
run: echo "node-version=$(cat .nvmrc)" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Setup node.js
|
||||
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
|
||||
with:
|
||||
node-version-file: '.nvmrc'
|
||||
|
||||
- name: Install node_modules
|
||||
run: pnpm install --frozen-lockfile
|
||||
|
||||
- run: rustup toolchain install $(cat rust-toolchain) --profile minimal --target ${{ matrix.rust-cross-target }}
|
||||
|
||||
- name: Install dump_syms
|
||||
run: cargo install dump_syms --no-default-features --features cli
|
||||
|
||||
- name: Prebuild ${{ matrix.target }}
|
||||
run: |
|
||||
pnpm prebuildify --target '${{ steps.get-nvm-version.outputs.node-version }}' --arch ${{ matrix.target }}
|
||||
- name: Prebuild ${{ matrix.cross-target }}
|
||||
run: pnpm prebuildify --target '${{ steps.get-nvm-version.outputs.node-version }}' --arch ${{ matrix.cross-target }}
|
||||
|
||||
- name: Upload artifacts
|
||||
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
|
||||
with:
|
||||
name: sqlcipher-${{matrix.os}}
|
||||
path: prebuilds/*
|
||||
|
||||
prebuild_linux:
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 30
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
- name: Build in docker container
|
||||
run: ./docker-prebuildify.sh
|
||||
|
||||
- name: Upload artifacts
|
||||
uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1
|
||||
with:
|
||||
name: sqlcipher-linux-latest
|
||||
path: prebuilds/*
|
||||
|
||||
publish:
|
||||
name: Publish
|
||||
|
||||
permissions:
|
||||
# Needed for ncipollo/release-action.
|
||||
contents: 'write'
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
needs: [prebuild, prebuild_linux]
|
||||
|
||||
timeout-minutes: 45
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
|
||||
- name: Setup pnpm
|
||||
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0
|
||||
with:
|
||||
version: 10.3.0
|
||||
- name: Setup node.js
|
||||
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
|
||||
with:
|
||||
node-version-file: '.nvmrc'
|
||||
registry-url: 'https://registry.npmjs.org/'
|
||||
|
||||
- name: Download built libraries
|
||||
uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806 # v4.19.1
|
||||
with:
|
||||
pattern: sqlcipher-*
|
||||
path: prebuilds
|
||||
merge-multiple: true
|
||||
|
||||
- name: Install node_modules
|
||||
run: pnpm install --frozen-lockfile
|
||||
|
||||
- name: Build
|
||||
run: pnpm build
|
||||
|
||||
- name: Lint
|
||||
run: pnpm lint
|
||||
|
||||
- run: pnpm test
|
||||
env:
|
||||
PREBUILDS_ONLY: 1
|
||||
|
||||
- name: Publish
|
||||
run: pnpm publish --tag '${{ github.event.inputs.npm_tag }}' --access public --no-git-checks ${{ inputs.dry_run && '--dry-run' || ''}}
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
|
||||
- name: Rename symbols
|
||||
run: |
|
||||
mv prebuilds/darwin-arm64/node_sqlcipher.sym prebuilds/node_sqlcipher_darwin_arm64.sym
|
||||
mv prebuilds/darwin-x64/node_sqlcipher.sym prebuilds/node_sqlcipher_darwin_x64.sym
|
||||
mv prebuilds/linux-arm64/node_sqlcipher.sym prebuilds/node_sqlcipher_linux_arm64.sym
|
||||
mv prebuilds/linux-x64/node_sqlcipher.sym prebuilds/node_sqlcipher_linux_x64.sym
|
||||
mv prebuilds/win32-arm64/node_sqlcipher.sym prebuilds/node_sqlcipher_win32_arm64.sym
|
||||
mv prebuilds/win32-x64/node_sqlcipher.sym prebuilds/node_sqlcipher_win32_x64.sym
|
||||
|
||||
# This step is expected to fail if not run on a tag.
|
||||
- name: Upload debug info to release
|
||||
uses: ncipollo/release-action@440c8c1cb0ed28b9f43e4d1d670870f059653174 # v1.16.0
|
||||
if: ${{ !inputs.dry_run }}
|
||||
with:
|
||||
allowUpdates: true
|
||||
artifactErrorsFailBuild: true
|
||||
artifacts: prebuilds/node_sqlcipher_*.sym
|
||||
75
.github/workflows/test.yaml
vendored
Normal file
75
.github/workflows/test.yaml
vendored
Normal file
@ -0,0 +1,75 @@
|
||||
# Copyright 2025 Signal Messenger, LLC
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
name: Test
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||
include:
|
||||
- os: macos-latest
|
||||
cc: clang
|
||||
cxx: clang++
|
||||
- os: ubuntu-latest
|
||||
cc: gcc
|
||||
cxx: g++
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
timeout-minutes: 30
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
- name: Setup pnpm
|
||||
uses: pnpm/action-setup@a7487c7e89a18df4991f7f222e4898a00d66ddda # v4.1.0
|
||||
with:
|
||||
version: 10.3.0
|
||||
- name: Setup node.js
|
||||
uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4.2.0
|
||||
with:
|
||||
node-version-file: '.nvmrc'
|
||||
cache: 'pnpm'
|
||||
cache-dependency-path: 'pnpm-lock.yaml'
|
||||
|
||||
- name: Setup sccache
|
||||
uses: mozilla-actions/sccache-action@65101d47ea8028ed0c98a1cdea8dd9182e9b5133 # v0.0.8
|
||||
- name: Restore sccache
|
||||
uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
|
||||
with:
|
||||
path: ${{ env.SCCACHE_PATH }}
|
||||
key: sccache-${{ runner.os }}-${{ hashFiles('pnpm-lock.yaml', 'patches/**', 'deps/extension/Cargo.lock') }}
|
||||
|
||||
- name: Restore cargo cache
|
||||
uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4.2.2
|
||||
with:
|
||||
path: ~/.cargo/registry
|
||||
key: cargo-${{ runner.os }}-${{ hashFiles('deps/extension/Cargo.lock') }}
|
||||
|
||||
- name: Install node_modules (unixes)
|
||||
if: ${{ matrix.os == 'macos-latest' || matrix.os == 'ubuntu-latest' }}
|
||||
run: pnpm install
|
||||
env:
|
||||
CC: sccache ${{ matrix.cc }}
|
||||
CXX: sccache ${{ matrix.cxx }}
|
||||
RUSTC_WRAPPER: sccache
|
||||
SCCACHE_GHA_ENABLED: 'true'
|
||||
|
||||
- name: Install node_modules (windows)
|
||||
if: ${{ matrix.os == 'windows-latest' }}
|
||||
run: pnpm install
|
||||
env:
|
||||
RUSTC_WRAPPER: sccache
|
||||
|
||||
- name: Run lint
|
||||
if: matrix.os != 'windows-latest'
|
||||
run: pnpm lint
|
||||
|
||||
- name: Run tests
|
||||
run: pnpm test
|
||||
9
.gitignore
vendored
Normal file
9
.gitignore
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
build/
|
||||
dist/
|
||||
node_modules/
|
||||
coverage/
|
||||
prebuilds/
|
||||
docs/
|
||||
.tmp/
|
||||
.eslintcache
|
||||
todo.md
|
||||
5
.prettierignore
Normal file
5
.prettierignore
Normal file
@ -0,0 +1,5 @@
|
||||
build/
|
||||
deps/sqlcipher/*
|
||||
dist/
|
||||
deps/extension/target
|
||||
pnpm-lock.yaml
|
||||
4
.prettierrc.json
Normal file
4
.prettierrc.json
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"singleQuote": true,
|
||||
"trailingComma": "all"
|
||||
}
|
||||
76
Dockerfile
Normal file
76
Dockerfile
Normal file
@ -0,0 +1,76 @@
|
||||
# Copyright 2022 Signal Messenger, LLC.
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
#
|
||||
|
||||
FROM ubuntu:focal-20240530@sha256:fa17826afb526a9fc7250e0fbcbfd18d03fe7a54849472f86879d8bf562c629e
|
||||
|
||||
# Avoid getting prompted to configure things during installation.
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
# APT source files
|
||||
COPY docker/ docker/
|
||||
COPY docker/apt.conf docker/sources.list /etc/apt/
|
||||
|
||||
# Ubuntu needs the ca-certificates package before it'll trust our mirror.
|
||||
# But we can't install it because it doesn't trust our mirror!
|
||||
# Temporarily disables APT's certificate signature checking
|
||||
# to download the certificates.
|
||||
RUN apt-get update -oAcquire::https::Verify-Peer=false \
|
||||
&& apt-get install -oAcquire::https::Verify-Peer=false -y ca-certificates
|
||||
# Back to normal, verification back on
|
||||
|
||||
# Install only what's needed to set up Rust and Node.
|
||||
# We'll install additional tools at the end to take advantage of Docker's caching of earlier steps.
|
||||
RUN apt-get update && apt-get install -y apt-transport-https xz-utils unzip
|
||||
|
||||
# User-specific setup!
|
||||
|
||||
ARG UID
|
||||
ARG GID
|
||||
|
||||
# Create a user to map the host user to.
|
||||
RUN groupadd -o -g "${GID}" sqlcipher \
|
||||
&& useradd -m -o -u "${UID}" -g "${GID}" -s /bin/bash sqlcipher
|
||||
|
||||
USER sqlcipher
|
||||
ENV HOME=/home/sqlcipher
|
||||
ENV USER=sqlcipher
|
||||
ENV SHELL=/bin/bash
|
||||
ENV CI=on
|
||||
|
||||
WORKDIR /home/sqlcipher
|
||||
|
||||
# Rust setup
|
||||
COPY rust-toolchain rust-toolchain
|
||||
ENV PATH="/home/sqlcipher/.cargo/bin:${PATH}"
|
||||
ARG RUSTUP_SHA=ad1f8b5199b3b9e231472ed7aa08d2e5d1d539198a15c5b1e53c746aad81d27b
|
||||
|
||||
ADD --chown=sqlcipher --chmod=755 --checksum=sha256:${RUSTUP_SHA} \
|
||||
https://static.rust-lang.org/rustup/archive/1.21.1/x86_64-unknown-linux-gnu/rustup-init /tmp/rustup-init
|
||||
|
||||
RUN /tmp/rustup-init -y --profile minimal --default-toolchain "$(cat rust-toolchain)" \
|
||||
&& rm -rf /tmp/rustup-init
|
||||
|
||||
RUN rustup target add aarch64-unknown-linux-gnu
|
||||
|
||||
# Node setup
|
||||
|
||||
ARG NODE_VERSION
|
||||
|
||||
ADD --chown=sqlcipher https://nodejs.org/dist/v${NODE_VERSION}/node-v${NODE_VERSION}-linux-x64.tar.xz node.tar.xz
|
||||
|
||||
RUN tar -xf node.tar.xz \
|
||||
&& mv node-v* node \
|
||||
&& rm -f node.tar.xz
|
||||
|
||||
ENV PATH="/home/sqlcipher/node/bin:${PATH}"
|
||||
|
||||
# And finally any bonus packages we're going to need
|
||||
# Note that we jump back to root for this.
|
||||
USER root
|
||||
RUN apt-get install -y g++ gcc crossbuild-essential-arm64 git python3 binutils
|
||||
USER sqlcipher
|
||||
|
||||
RUN cargo install dump_syms --no-default-features --features cli
|
||||
|
||||
CMD [ "/bin/bash" ]
|
||||
661
LICENSE
Normal file
661
LICENSE
Normal file
@ -0,0 +1,661 @@
|
||||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
Version 3, 19 November 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU Affero General Public License is a free, copyleft license for
|
||||
software and other kinds of works, specifically designed to ensure
|
||||
cooperation with the community in the case of network server software.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
our General Public Licenses are intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
Developers that use our General Public Licenses protect your rights
|
||||
with two steps: (1) assert copyright on the software, and (2) offer
|
||||
you this License which gives you legal permission to copy, distribute
|
||||
and/or modify the software.
|
||||
|
||||
A secondary benefit of defending all users' freedom is that
|
||||
improvements made in alternate versions of the program, if they
|
||||
receive widespread use, become available for other developers to
|
||||
incorporate. Many developers of free software are heartened and
|
||||
encouraged by the resulting cooperation. However, in the case of
|
||||
software used on network servers, this result may fail to come about.
|
||||
The GNU General Public License permits making a modified version and
|
||||
letting the public access it on a server without ever releasing its
|
||||
source code to the public.
|
||||
|
||||
The GNU Affero General Public License is designed specifically to
|
||||
ensure that, in such cases, the modified source code becomes available
|
||||
to the community. It requires the operator of a network server to
|
||||
provide the source code of the modified version running there to the
|
||||
users of that server. Therefore, public use of a modified version, on
|
||||
a publicly accessible server, gives the public access to the source
|
||||
code of the modified version.
|
||||
|
||||
An older license, called the Affero General Public License and
|
||||
published by Affero, was designed to accomplish similar goals. This is
|
||||
a different license, not a version of the Affero GPL, but Affero has
|
||||
released a new version of the Affero GPL which permits relicensing under
|
||||
this license.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, if you modify the
|
||||
Program, your modified version must prominently offer all users
|
||||
interacting with it remotely through a computer network (if your version
|
||||
supports such interaction) an opportunity to receive the Corresponding
|
||||
Source of your version by providing access to the Corresponding Source
|
||||
from a network server at no charge, through some standard or customary
|
||||
means of facilitating copying of software. This Corresponding Source
|
||||
shall include the Corresponding Source for any work covered by version 3
|
||||
of the GNU General Public License that is incorporated pursuant to the
|
||||
following paragraph.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the work with which it is combined will remain governed by version
|
||||
3 of the GNU General Public License.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU Affero General Public License from time to time. Such new versions
|
||||
will be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU Affero General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU Affero General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU Affero General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If your software can interact with users remotely through a computer
|
||||
network, you should also make sure that it provides a way for users to
|
||||
get its source. For example, if your program is a web application, its
|
||||
interface could display a "Source" link that leads users to an archive
|
||||
of the code. There are many ways you could offer source, and different
|
||||
solutions will be better for different programs; see section 13 for the
|
||||
specific requirements.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU AGPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
48
README.md
Normal file
48
README.md
Normal file
@ -0,0 +1,48 @@
|
||||
# @signalapp/sqlcipher
|
||||
|
||||
[](https://www.npmjs.com/package/@signalapp/sqlcipher)
|
||||
|
||||
A fast [N-API](https://github.com/nodejs/node-addon-api)-based Node.js addon
|
||||
wrapping [sqlcipher](https://github.com/sqlcipher/sqlcipher) and Signal-specific
|
||||
[FTS5 segmenting APIs](https://github.com/signalapp/Signal-FTS5-Extension).
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
import Database from '@signalapp/sqlcipher';
|
||||
|
||||
const db = new Database('/path/to/db');
|
||||
|
||||
db.exec(`
|
||||
CREATE TABLE t (
|
||||
a INTEGER,
|
||||
b TEXT,
|
||||
c BLOB
|
||||
);
|
||||
`);
|
||||
|
||||
const insert = db.prepare('INSERT INTO t (a, b, c) VALUES ($a, $b, $c)');
|
||||
insert.run({ a: 1, b: 'hello', c: Buffer.from('world') });
|
||||
insert.run({ a: 2, b: 'world', c: Buffer.from('hello') });
|
||||
|
||||
console.log(db.prepare('SELECT * FROM t').all());
|
||||
```
|
||||
|
||||
## Updating sqlcipher
|
||||
|
||||
On macOS:
|
||||
|
||||
```sh
|
||||
cd deps/sqlcipher
|
||||
export OPENSSL_PREFIX=`brew --prefix openssl`
|
||||
export CFLAGS="-I $OPENSSL_PREFIX/include"
|
||||
export LIBRARY_PATH="$LIBRARY_PATH:$OPENSSL_PREFIX/lib"
|
||||
./update.sh v4.6.1
|
||||
cd -
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
Copyright 2025 Signal Messenger, LLC.
|
||||
|
||||
Licensed under the AGPLv3: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
54
bench/insert-blob.bench.js
Normal file
54
bench/insert-blob.bench.js
Normal file
@ -0,0 +1,54 @@
|
||||
import { Buffer } from 'node:buffer';
|
||||
import { bench, describe } from 'vitest';
|
||||
|
||||
import BDatabase from '@signalapp/better-sqlite3';
|
||||
import Database from '../lib/index.js';
|
||||
|
||||
const PREPARE = `
|
||||
CREATE TABLE t (
|
||||
b BLOB
|
||||
);
|
||||
`;
|
||||
|
||||
const INSERT = `
|
||||
INSERT INTO t (b) VALUES ($b);
|
||||
`;
|
||||
|
||||
const BLOB = Buffer.alloc(16 * 1024);
|
||||
|
||||
const DELETE = 'DELETE FROM t';
|
||||
|
||||
describe('INSERT INTO t', () => {
|
||||
const sdb = new Database(':memory:', { cacheStatements: true });
|
||||
const bdb = new BDatabase(':memory:');
|
||||
|
||||
sdb.exec(PREPARE);
|
||||
bdb.exec(PREPARE);
|
||||
|
||||
const sinsert = sdb.prepare(INSERT);
|
||||
const binsert = bdb.prepare(INSERT);
|
||||
|
||||
bench(
|
||||
'@signalapp/sqlcipher',
|
||||
() => {
|
||||
sinsert.run({ b: BLOB });
|
||||
},
|
||||
{
|
||||
teardown: () => {
|
||||
sdb.exec(DELETE);
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
bench(
|
||||
'@signalapp/better-sqlite',
|
||||
() => {
|
||||
binsert.run({ b: BLOB });
|
||||
},
|
||||
{
|
||||
teardown: () => {
|
||||
bdb.exec(DELETE);
|
||||
},
|
||||
},
|
||||
);
|
||||
});
|
||||
57
bench/insert.bench.js
Normal file
57
bench/insert.bench.js
Normal file
@ -0,0 +1,57 @@
|
||||
import { bench, describe } from 'vitest';
|
||||
|
||||
import BDatabase from '@signalapp/better-sqlite3';
|
||||
import Database from '../lib/index.js';
|
||||
|
||||
const PREPARE = `
|
||||
CREATE TABLE t (
|
||||
a1 INTEGER,
|
||||
a2 INTEGER,
|
||||
a3 INTEGER,
|
||||
b1 TEXT,
|
||||
b2 TEXT,
|
||||
b3 TEXT
|
||||
);
|
||||
`;
|
||||
|
||||
const INSERT = `
|
||||
INSERT INTO t (a1, a2, a3, b1, b2, b3) VALUES
|
||||
($a1, $a2, $a3, $b1, $b2, $b3);
|
||||
`;
|
||||
|
||||
const DELETE = 'DELETE FROM t';
|
||||
|
||||
describe('INSERT INTO t', () => {
|
||||
const sdb = new Database(':memory:', { cacheStatements: true });
|
||||
const bdb = new BDatabase(':memory:');
|
||||
|
||||
sdb.exec(PREPARE);
|
||||
bdb.exec(PREPARE);
|
||||
|
||||
const sinsert = sdb.prepare(INSERT);
|
||||
const binsert = bdb.prepare(INSERT);
|
||||
|
||||
bench(
|
||||
'@signalapp/sqlcipher',
|
||||
() => {
|
||||
sinsert.run({ a1: 1, a2: 2, a3: 3, b1: 'b1', b2: 'b2', b3: 'b3' });
|
||||
},
|
||||
{
|
||||
teardown: () => {
|
||||
sdb.exec(DELETE);
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
bench(
|
||||
'@signalapp/better-sqlite',
|
||||
() => {
|
||||
binsert.run({ a1: 1, a2: 2, a3: 3, b1: 'b1', b2: 'b2', b3: 'b3' });
|
||||
},
|
||||
{
|
||||
teardown: () => {
|
||||
bdb.exec(DELETE);
|
||||
},
|
||||
},
|
||||
);
|
||||
});
|
||||
20
bench/package.json
Normal file
20
bench/package.json
Normal file
@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "bench",
|
||||
"version": "1.0.0",
|
||||
"private": "true",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"bench": "vitest bench"
|
||||
},
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@signalapp/better-sqlite3": "^9.0.13",
|
||||
"vitest": "^3.0.8"
|
||||
},
|
||||
"pnpm": {
|
||||
"onlyBuiltDependencies": [
|
||||
"@signalapp/better-sqlite3",
|
||||
"esbuild"
|
||||
]
|
||||
}
|
||||
}
|
||||
943
bench/pnpm-lock.yaml
generated
Normal file
943
bench/pnpm-lock.yaml
generated
Normal file
@ -0,0 +1,943 @@
|
||||
lockfileVersion: '9.0'
|
||||
|
||||
settings:
|
||||
autoInstallPeers: true
|
||||
excludeLinksFromLockfile: false
|
||||
|
||||
importers:
|
||||
|
||||
.:
|
||||
dependencies:
|
||||
'@signalapp/better-sqlite3':
|
||||
specifier: ^9.0.13
|
||||
version: 9.0.13
|
||||
vitest:
|
||||
specifier: ^3.0.8
|
||||
version: 3.0.8
|
||||
|
||||
packages:
|
||||
|
||||
'@esbuild/aix-ppc64@0.25.0':
|
||||
resolution: {integrity: sha512-O7vun9Sf8DFjH2UtqK8Ku3LkquL9SZL8OLY1T5NZkA34+wG3OQF7cl4Ql8vdNzM6fzBbYfLaiRLIOZ+2FOCgBQ==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [ppc64]
|
||||
os: [aix]
|
||||
|
||||
'@esbuild/android-arm64@0.25.0':
|
||||
resolution: {integrity: sha512-grvv8WncGjDSyUBjN9yHXNt+cq0snxXbDxy5pJtzMKGmmpPxeAmAhWxXI+01lU5rwZomDgD3kJwulEnhTRUd6g==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [arm64]
|
||||
os: [android]
|
||||
|
||||
'@esbuild/android-arm@0.25.0':
|
||||
resolution: {integrity: sha512-PTyWCYYiU0+1eJKmw21lWtC+d08JDZPQ5g+kFyxP0V+es6VPPSUhM6zk8iImp2jbV6GwjX4pap0JFbUQN65X1g==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [arm]
|
||||
os: [android]
|
||||
|
||||
'@esbuild/android-x64@0.25.0':
|
||||
resolution: {integrity: sha512-m/ix7SfKG5buCnxasr52+LI78SQ+wgdENi9CqyCXwjVR2X4Jkz+BpC3le3AoBPYTC9NHklwngVXvbJ9/Akhrfg==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [x64]
|
||||
os: [android]
|
||||
|
||||
'@esbuild/darwin-arm64@0.25.0':
|
||||
resolution: {integrity: sha512-mVwdUb5SRkPayVadIOI78K7aAnPamoeFR2bT5nszFUZ9P8UpK4ratOdYbZZXYSqPKMHfS1wdHCJk1P1EZpRdvw==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [arm64]
|
||||
os: [darwin]
|
||||
|
||||
'@esbuild/darwin-x64@0.25.0':
|
||||
resolution: {integrity: sha512-DgDaYsPWFTS4S3nWpFcMn/33ZZwAAeAFKNHNa1QN0rI4pUjgqf0f7ONmXf6d22tqTY+H9FNdgeaAa+YIFUn2Rg==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [x64]
|
||||
os: [darwin]
|
||||
|
||||
'@esbuild/freebsd-arm64@0.25.0':
|
||||
resolution: {integrity: sha512-VN4ocxy6dxefN1MepBx/iD1dH5K8qNtNe227I0mnTRjry8tj5MRk4zprLEdG8WPyAPb93/e4pSgi1SoHdgOa4w==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [arm64]
|
||||
os: [freebsd]
|
||||
|
||||
'@esbuild/freebsd-x64@0.25.0':
|
||||
resolution: {integrity: sha512-mrSgt7lCh07FY+hDD1TxiTyIHyttn6vnjesnPoVDNmDfOmggTLXRv8Id5fNZey1gl/V2dyVK1VXXqVsQIiAk+A==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [x64]
|
||||
os: [freebsd]
|
||||
|
||||
'@esbuild/linux-arm64@0.25.0':
|
||||
resolution: {integrity: sha512-9QAQjTWNDM/Vk2bgBl17yWuZxZNQIF0OUUuPZRKoDtqF2k4EtYbpyiG5/Dk7nqeK6kIJWPYldkOcBqjXjrUlmg==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
|
||||
'@esbuild/linux-arm@0.25.0':
|
||||
resolution: {integrity: sha512-vkB3IYj2IDo3g9xX7HqhPYxVkNQe8qTK55fraQyTzTX/fxaDtXiEnavv9geOsonh2Fd2RMB+i5cbhu2zMNWJwg==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [arm]
|
||||
os: [linux]
|
||||
|
||||
'@esbuild/linux-ia32@0.25.0':
|
||||
resolution: {integrity: sha512-43ET5bHbphBegyeqLb7I1eYn2P/JYGNmzzdidq/w0T8E2SsYL1U6un2NFROFRg1JZLTzdCoRomg8Rvf9M6W6Gg==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [ia32]
|
||||
os: [linux]
|
||||
|
||||
'@esbuild/linux-loong64@0.25.0':
|
||||
resolution: {integrity: sha512-fC95c/xyNFueMhClxJmeRIj2yrSMdDfmqJnyOY4ZqsALkDrrKJfIg5NTMSzVBr5YW1jf+l7/cndBfP3MSDpoHw==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [loong64]
|
||||
os: [linux]
|
||||
|
||||
'@esbuild/linux-mips64el@0.25.0':
|
||||
resolution: {integrity: sha512-nkAMFju7KDW73T1DdH7glcyIptm95a7Le8irTQNO/qtkoyypZAnjchQgooFUDQhNAy4iu08N79W4T4pMBwhPwQ==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [mips64el]
|
||||
os: [linux]
|
||||
|
||||
'@esbuild/linux-ppc64@0.25.0':
|
||||
resolution: {integrity: sha512-NhyOejdhRGS8Iwv+KKR2zTq2PpysF9XqY+Zk77vQHqNbo/PwZCzB5/h7VGuREZm1fixhs4Q/qWRSi5zmAiO4Fw==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [ppc64]
|
||||
os: [linux]
|
||||
|
||||
'@esbuild/linux-riscv64@0.25.0':
|
||||
resolution: {integrity: sha512-5S/rbP5OY+GHLC5qXp1y/Mx//e92L1YDqkiBbO9TQOvuFXM+iDqUNG5XopAnXoRH3FjIUDkeGcY1cgNvnXp/kA==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [riscv64]
|
||||
os: [linux]
|
||||
|
||||
'@esbuild/linux-s390x@0.25.0':
|
||||
resolution: {integrity: sha512-XM2BFsEBz0Fw37V0zU4CXfcfuACMrppsMFKdYY2WuTS3yi8O1nFOhil/xhKTmE1nPmVyvQJjJivgDT+xh8pXJA==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [s390x]
|
||||
os: [linux]
|
||||
|
||||
'@esbuild/linux-x64@0.25.0':
|
||||
resolution: {integrity: sha512-9yl91rHw/cpwMCNytUDxwj2XjFpxML0y9HAOH9pNVQDpQrBxHy01Dx+vaMu0N1CKa/RzBD2hB4u//nfc+Sd3Cw==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
|
||||
'@esbuild/netbsd-arm64@0.25.0':
|
||||
resolution: {integrity: sha512-RuG4PSMPFfrkH6UwCAqBzauBWTygTvb1nxWasEJooGSJ/NwRw7b2HOwyRTQIU97Hq37l3npXoZGYMy3b3xYvPw==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [arm64]
|
||||
os: [netbsd]
|
||||
|
||||
'@esbuild/netbsd-x64@0.25.0':
|
||||
resolution: {integrity: sha512-jl+qisSB5jk01N5f7sPCsBENCOlPiS/xptD5yxOx2oqQfyourJwIKLRA2yqWdifj3owQZCL2sn6o08dBzZGQzA==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [x64]
|
||||
os: [netbsd]
|
||||
|
||||
'@esbuild/openbsd-arm64@0.25.0':
|
||||
resolution: {integrity: sha512-21sUNbq2r84YE+SJDfaQRvdgznTD8Xc0oc3p3iW/a1EVWeNj/SdUCbm5U0itZPQYRuRTW20fPMWMpcrciH2EJw==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [arm64]
|
||||
os: [openbsd]
|
||||
|
||||
'@esbuild/openbsd-x64@0.25.0':
|
||||
resolution: {integrity: sha512-2gwwriSMPcCFRlPlKx3zLQhfN/2WjJ2NSlg5TKLQOJdV0mSxIcYNTMhk3H3ulL/cak+Xj0lY1Ym9ysDV1igceg==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [x64]
|
||||
os: [openbsd]
|
||||
|
||||
'@esbuild/sunos-x64@0.25.0':
|
||||
resolution: {integrity: sha512-bxI7ThgLzPrPz484/S9jLlvUAHYMzy6I0XiU1ZMeAEOBcS0VePBFxh1JjTQt3Xiat5b6Oh4x7UC7IwKQKIJRIg==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [x64]
|
||||
os: [sunos]
|
||||
|
||||
'@esbuild/win32-arm64@0.25.0':
|
||||
resolution: {integrity: sha512-ZUAc2YK6JW89xTbXvftxdnYy3m4iHIkDtK3CLce8wg8M2L+YZhIvO1DKpxrd0Yr59AeNNkTiic9YLf6FTtXWMw==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [arm64]
|
||||
os: [win32]
|
||||
|
||||
'@esbuild/win32-ia32@0.25.0':
|
||||
resolution: {integrity: sha512-eSNxISBu8XweVEWG31/JzjkIGbGIJN/TrRoiSVZwZ6pkC6VX4Im/WV2cz559/TXLcYbcrDN8JtKgd9DJVIo8GA==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [ia32]
|
||||
os: [win32]
|
||||
|
||||
'@esbuild/win32-x64@0.25.0':
|
||||
resolution: {integrity: sha512-ZENoHJBxA20C2zFzh6AI4fT6RraMzjYw4xKWemRTRmRVtN9c5DcH9r/f2ihEkMjOW5eGgrwCslG/+Y/3bL+DHQ==}
|
||||
engines: {node: '>=18'}
|
||||
cpu: [x64]
|
||||
os: [win32]
|
||||
|
||||
'@jridgewell/sourcemap-codec@1.5.0':
|
||||
resolution: {integrity: sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==}
|
||||
|
||||
'@rollup/rollup-android-arm-eabi@4.34.9':
|
||||
resolution: {integrity: sha512-qZdlImWXur0CFakn2BJ2znJOdqYZKiedEPEVNTBrpfPjc/YuTGcaYZcdmNFTkUj3DU0ZM/AElcM8Ybww3xVLzA==}
|
||||
cpu: [arm]
|
||||
os: [android]
|
||||
|
||||
'@rollup/rollup-android-arm64@4.34.9':
|
||||
resolution: {integrity: sha512-4KW7P53h6HtJf5Y608T1ISKvNIYLWRKMvfnG0c44M6In4DQVU58HZFEVhWINDZKp7FZps98G3gxwC1sb0wXUUg==}
|
||||
cpu: [arm64]
|
||||
os: [android]
|
||||
|
||||
'@rollup/rollup-darwin-arm64@4.34.9':
|
||||
resolution: {integrity: sha512-0CY3/K54slrzLDjOA7TOjN1NuLKERBgk9nY5V34mhmuu673YNb+7ghaDUs6N0ujXR7fz5XaS5Aa6d2TNxZd0OQ==}
|
||||
cpu: [arm64]
|
||||
os: [darwin]
|
||||
|
||||
'@rollup/rollup-darwin-x64@4.34.9':
|
||||
resolution: {integrity: sha512-eOojSEAi/acnsJVYRxnMkPFqcxSMFfrw7r2iD9Q32SGkb/Q9FpUY1UlAu1DH9T7j++gZ0lHjnm4OyH2vCI7l7Q==}
|
||||
cpu: [x64]
|
||||
os: [darwin]
|
||||
|
||||
'@rollup/rollup-freebsd-arm64@4.34.9':
|
||||
resolution: {integrity: sha512-2lzjQPJbN5UnHm7bHIUKFMulGTQwdvOkouJDpPysJS+QFBGDJqcfh+CxxtG23Ik/9tEvnebQiylYoazFMAgrYw==}
|
||||
cpu: [arm64]
|
||||
os: [freebsd]
|
||||
|
||||
'@rollup/rollup-freebsd-x64@4.34.9':
|
||||
resolution: {integrity: sha512-SLl0hi2Ah2H7xQYd6Qaiu01kFPzQ+hqvdYSoOtHYg/zCIFs6t8sV95kaoqjzjFwuYQLtOI0RZre/Ke0nPaQV+g==}
|
||||
cpu: [x64]
|
||||
os: [freebsd]
|
||||
|
||||
'@rollup/rollup-linux-arm-gnueabihf@4.34.9':
|
||||
resolution: {integrity: sha512-88I+D3TeKItrw+Y/2ud4Tw0+3CxQ2kLgu3QvrogZ0OfkmX/DEppehus7L3TS2Q4lpB+hYyxhkQiYPJ6Mf5/dPg==}
|
||||
cpu: [arm]
|
||||
os: [linux]
|
||||
|
||||
'@rollup/rollup-linux-arm-musleabihf@4.34.9':
|
||||
resolution: {integrity: sha512-3qyfWljSFHi9zH0KgtEPG4cBXHDFhwD8kwg6xLfHQ0IWuH9crp005GfoUUh/6w9/FWGBwEHg3lxK1iHRN1MFlA==}
|
||||
cpu: [arm]
|
||||
os: [linux]
|
||||
|
||||
'@rollup/rollup-linux-arm64-gnu@4.34.9':
|
||||
resolution: {integrity: sha512-6TZjPHjKZUQKmVKMUowF3ewHxctrRR09eYyvT5eFv8w/fXarEra83A2mHTVJLA5xU91aCNOUnM+DWFMSbQ0Nxw==}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
|
||||
'@rollup/rollup-linux-arm64-musl@4.34.9':
|
||||
resolution: {integrity: sha512-LD2fytxZJZ6xzOKnMbIpgzFOuIKlxVOpiMAXawsAZ2mHBPEYOnLRK5TTEsID6z4eM23DuO88X0Tq1mErHMVq0A==}
|
||||
cpu: [arm64]
|
||||
os: [linux]
|
||||
|
||||
'@rollup/rollup-linux-loongarch64-gnu@4.34.9':
|
||||
resolution: {integrity: sha512-dRAgTfDsn0TE0HI6cmo13hemKpVHOEyeciGtvlBTkpx/F65kTvShtY/EVyZEIfxFkV5JJTuQ9tP5HGBS0hfxIg==}
|
||||
cpu: [loong64]
|
||||
os: [linux]
|
||||
|
||||
'@rollup/rollup-linux-powerpc64le-gnu@4.34.9':
|
||||
resolution: {integrity: sha512-PHcNOAEhkoMSQtMf+rJofwisZqaU8iQ8EaSps58f5HYll9EAY5BSErCZ8qBDMVbq88h4UxaNPlbrKqfWP8RfJA==}
|
||||
cpu: [ppc64]
|
||||
os: [linux]
|
||||
|
||||
'@rollup/rollup-linux-riscv64-gnu@4.34.9':
|
||||
resolution: {integrity: sha512-Z2i0Uy5G96KBYKjeQFKbbsB54xFOL5/y1P5wNBsbXB8yE+At3oh0DVMjQVzCJRJSfReiB2tX8T6HUFZ2k8iaKg==}
|
||||
cpu: [riscv64]
|
||||
os: [linux]
|
||||
|
||||
'@rollup/rollup-linux-s390x-gnu@4.34.9':
|
||||
resolution: {integrity: sha512-U+5SwTMoeYXoDzJX5dhDTxRltSrIax8KWwfaaYcynuJw8mT33W7oOgz0a+AaXtGuvhzTr2tVKh5UO8GVANTxyQ==}
|
||||
cpu: [s390x]
|
||||
os: [linux]
|
||||
|
||||
'@rollup/rollup-linux-x64-gnu@4.34.9':
|
||||
resolution: {integrity: sha512-FwBHNSOjUTQLP4MG7y6rR6qbGw4MFeQnIBrMe161QGaQoBQLqSUEKlHIiVgF3g/mb3lxlxzJOpIBhaP+C+KP2A==}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
|
||||
'@rollup/rollup-linux-x64-musl@4.34.9':
|
||||
resolution: {integrity: sha512-cYRpV4650z2I3/s6+5/LONkjIz8MBeqrk+vPXV10ORBnshpn8S32bPqQ2Utv39jCiDcO2eJTuSlPXpnvmaIgRA==}
|
||||
cpu: [x64]
|
||||
os: [linux]
|
||||
|
||||
'@rollup/rollup-win32-arm64-msvc@4.34.9':
|
||||
resolution: {integrity: sha512-z4mQK9dAN6byRA/vsSgQiPeuO63wdiDxZ9yg9iyX2QTzKuQM7T4xlBoeUP/J8uiFkqxkcWndWi+W7bXdPbt27Q==}
|
||||
cpu: [arm64]
|
||||
os: [win32]
|
||||
|
||||
'@rollup/rollup-win32-ia32-msvc@4.34.9':
|
||||
resolution: {integrity: sha512-KB48mPtaoHy1AwDNkAJfHXvHp24H0ryZog28spEs0V48l3H1fr4i37tiyHsgKZJnCmvxsbATdZGBpbmxTE3a9w==}
|
||||
cpu: [ia32]
|
||||
os: [win32]
|
||||
|
||||
'@rollup/rollup-win32-x64-msvc@4.34.9':
|
||||
resolution: {integrity: sha512-AyleYRPU7+rgkMWbEh71fQlrzRfeP6SyMnRf9XX4fCdDPAJumdSBqYEcWPMzVQ4ScAl7E4oFfK0GUVn77xSwbw==}
|
||||
cpu: [x64]
|
||||
os: [win32]
|
||||
|
||||
'@signalapp/better-sqlite3@9.0.13':
|
||||
resolution: {integrity: sha512-sl5JJvHz/mGy3JXXcWFq7PxeO/d9SaCjPq/FPc4RCujaTC9JofHLdxQjn2xSSZQBLm28o2as3p6hD9eDk+BVNw==}
|
||||
|
||||
'@types/estree@1.0.6':
|
||||
resolution: {integrity: sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw==}
|
||||
|
||||
'@vitest/expect@3.0.8':
|
||||
resolution: {integrity: sha512-Xu6TTIavTvSSS6LZaA3EebWFr6tsoXPetOWNMOlc7LO88QVVBwq2oQWBoDiLCN6YTvNYsGSjqOO8CAdjom5DCQ==}
|
||||
|
||||
'@vitest/mocker@3.0.8':
|
||||
resolution: {integrity: sha512-n3LjS7fcW1BCoF+zWZxG7/5XvuYH+lsFg+BDwwAz0arIwHQJFUEsKBQ0BLU49fCxuM/2HSeBPHQD8WjgrxMfow==}
|
||||
peerDependencies:
|
||||
msw: ^2.4.9
|
||||
vite: ^5.0.0 || ^6.0.0
|
||||
peerDependenciesMeta:
|
||||
msw:
|
||||
optional: true
|
||||
vite:
|
||||
optional: true
|
||||
|
||||
'@vitest/pretty-format@3.0.8':
|
||||
resolution: {integrity: sha512-BNqwbEyitFhzYMYHUVbIvepOyeQOSFA/NeJMIP9enMntkkxLgOcgABH6fjyXG85ipTgvero6noreavGIqfJcIg==}
|
||||
|
||||
'@vitest/runner@3.0.8':
|
||||
resolution: {integrity: sha512-c7UUw6gEcOzI8fih+uaAXS5DwjlBaCJUo7KJ4VvJcjL95+DSR1kova2hFuRt3w41KZEFcOEiq098KkyrjXeM5w==}
|
||||
|
||||
'@vitest/snapshot@3.0.8':
|
||||
resolution: {integrity: sha512-x8IlMGSEMugakInj44nUrLSILh/zy1f2/BgH0UeHpNyOocG18M9CWVIFBaXPt8TrqVZWmcPjwfG/ht5tnpba8A==}
|
||||
|
||||
'@vitest/spy@3.0.8':
|
||||
resolution: {integrity: sha512-MR+PzJa+22vFKYb934CejhR4BeRpMSoxkvNoDit68GQxRLSf11aT6CTj3XaqUU9rxgWJFnqicN/wxw6yBRkI1Q==}
|
||||
|
||||
'@vitest/utils@3.0.8':
|
||||
resolution: {integrity: sha512-nkBC3aEhfX2PdtQI/QwAWp8qZWwzASsU4Npbcd5RdMPBSSLCpkZp52P3xku3s3uA0HIEhGvEcF8rNkBsz9dQ4Q==}
|
||||
|
||||
assertion-error@2.0.1:
|
||||
resolution: {integrity: sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==}
|
||||
engines: {node: '>=12'}
|
||||
|
||||
bindings@1.5.0:
|
||||
resolution: {integrity: sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==}
|
||||
|
||||
cac@6.7.14:
|
||||
resolution: {integrity: sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==}
|
||||
engines: {node: '>=8'}
|
||||
|
||||
chai@5.2.0:
|
||||
resolution: {integrity: sha512-mCuXncKXk5iCLhfhwTc0izo0gtEmpz5CtG2y8GiOINBlMVS6v8TMRc5TaLWKS6692m9+dVVfzgeVxR5UxWHTYw==}
|
||||
engines: {node: '>=12'}
|
||||
|
||||
check-error@2.1.1:
|
||||
resolution: {integrity: sha512-OAlb+T7V4Op9OwdkjmguYRqncdlx5JiofwOAUkmTF+jNdHwzTaTs4sRAGpzLF3oOz5xAyDGrPgeIDFQmDOTiJw==}
|
||||
engines: {node: '>= 16'}
|
||||
|
||||
chownr@2.0.0:
|
||||
resolution: {integrity: sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==}
|
||||
engines: {node: '>=10'}
|
||||
|
||||
debug@4.4.0:
|
||||
resolution: {integrity: sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==}
|
||||
engines: {node: '>=6.0'}
|
||||
peerDependencies:
|
||||
supports-color: '*'
|
||||
peerDependenciesMeta:
|
||||
supports-color:
|
||||
optional: true
|
||||
|
||||
deep-eql@5.0.2:
|
||||
resolution: {integrity: sha512-h5k/5U50IJJFpzfL6nO9jaaumfjO/f2NjK/oYB2Djzm4p9L+3T9qWpZqZ2hAbLPuuYq9wrU08WQyBTL5GbPk5Q==}
|
||||
engines: {node: '>=6'}
|
||||
|
||||
es-module-lexer@1.6.0:
|
||||
resolution: {integrity: sha512-qqnD1yMU6tk/jnaMosogGySTZP8YtUgAffA9nMN+E/rjxcfRQ6IEk7IiozUjgxKoFHBGjTLnrHB/YC45r/59EQ==}
|
||||
|
||||
esbuild@0.25.0:
|
||||
resolution: {integrity: sha512-BXq5mqc8ltbaN34cDqWuYKyNhX8D/Z0J1xdtdQ8UcIIIyJyz+ZMKUt58tF3SrZ85jcfN/PZYhjR5uDQAYNVbuw==}
|
||||
engines: {node: '>=18'}
|
||||
hasBin: true
|
||||
|
||||
estree-walker@3.0.3:
|
||||
resolution: {integrity: sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==}
|
||||
|
||||
expect-type@1.2.0:
|
||||
resolution: {integrity: sha512-80F22aiJ3GLyVnS/B3HzgR6RelZVumzj9jkL0Rhz4h0xYbNW9PjlQz5h3J/SShErbXBc295vseR4/MIbVmUbeA==}
|
||||
engines: {node: '>=12.0.0'}
|
||||
|
||||
file-uri-to-path@1.0.0:
|
||||
resolution: {integrity: sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==}
|
||||
|
||||
fs-minipass@2.1.0:
|
||||
resolution: {integrity: sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg==}
|
||||
engines: {node: '>= 8'}
|
||||
|
||||
fsevents@2.3.3:
|
||||
resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==}
|
||||
engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0}
|
||||
os: [darwin]
|
||||
|
||||
loupe@3.1.3:
|
||||
resolution: {integrity: sha512-kkIp7XSkP78ZxJEsSxW3712C6teJVoeHHwgo9zJ380de7IYyJ2ISlxojcH2pC5OFLewESmnRi/+XCDIEEVyoug==}
|
||||
|
||||
magic-string@0.30.17:
|
||||
resolution: {integrity: sha512-sNPKHvyjVf7gyjwS4xGTaW/mCnF8wnjtifKBEhxfZ7E/S8tQ0rssrwGNn6q8JH/ohItJfSQp9mBtQYuTlH5QnA==}
|
||||
|
||||
minipass@3.3.6:
|
||||
resolution: {integrity: sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==}
|
||||
engines: {node: '>=8'}
|
||||
|
||||
minipass@5.0.0:
|
||||
resolution: {integrity: sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ==}
|
||||
engines: {node: '>=8'}
|
||||
|
||||
minizlib@2.1.2:
|
||||
resolution: {integrity: sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg==}
|
||||
engines: {node: '>= 8'}
|
||||
|
||||
mkdirp@1.0.4:
|
||||
resolution: {integrity: sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==}
|
||||
engines: {node: '>=10'}
|
||||
hasBin: true
|
||||
|
||||
ms@2.1.3:
|
||||
resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==}
|
||||
|
||||
nanoid@3.3.9:
|
||||
resolution: {integrity: sha512-SppoicMGpZvbF1l3z4x7No3OlIjP7QJvC9XR7AhZr1kL133KHnKPztkKDc+Ir4aJ/1VhTySrtKhrsycmrMQfvg==}
|
||||
engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1}
|
||||
hasBin: true
|
||||
|
||||
pathe@2.0.3:
|
||||
resolution: {integrity: sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==}
|
||||
|
||||
pathval@2.0.0:
|
||||
resolution: {integrity: sha512-vE7JKRyES09KiunauX7nd2Q9/L7lhok4smP9RZTDeD4MVs72Dp2qNFVz39Nz5a0FVEW0BJR6C0DYrq6unoziZA==}
|
||||
engines: {node: '>= 14.16'}
|
||||
|
||||
picocolors@1.1.1:
|
||||
resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==}
|
||||
|
||||
postcss@8.5.3:
|
||||
resolution: {integrity: sha512-dle9A3yYxlBSrt8Fu+IpjGT8SY8hN0mlaA6GY8t0P5PjIOZemULz/E2Bnm/2dcUOena75OTNkHI76uZBNUUq3A==}
|
||||
engines: {node: ^10 || ^12 || >=14}
|
||||
|
||||
rollup@4.34.9:
|
||||
resolution: {integrity: sha512-nF5XYqWWp9hx/LrpC8sZvvvmq0TeTjQgaZHYmAgwysT9nh8sWnZhBnM8ZyVbbJFIQBLwHDNoMqsBZBbUo4U8sQ==}
|
||||
engines: {node: '>=18.0.0', npm: '>=8.0.0'}
|
||||
hasBin: true
|
||||
|
||||
siginfo@2.0.0:
|
||||
resolution: {integrity: sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==}
|
||||
|
||||
source-map-js@1.2.1:
|
||||
resolution: {integrity: sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==}
|
||||
engines: {node: '>=0.10.0'}
|
||||
|
||||
stackback@0.0.2:
|
||||
resolution: {integrity: sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==}
|
||||
|
||||
std-env@3.8.1:
|
||||
resolution: {integrity: sha512-vj5lIj3Mwf9D79hBkltk5qmkFI+biIKWS2IBxEyEU3AX1tUf7AoL8nSazCOiiqQsGKIq01SClsKEzweu34uwvA==}
|
||||
|
||||
tar@6.2.1:
|
||||
resolution: {integrity: sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A==}
|
||||
engines: {node: '>=10'}
|
||||
|
||||
tinybench@2.9.0:
|
||||
resolution: {integrity: sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg==}
|
||||
|
||||
tinyexec@0.3.2:
|
||||
resolution: {integrity: sha512-KQQR9yN7R5+OSwaK0XQoj22pwHoTlgYqmUscPYoknOoWCWfj/5/ABTMRi69FrKU5ffPVh5QcFikpWJI/P1ocHA==}
|
||||
|
||||
tinypool@1.0.2:
|
||||
resolution: {integrity: sha512-al6n+QEANGFOMf/dmUMsuS5/r9B06uwlyNjZZql/zv8J7ybHCgoihBNORZCY2mzUuAnomQa2JdhyHKzZxPCrFA==}
|
||||
engines: {node: ^18.0.0 || >=20.0.0}
|
||||
|
||||
tinyrainbow@2.0.0:
|
||||
resolution: {integrity: sha512-op4nsTR47R6p0vMUUoYl/a+ljLFVtlfaXkLQmqfLR1qHma1h/ysYk4hEXZ880bf2CYgTskvTa/e196Vd5dDQXw==}
|
||||
engines: {node: '>=14.0.0'}
|
||||
|
||||
tinyspy@3.0.2:
|
||||
resolution: {integrity: sha512-n1cw8k1k0x4pgA2+9XrOkFydTerNcJ1zWCO5Nn9scWHTD+5tp8dghT2x1uduQePZTZgd3Tupf+x9BxJjeJi77Q==}
|
||||
engines: {node: '>=14.0.0'}
|
||||
|
||||
vite-node@3.0.8:
|
||||
resolution: {integrity: sha512-6PhR4H9VGlcwXZ+KWCdMqbtG649xCPZqfI9j2PsK1FcXgEzro5bGHcVKFCTqPLaNKZES8Evqv4LwvZARsq5qlg==}
|
||||
engines: {node: ^18.0.0 || ^20.0.0 || >=22.0.0}
|
||||
hasBin: true
|
||||
|
||||
vite@6.2.1:
|
||||
resolution: {integrity: sha512-n2GnqDb6XPhlt9B8olZPrgMD/es/Nd1RdChF6CBD/fHW6pUyUTt2sQW2fPRX5GiD9XEa6+8A6A4f2vT6pSsE7Q==}
|
||||
engines: {node: ^18.0.0 || ^20.0.0 || >=22.0.0}
|
||||
hasBin: true
|
||||
peerDependencies:
|
||||
'@types/node': ^18.0.0 || ^20.0.0 || >=22.0.0
|
||||
jiti: '>=1.21.0'
|
||||
less: '*'
|
||||
lightningcss: ^1.21.0
|
||||
sass: '*'
|
||||
sass-embedded: '*'
|
||||
stylus: '*'
|
||||
sugarss: '*'
|
||||
terser: ^5.16.0
|
||||
tsx: ^4.8.1
|
||||
yaml: ^2.4.2
|
||||
peerDependenciesMeta:
|
||||
'@types/node':
|
||||
optional: true
|
||||
jiti:
|
||||
optional: true
|
||||
less:
|
||||
optional: true
|
||||
lightningcss:
|
||||
optional: true
|
||||
sass:
|
||||
optional: true
|
||||
sass-embedded:
|
||||
optional: true
|
||||
stylus:
|
||||
optional: true
|
||||
sugarss:
|
||||
optional: true
|
||||
terser:
|
||||
optional: true
|
||||
tsx:
|
||||
optional: true
|
||||
yaml:
|
||||
optional: true
|
||||
|
||||
vitest@3.0.8:
|
||||
resolution: {integrity: sha512-dfqAsNqRGUc8hB9OVR2P0w8PZPEckti2+5rdZip0WIz9WW0MnImJ8XiR61QhqLa92EQzKP2uPkzenKOAHyEIbA==}
|
||||
engines: {node: ^18.0.0 || ^20.0.0 || >=22.0.0}
|
||||
hasBin: true
|
||||
peerDependencies:
|
||||
'@edge-runtime/vm': '*'
|
||||
'@types/debug': ^4.1.12
|
||||
'@types/node': ^18.0.0 || ^20.0.0 || >=22.0.0
|
||||
'@vitest/browser': 3.0.8
|
||||
'@vitest/ui': 3.0.8
|
||||
happy-dom: '*'
|
||||
jsdom: '*'
|
||||
peerDependenciesMeta:
|
||||
'@edge-runtime/vm':
|
||||
optional: true
|
||||
'@types/debug':
|
||||
optional: true
|
||||
'@types/node':
|
||||
optional: true
|
||||
'@vitest/browser':
|
||||
optional: true
|
||||
'@vitest/ui':
|
||||
optional: true
|
||||
happy-dom:
|
||||
optional: true
|
||||
jsdom:
|
||||
optional: true
|
||||
|
||||
why-is-node-running@2.3.0:
|
||||
resolution: {integrity: sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w==}
|
||||
engines: {node: '>=8'}
|
||||
hasBin: true
|
||||
|
||||
yallist@4.0.0:
|
||||
resolution: {integrity: sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==}
|
||||
|
||||
snapshots:
|
||||
|
||||
'@esbuild/aix-ppc64@0.25.0':
|
||||
optional: true
|
||||
|
||||
'@esbuild/android-arm64@0.25.0':
|
||||
optional: true
|
||||
|
||||
'@esbuild/android-arm@0.25.0':
|
||||
optional: true
|
||||
|
||||
'@esbuild/android-x64@0.25.0':
|
||||
optional: true
|
||||
|
||||
'@esbuild/darwin-arm64@0.25.0':
|
||||
optional: true
|
||||
|
||||
'@esbuild/darwin-x64@0.25.0':
|
||||
optional: true
|
||||
|
||||
'@esbuild/freebsd-arm64@0.25.0':
|
||||
optional: true
|
||||
|
||||
'@esbuild/freebsd-x64@0.25.0':
|
||||
optional: true
|
||||
|
||||
'@esbuild/linux-arm64@0.25.0':
|
||||
optional: true
|
||||
|
||||
'@esbuild/linux-arm@0.25.0':
|
||||
optional: true
|
||||
|
||||
'@esbuild/linux-ia32@0.25.0':
|
||||
optional: true
|
||||
|
||||
'@esbuild/linux-loong64@0.25.0':
|
||||
optional: true
|
||||
|
||||
'@esbuild/linux-mips64el@0.25.0':
|
||||
optional: true
|
||||
|
||||
'@esbuild/linux-ppc64@0.25.0':
|
||||
optional: true
|
||||
|
||||
'@esbuild/linux-riscv64@0.25.0':
|
||||
optional: true
|
||||
|
||||
'@esbuild/linux-s390x@0.25.0':
|
||||
optional: true
|
||||
|
||||
'@esbuild/linux-x64@0.25.0':
|
||||
optional: true
|
||||
|
||||
'@esbuild/netbsd-arm64@0.25.0':
|
||||
optional: true
|
||||
|
||||
'@esbuild/netbsd-x64@0.25.0':
|
||||
optional: true
|
||||
|
||||
'@esbuild/openbsd-arm64@0.25.0':
|
||||
optional: true
|
||||
|
||||
'@esbuild/openbsd-x64@0.25.0':
|
||||
optional: true
|
||||
|
||||
'@esbuild/sunos-x64@0.25.0':
|
||||
optional: true
|
||||
|
||||
'@esbuild/win32-arm64@0.25.0':
|
||||
optional: true
|
||||
|
||||
'@esbuild/win32-ia32@0.25.0':
|
||||
optional: true
|
||||
|
||||
'@esbuild/win32-x64@0.25.0':
|
||||
optional: true
|
||||
|
||||
'@jridgewell/sourcemap-codec@1.5.0': {}
|
||||
|
||||
'@rollup/rollup-android-arm-eabi@4.34.9':
|
||||
optional: true
|
||||
|
||||
'@rollup/rollup-android-arm64@4.34.9':
|
||||
optional: true
|
||||
|
||||
'@rollup/rollup-darwin-arm64@4.34.9':
|
||||
optional: true
|
||||
|
||||
'@rollup/rollup-darwin-x64@4.34.9':
|
||||
optional: true
|
||||
|
||||
'@rollup/rollup-freebsd-arm64@4.34.9':
|
||||
optional: true
|
||||
|
||||
'@rollup/rollup-freebsd-x64@4.34.9':
|
||||
optional: true
|
||||
|
||||
'@rollup/rollup-linux-arm-gnueabihf@4.34.9':
|
||||
optional: true
|
||||
|
||||
'@rollup/rollup-linux-arm-musleabihf@4.34.9':
|
||||
optional: true
|
||||
|
||||
'@rollup/rollup-linux-arm64-gnu@4.34.9':
|
||||
optional: true
|
||||
|
||||
'@rollup/rollup-linux-arm64-musl@4.34.9':
|
||||
optional: true
|
||||
|
||||
'@rollup/rollup-linux-loongarch64-gnu@4.34.9':
|
||||
optional: true
|
||||
|
||||
'@rollup/rollup-linux-powerpc64le-gnu@4.34.9':
|
||||
optional: true
|
||||
|
||||
'@rollup/rollup-linux-riscv64-gnu@4.34.9':
|
||||
optional: true
|
||||
|
||||
'@rollup/rollup-linux-s390x-gnu@4.34.9':
|
||||
optional: true
|
||||
|
||||
'@rollup/rollup-linux-x64-gnu@4.34.9':
|
||||
optional: true
|
||||
|
||||
'@rollup/rollup-linux-x64-musl@4.34.9':
|
||||
optional: true
|
||||
|
||||
'@rollup/rollup-win32-arm64-msvc@4.34.9':
|
||||
optional: true
|
||||
|
||||
'@rollup/rollup-win32-ia32-msvc@4.34.9':
|
||||
optional: true
|
||||
|
||||
'@rollup/rollup-win32-x64-msvc@4.34.9':
|
||||
optional: true
|
||||
|
||||
'@signalapp/better-sqlite3@9.0.13':
|
||||
dependencies:
|
||||
bindings: 1.5.0
|
||||
tar: 6.2.1
|
||||
|
||||
'@types/estree@1.0.6': {}
|
||||
|
||||
'@vitest/expect@3.0.8':
|
||||
dependencies:
|
||||
'@vitest/spy': 3.0.8
|
||||
'@vitest/utils': 3.0.8
|
||||
chai: 5.2.0
|
||||
tinyrainbow: 2.0.0
|
||||
|
||||
'@vitest/mocker@3.0.8(vite@6.2.1)':
|
||||
dependencies:
|
||||
'@vitest/spy': 3.0.8
|
||||
estree-walker: 3.0.3
|
||||
magic-string: 0.30.17
|
||||
optionalDependencies:
|
||||
vite: 6.2.1
|
||||
|
||||
'@vitest/pretty-format@3.0.8':
|
||||
dependencies:
|
||||
tinyrainbow: 2.0.0
|
||||
|
||||
'@vitest/runner@3.0.8':
|
||||
dependencies:
|
||||
'@vitest/utils': 3.0.8
|
||||
pathe: 2.0.3
|
||||
|
||||
'@vitest/snapshot@3.0.8':
|
||||
dependencies:
|
||||
'@vitest/pretty-format': 3.0.8
|
||||
magic-string: 0.30.17
|
||||
pathe: 2.0.3
|
||||
|
||||
'@vitest/spy@3.0.8':
|
||||
dependencies:
|
||||
tinyspy: 3.0.2
|
||||
|
||||
'@vitest/utils@3.0.8':
|
||||
dependencies:
|
||||
'@vitest/pretty-format': 3.0.8
|
||||
loupe: 3.1.3
|
||||
tinyrainbow: 2.0.0
|
||||
|
||||
assertion-error@2.0.1: {}
|
||||
|
||||
bindings@1.5.0:
|
||||
dependencies:
|
||||
file-uri-to-path: 1.0.0
|
||||
|
||||
cac@6.7.14: {}
|
||||
|
||||
chai@5.2.0:
|
||||
dependencies:
|
||||
assertion-error: 2.0.1
|
||||
check-error: 2.1.1
|
||||
deep-eql: 5.0.2
|
||||
loupe: 3.1.3
|
||||
pathval: 2.0.0
|
||||
|
||||
check-error@2.1.1: {}
|
||||
|
||||
chownr@2.0.0: {}
|
||||
|
||||
debug@4.4.0:
|
||||
dependencies:
|
||||
ms: 2.1.3
|
||||
|
||||
deep-eql@5.0.2: {}
|
||||
|
||||
es-module-lexer@1.6.0: {}
|
||||
|
||||
esbuild@0.25.0:
|
||||
optionalDependencies:
|
||||
'@esbuild/aix-ppc64': 0.25.0
|
||||
'@esbuild/android-arm': 0.25.0
|
||||
'@esbuild/android-arm64': 0.25.0
|
||||
'@esbuild/android-x64': 0.25.0
|
||||
'@esbuild/darwin-arm64': 0.25.0
|
||||
'@esbuild/darwin-x64': 0.25.0
|
||||
'@esbuild/freebsd-arm64': 0.25.0
|
||||
'@esbuild/freebsd-x64': 0.25.0
|
||||
'@esbuild/linux-arm': 0.25.0
|
||||
'@esbuild/linux-arm64': 0.25.0
|
||||
'@esbuild/linux-ia32': 0.25.0
|
||||
'@esbuild/linux-loong64': 0.25.0
|
||||
'@esbuild/linux-mips64el': 0.25.0
|
||||
'@esbuild/linux-ppc64': 0.25.0
|
||||
'@esbuild/linux-riscv64': 0.25.0
|
||||
'@esbuild/linux-s390x': 0.25.0
|
||||
'@esbuild/linux-x64': 0.25.0
|
||||
'@esbuild/netbsd-arm64': 0.25.0
|
||||
'@esbuild/netbsd-x64': 0.25.0
|
||||
'@esbuild/openbsd-arm64': 0.25.0
|
||||
'@esbuild/openbsd-x64': 0.25.0
|
||||
'@esbuild/sunos-x64': 0.25.0
|
||||
'@esbuild/win32-arm64': 0.25.0
|
||||
'@esbuild/win32-ia32': 0.25.0
|
||||
'@esbuild/win32-x64': 0.25.0
|
||||
|
||||
estree-walker@3.0.3:
|
||||
dependencies:
|
||||
'@types/estree': 1.0.6
|
||||
|
||||
expect-type@1.2.0: {}
|
||||
|
||||
file-uri-to-path@1.0.0: {}
|
||||
|
||||
fs-minipass@2.1.0:
|
||||
dependencies:
|
||||
minipass: 3.3.6
|
||||
|
||||
fsevents@2.3.3:
|
||||
optional: true
|
||||
|
||||
loupe@3.1.3: {}
|
||||
|
||||
magic-string@0.30.17:
|
||||
dependencies:
|
||||
'@jridgewell/sourcemap-codec': 1.5.0
|
||||
|
||||
minipass@3.3.6:
|
||||
dependencies:
|
||||
yallist: 4.0.0
|
||||
|
||||
minipass@5.0.0: {}
|
||||
|
||||
minizlib@2.1.2:
|
||||
dependencies:
|
||||
minipass: 3.3.6
|
||||
yallist: 4.0.0
|
||||
|
||||
mkdirp@1.0.4: {}
|
||||
|
||||
ms@2.1.3: {}
|
||||
|
||||
nanoid@3.3.9: {}
|
||||
|
||||
pathe@2.0.3: {}
|
||||
|
||||
pathval@2.0.0: {}
|
||||
|
||||
picocolors@1.1.1: {}
|
||||
|
||||
postcss@8.5.3:
|
||||
dependencies:
|
||||
nanoid: 3.3.9
|
||||
picocolors: 1.1.1
|
||||
source-map-js: 1.2.1
|
||||
|
||||
rollup@4.34.9:
|
||||
dependencies:
|
||||
'@types/estree': 1.0.6
|
||||
optionalDependencies:
|
||||
'@rollup/rollup-android-arm-eabi': 4.34.9
|
||||
'@rollup/rollup-android-arm64': 4.34.9
|
||||
'@rollup/rollup-darwin-arm64': 4.34.9
|
||||
'@rollup/rollup-darwin-x64': 4.34.9
|
||||
'@rollup/rollup-freebsd-arm64': 4.34.9
|
||||
'@rollup/rollup-freebsd-x64': 4.34.9
|
||||
'@rollup/rollup-linux-arm-gnueabihf': 4.34.9
|
||||
'@rollup/rollup-linux-arm-musleabihf': 4.34.9
|
||||
'@rollup/rollup-linux-arm64-gnu': 4.34.9
|
||||
'@rollup/rollup-linux-arm64-musl': 4.34.9
|
||||
'@rollup/rollup-linux-loongarch64-gnu': 4.34.9
|
||||
'@rollup/rollup-linux-powerpc64le-gnu': 4.34.9
|
||||
'@rollup/rollup-linux-riscv64-gnu': 4.34.9
|
||||
'@rollup/rollup-linux-s390x-gnu': 4.34.9
|
||||
'@rollup/rollup-linux-x64-gnu': 4.34.9
|
||||
'@rollup/rollup-linux-x64-musl': 4.34.9
|
||||
'@rollup/rollup-win32-arm64-msvc': 4.34.9
|
||||
'@rollup/rollup-win32-ia32-msvc': 4.34.9
|
||||
'@rollup/rollup-win32-x64-msvc': 4.34.9
|
||||
fsevents: 2.3.3
|
||||
|
||||
siginfo@2.0.0: {}
|
||||
|
||||
source-map-js@1.2.1: {}
|
||||
|
||||
stackback@0.0.2: {}
|
||||
|
||||
std-env@3.8.1: {}
|
||||
|
||||
tar@6.2.1:
|
||||
dependencies:
|
||||
chownr: 2.0.0
|
||||
fs-minipass: 2.1.0
|
||||
minipass: 5.0.0
|
||||
minizlib: 2.1.2
|
||||
mkdirp: 1.0.4
|
||||
yallist: 4.0.0
|
||||
|
||||
tinybench@2.9.0: {}
|
||||
|
||||
tinyexec@0.3.2: {}
|
||||
|
||||
tinypool@1.0.2: {}
|
||||
|
||||
tinyrainbow@2.0.0: {}
|
||||
|
||||
tinyspy@3.0.2: {}
|
||||
|
||||
vite-node@3.0.8:
|
||||
dependencies:
|
||||
cac: 6.7.14
|
||||
debug: 4.4.0
|
||||
es-module-lexer: 1.6.0
|
||||
pathe: 2.0.3
|
||||
vite: 6.2.1
|
||||
transitivePeerDependencies:
|
||||
- '@types/node'
|
||||
- jiti
|
||||
- less
|
||||
- lightningcss
|
||||
- sass
|
||||
- sass-embedded
|
||||
- stylus
|
||||
- sugarss
|
||||
- supports-color
|
||||
- terser
|
||||
- tsx
|
||||
- yaml
|
||||
|
||||
vite@6.2.1:
|
||||
dependencies:
|
||||
esbuild: 0.25.0
|
||||
postcss: 8.5.3
|
||||
rollup: 4.34.9
|
||||
optionalDependencies:
|
||||
fsevents: 2.3.3
|
||||
|
||||
vitest@3.0.8:
|
||||
dependencies:
|
||||
'@vitest/expect': 3.0.8
|
||||
'@vitest/mocker': 3.0.8(vite@6.2.1)
|
||||
'@vitest/pretty-format': 3.0.8
|
||||
'@vitest/runner': 3.0.8
|
||||
'@vitest/snapshot': 3.0.8
|
||||
'@vitest/spy': 3.0.8
|
||||
'@vitest/utils': 3.0.8
|
||||
chai: 5.2.0
|
||||
debug: 4.4.0
|
||||
expect-type: 1.2.0
|
||||
magic-string: 0.30.17
|
||||
pathe: 2.0.3
|
||||
std-env: 3.8.1
|
||||
tinybench: 2.9.0
|
||||
tinyexec: 0.3.2
|
||||
tinypool: 1.0.2
|
||||
tinyrainbow: 2.0.0
|
||||
vite: 6.2.1
|
||||
vite-node: 3.0.8
|
||||
why-is-node-running: 2.3.0
|
||||
transitivePeerDependencies:
|
||||
- jiti
|
||||
- less
|
||||
- lightningcss
|
||||
- msw
|
||||
- sass
|
||||
- sass-embedded
|
||||
- stylus
|
||||
- sugarss
|
||||
- supports-color
|
||||
- terser
|
||||
- tsx
|
||||
- yaml
|
||||
|
||||
why-is-node-running@2.3.0:
|
||||
dependencies:
|
||||
siginfo: 2.0.0
|
||||
stackback: 0.0.2
|
||||
|
||||
yallist@4.0.0: {}
|
||||
68
bench/select.bench.js
Normal file
68
bench/select.bench.js
Normal file
@ -0,0 +1,68 @@
|
||||
import { bench, describe } from 'vitest';
|
||||
|
||||
import BDatabase from '@signalapp/better-sqlite3';
|
||||
import Database from '../lib/index.js';
|
||||
|
||||
const PREPARE = `
|
||||
CREATE TABLE t (
|
||||
a1 INTEGER,
|
||||
a2 INTEGER,
|
||||
a3 INTEGER,
|
||||
b1 TEXT,
|
||||
b2 TEXT,
|
||||
b3 TEXT
|
||||
);
|
||||
`;
|
||||
|
||||
const INSERT = `
|
||||
INSERT INTO t (a1, a2, a3, b1, b2, b3) VALUES
|
||||
($a1, $a2, $a3, $b1, $b2, $b3);
|
||||
`;
|
||||
|
||||
const VALUES = [];
|
||||
for (let i = 0; i < 100; i += 1) {
|
||||
VALUES.push({
|
||||
a1: i,
|
||||
a2: i ** 2,
|
||||
a3: i ** 3,
|
||||
b1: `b1-${i}`,
|
||||
b2: `b2-${i}`,
|
||||
b3: `b3-${i}`,
|
||||
});
|
||||
}
|
||||
|
||||
const SELECT = 'SELECT * FROM t LIMIT 1000';
|
||||
|
||||
describe('SELECT * FROM t', () => {
|
||||
const sdb = new Database(':memory:', { cacheStatements: true });
|
||||
const bdb = new BDatabase(':memory:');
|
||||
|
||||
sdb.exec(PREPARE);
|
||||
bdb.exec(PREPARE);
|
||||
|
||||
const sinsert = sdb.prepare(INSERT);
|
||||
const binsert = bdb.prepare(INSERT);
|
||||
|
||||
sdb.transaction(() => {
|
||||
for (const value of VALUES) {
|
||||
sinsert.run(value);
|
||||
}
|
||||
})();
|
||||
|
||||
bdb.transaction(() => {
|
||||
for (const value of VALUES) {
|
||||
binsert.run(value);
|
||||
}
|
||||
})();
|
||||
|
||||
const sselect = sdb.prepare(SELECT);
|
||||
const bselect = bdb.prepare(SELECT);
|
||||
|
||||
bench('@signalapp/sqlcipher', () => {
|
||||
sselect.all();
|
||||
});
|
||||
|
||||
bench('@signalapp/better-sqlite', () => {
|
||||
bselect.all();
|
||||
});
|
||||
});
|
||||
22
binding.gyp
Normal file
22
binding.gyp
Normal file
@ -0,0 +1,22 @@
|
||||
{
|
||||
'includes': ['deps/common.gypi'],
|
||||
'targets': [
|
||||
{
|
||||
'target_name': 'node_sqlcipher',
|
||||
'dependencies': [
|
||||
'deps/sqlcipher/sqlcipher.gyp:sqlcipher',
|
||||
'deps/extension/extension.gyp:extension',
|
||||
"<!(node -p \"require('node-addon-api').targets\"):node_addon_api",
|
||||
],
|
||||
'sources': ['src/addon.cc'],
|
||||
'conditions': [
|
||||
['OS=="linux"', {
|
||||
'ldflags': [
|
||||
'-Wl,-Bsymbolic',
|
||||
'-Wl,--exclude-libs,ALL',
|
||||
],
|
||||
}],
|
||||
],
|
||||
},
|
||||
],
|
||||
}
|
||||
73
deps/common.gypi
vendored
Normal file
73
deps/common.gypi
vendored
Normal file
@ -0,0 +1,73 @@
|
||||
{
|
||||
'target_defaults': {
|
||||
'default_configuration': 'Release',
|
||||
'msvs_settings': {
|
||||
'VCCLCompilerTool': {
|
||||
'ExceptionHandling': 1,
|
||||
},
|
||||
},
|
||||
'conditions': [
|
||||
['OS == "win"', {
|
||||
'defines': ['WIN32'],
|
||||
}],
|
||||
],
|
||||
'configurations': {
|
||||
'Debug': {
|
||||
'defines!': [
|
||||
'NDEBUG',
|
||||
],
|
||||
'defines': [
|
||||
'DEBUG',
|
||||
'_DEBUG',
|
||||
'SQLITE_DEBUG',
|
||||
'SQLITE_MEMDEBUG',
|
||||
'SQLITE_ENABLE_API_ARMOR',
|
||||
'SQLITE_WIN32_MALLOC_VALIDATE',
|
||||
],
|
||||
'cflags': [
|
||||
'-O0',
|
||||
],
|
||||
'xcode_settings': {
|
||||
'MACOSX_DEPLOYMENT_TARGET': '11',
|
||||
'GCC_OPTIMIZATION_LEVEL': '0',
|
||||
'GCC_GENERATE_DEBUGGING_SYMBOLS': 'YES',
|
||||
'GCC_ENABLE_CPP_EXCEPTIONS': 'NO',
|
||||
},
|
||||
'msvs_settings': {
|
||||
'VCLinkerTool': {
|
||||
'GenerateDebugInformation': 'true',
|
||||
},
|
||||
},
|
||||
},
|
||||
'Release': {
|
||||
'defines!': [
|
||||
'DEBUG',
|
||||
'_DEBUG',
|
||||
],
|
||||
'defines': [
|
||||
'NDEBUG',
|
||||
],
|
||||
'cflags': [
|
||||
'-O3',
|
||||
],
|
||||
'conditions': [
|
||||
['OS == "linux"', {
|
||||
# GCC only for now
|
||||
'cflags': ['-flto=4', '-fuse-linker-plugin', '-ffat-lto-objects'],
|
||||
'ldflags': ['-flto=4', '-fuse-linker-plugin', '-ffat-lto-objects'],
|
||||
}],
|
||||
],
|
||||
'xcode_settings': {
|
||||
'MACOSX_DEPLOYMENT_TARGET': '11',
|
||||
'GCC_OPTIMIZATION_LEVEL': '3',
|
||||
'GCC_GENERATE_DEBUGGING_SYMBOLS': 'NO',
|
||||
'DEAD_CODE_STRIPPING': 'YES',
|
||||
'GCC_INLINES_ARE_PRIVATE_EXTERN': 'YES',
|
||||
'GCC_ENABLE_CPP_EXCEPTIONS': 'NO',
|
||||
'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES', # -fvisibility=hidden
|
||||
'LLVM_LTO': 'YES',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
1
deps/extension/.gitignore
vendored
Normal file
1
deps/extension/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/target
|
||||
698
deps/extension/Cargo.lock
generated
vendored
Normal file
698
deps/extension/Cargo.lock
generated
vendored
Normal file
@ -0,0 +1,698 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "aes"
|
||||
version = "0.8.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cipher",
|
||||
"cpufeatures",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstream"
|
||||
version = "0.6.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526"
|
||||
dependencies = [
|
||||
"anstyle",
|
||||
"anstyle-parse",
|
||||
"anstyle-query",
|
||||
"anstyle-wincon",
|
||||
"colorchoice",
|
||||
"is_terminal_polyfill",
|
||||
"utf8parse",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle"
|
||||
version = "1.0.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1"
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-parse"
|
||||
version = "0.2.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eb47de1e80c2b463c735db5b217a0ddc39d612e7ac9e2e96a5aed1f57616c1cb"
|
||||
dependencies = [
|
||||
"utf8parse",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-query"
|
||||
version = "1.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a"
|
||||
dependencies = [
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anstyle-wincon"
|
||||
version = "3.0.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8"
|
||||
dependencies = [
|
||||
"anstyle",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "2.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de"
|
||||
|
||||
[[package]]
|
||||
name = "block-buffer"
|
||||
version = "0.10.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3078c7629b62d3f0439517fa394996acacc5cbc91c5a20d8c658e77abd503a71"
|
||||
dependencies = [
|
||||
"generic-array",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "block-padding"
|
||||
version = "0.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a8894febbff9f758034a5b8e12d87918f56dfc64a8e1fe757d65e29041538d93"
|
||||
dependencies = [
|
||||
"generic-array",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cbc"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "26b52a9543ae338f279b96b0b9fed9c8093744685043739079ce85cd58f289a6"
|
||||
dependencies = [
|
||||
"cipher",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cbindgen"
|
||||
version = "0.27.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3fce8dd7fcfcbf3a0a87d8f515194b49d6135acab73e18bd380d1d93bb1a15eb"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"heck",
|
||||
"indexmap",
|
||||
"log",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"syn",
|
||||
"tempfile",
|
||||
"toml",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.1.24"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "812acba72f0a070b003d3697490d2b55b837230ae7c6c6497f05cc2ddbb8d938"
|
||||
dependencies = [
|
||||
"shlex",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "cipher"
|
||||
version = "0.4.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "773f3b9af64447d2ce9850330c473515014aa235e6a783b02db81ff39e4a3dad"
|
||||
dependencies = [
|
||||
"crypto-common",
|
||||
"inout",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "4.5.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b97f376d85a664d5837dbae44bf546e6477a679ff6610010f17276f686d867e8"
|
||||
dependencies = [
|
||||
"clap_builder",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_builder"
|
||||
version = "4.5.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "19bc80abd44e4bed93ca373a0704ccbd1b710dc5749406201bb018272808dc54"
|
||||
dependencies = [
|
||||
"anstream",
|
||||
"anstyle",
|
||||
"clap_lex",
|
||||
"strsim",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_lex"
|
||||
version = "0.7.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97"
|
||||
|
||||
[[package]]
|
||||
name = "colorchoice"
|
||||
version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0"
|
||||
|
||||
[[package]]
|
||||
name = "cpufeatures"
|
||||
version = "0.2.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "608697df725056feaccfa42cffdaeeec3fccc4ffc38358ecd19b243e716a78e0"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crypto-common"
|
||||
version = "0.1.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1bfb12502f3fc46cca1bb51ac28df9d618d813cdc3d2f25b9fe775a34af26bb3"
|
||||
dependencies = [
|
||||
"generic-array",
|
||||
"typenum",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "digest"
|
||||
version = "0.10.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292"
|
||||
dependencies = [
|
||||
"block-buffer",
|
||||
"crypto-common",
|
||||
"subtle",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "equivalent"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
|
||||
|
||||
[[package]]
|
||||
name = "errno"
|
||||
version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fastrand"
|
||||
version = "2.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6"
|
||||
|
||||
[[package]]
|
||||
name = "generic-array"
|
||||
version = "0.14.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "85649ca51fd72272d7821adaf274ad91c288277713d9c18820d8499a7ff69e9a"
|
||||
dependencies = [
|
||||
"typenum",
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.2.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"wasi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.15.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb"
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
|
||||
|
||||
[[package]]
|
||||
name = "hmac"
|
||||
version = "0.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e"
|
||||
dependencies = [
|
||||
"digest",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "2.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da"
|
||||
dependencies = [
|
||||
"equivalent",
|
||||
"hashbrown",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "inout"
|
||||
version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a0c10553d664a4d0bcff9f4215d0aac67a639cc68ef660840afe309b807bc9f5"
|
||||
dependencies = [
|
||||
"block-padding",
|
||||
"generic-array",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "is_terminal_polyfill"
|
||||
version = "1.70.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "1.0.11"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.161"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1"
|
||||
|
||||
[[package]]
|
||||
name = "linux-raw-sys"
|
||||
version = "0.4.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89"
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24"
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.7.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.20.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775"
|
||||
|
||||
[[package]]
|
||||
name = "pbkdf2"
|
||||
version = "0.12.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f8ed6a7761f76e3b9f92dfb0a60a6a6477c61024b775147ff0973a02653abaf2"
|
||||
dependencies = [
|
||||
"digest",
|
||||
"hmac",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.88"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7c3a7fc5db1e57d5a779a352c8cdb57b29aa4c40cc69c3a68a7fedc815fbf2f9"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.37"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b5b9d34b8991d19d98081b46eacdd8eb58c6f2b201139f7c5f643cc155a633af"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.6.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
|
||||
dependencies = [
|
||||
"getrandom",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustix"
|
||||
version = "0.38.37"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"errno",
|
||||
"libc",
|
||||
"linux-raw-sys",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ryu"
|
||||
version = "1.0.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f"
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.210"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.210"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.129"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6dbcf9b78a125ee667ae19388837dd12294b858d101fdd393cb9d5501ef09eb2"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"memchr",
|
||||
"ryu",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_spanned"
|
||||
version = "0.6.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "87607cb1398ed59d48732e575a4c28a7a8ebf2454b964fe3f224f2afc07909e1"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sha2"
|
||||
version = "0.10.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"cpufeatures",
|
||||
"digest",
|
||||
"sha2-asm",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sha2-asm"
|
||||
version = "0.6.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b845214d6175804686b2bd482bcffe96651bb2d1200742b712003504a2dac1ab"
|
||||
dependencies = [
|
||||
"cc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "shlex"
|
||||
version = "1.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
|
||||
|
||||
[[package]]
|
||||
name = "signal-sqlcipher-extension"
|
||||
version = "0.2.1"
|
||||
dependencies = [
|
||||
"aes",
|
||||
"cbc",
|
||||
"cbindgen",
|
||||
"hmac",
|
||||
"pbkdf2",
|
||||
"rand_core",
|
||||
"sha2",
|
||||
"signal-tokenizer",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "signal-tokenizer"
|
||||
version = "0.2.1"
|
||||
source = "git+https://github.com/signalapp/Signal-FTS5-Extension#a2a00359b1c0987e9b167855ebf0cd93342fd26e"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"unicode-normalization",
|
||||
"unicode-segmentation",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
version = "0.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
|
||||
|
||||
[[package]]
|
||||
name = "subtle"
|
||||
version = "2.6.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.79"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tempfile"
|
||||
version = "3.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f0f2c9fc62d0beef6951ccffd757e241266a2c833136efbe35af6cd2567dca5b"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"fastrand",
|
||||
"once_cell",
|
||||
"rustix",
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tinyvec"
|
||||
version = "1.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "445e881f4f6d382d5f27c034e25eb92edd7c784ceab92a0937db7f2e9471b938"
|
||||
dependencies = [
|
||||
"tinyvec_macros",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tinyvec_macros"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
|
||||
|
||||
[[package]]
|
||||
name = "toml"
|
||||
version = "0.8.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"serde_spanned",
|
||||
"toml_datetime",
|
||||
"toml_edit",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_datetime"
|
||||
version = "0.6.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_edit"
|
||||
version = "0.22.22"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5"
|
||||
dependencies = [
|
||||
"indexmap",
|
||||
"serde",
|
||||
"serde_spanned",
|
||||
"toml_datetime",
|
||||
"winnow",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "typenum"
|
||||
version = "1.17.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-normalization"
|
||||
version = "0.1.24"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5033c97c4262335cded6d6fc3e5c18ab755e1a3dc96376350f3d8e9f009ad956"
|
||||
dependencies = [
|
||||
"tinyvec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-segmentation"
|
||||
version = "1.12.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493"
|
||||
|
||||
[[package]]
|
||||
name = "utf8parse"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
|
||||
|
||||
[[package]]
|
||||
name = "version_check"
|
||||
version = "0.9.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.11.0+wasi-snapshot-preview1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.52.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
|
||||
dependencies = [
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.59.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
|
||||
dependencies = [
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-targets"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
|
||||
dependencies = [
|
||||
"windows_aarch64_gnullvm",
|
||||
"windows_aarch64_msvc",
|
||||
"windows_i686_gnu",
|
||||
"windows_i686_gnullvm",
|
||||
"windows_i686_msvc",
|
||||
"windows_x86_64_gnu",
|
||||
"windows_x86_64_gnullvm",
|
||||
"windows_x86_64_msvc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnu"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnu"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
|
||||
|
||||
[[package]]
|
||||
name = "winnow"
|
||||
version = "0.6.20"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
37
deps/extension/Cargo.toml
vendored
Normal file
37
deps/extension/Cargo.toml
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
#
|
||||
# Copyright (C) 2024 Signal Messenger, LLC.
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
#
|
||||
|
||||
[package]
|
||||
name = "signal-sqlcipher-extension"
|
||||
version = "0.2.1"
|
||||
edition = "2021"
|
||||
license = "AGPL-3.0-only"
|
||||
|
||||
[lib]
|
||||
crate-type = ["staticlib"]
|
||||
|
||||
[profile.release]
|
||||
lto = true
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
aes = "0.8.4"
|
||||
cbc = "0.1.2"
|
||||
hmac = "0.12.1"
|
||||
pbkdf2 = "0.12.2"
|
||||
rand_core = { version = "0.6.4", "default-features" = false, features = ["getrandom"] }
|
||||
sha2 = { version = "0.10.8", "default-features" = false }
|
||||
signal-tokenizer = { git = "https://github.com/signalapp/Signal-FTS5-Extension" }
|
||||
|
||||
[build-dependencies]
|
||||
cbindgen = "0.27.0"
|
||||
|
||||
[target.'cfg(not(any(windows, target_arch = "x86")))'.dependencies]
|
||||
# sha2's asm implementation uses standalone .S files that aren't compiled correctly on Windows,
|
||||
# and aren't linked correctly on x86 Android.
|
||||
# This will be fixed in sha2 0.11, which also removes the "asm" feature and turns it on by default.
|
||||
# So when sha2 0.11 is released, this section will go away.
|
||||
sha2 = { version = "0.10.8", "default-features" = false, features = ["asm"] }
|
||||
661
deps/extension/LICENSE
vendored
Normal file
661
deps/extension/LICENSE
vendored
Normal file
@ -0,0 +1,661 @@
|
||||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
Version 3, 19 November 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU Affero General Public License is a free, copyleft license for
|
||||
software and other kinds of works, specifically designed to ensure
|
||||
cooperation with the community in the case of network server software.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
our General Public Licenses are intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
Developers that use our General Public Licenses protect your rights
|
||||
with two steps: (1) assert copyright on the software, and (2) offer
|
||||
you this License which gives you legal permission to copy, distribute
|
||||
and/or modify the software.
|
||||
|
||||
A secondary benefit of defending all users' freedom is that
|
||||
improvements made in alternate versions of the program, if they
|
||||
receive widespread use, become available for other developers to
|
||||
incorporate. Many developers of free software are heartened and
|
||||
encouraged by the resulting cooperation. However, in the case of
|
||||
software used on network servers, this result may fail to come about.
|
||||
The GNU General Public License permits making a modified version and
|
||||
letting the public access it on a server without ever releasing its
|
||||
source code to the public.
|
||||
|
||||
The GNU Affero General Public License is designed specifically to
|
||||
ensure that, in such cases, the modified source code becomes available
|
||||
to the community. It requires the operator of a network server to
|
||||
provide the source code of the modified version running there to the
|
||||
users of that server. Therefore, public use of a modified version, on
|
||||
a publicly accessible server, gives the public access to the source
|
||||
code of the modified version.
|
||||
|
||||
An older license, called the Affero General Public License and
|
||||
published by Affero, was designed to accomplish similar goals. This is
|
||||
a different license, not a version of the Affero GPL, but Affero has
|
||||
released a new version of the Affero GPL which permits relicensing under
|
||||
this license.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, if you modify the
|
||||
Program, your modified version must prominently offer all users
|
||||
interacting with it remotely through a computer network (if your version
|
||||
supports such interaction) an opportunity to receive the Corresponding
|
||||
Source of your version by providing access to the Corresponding Source
|
||||
from a network server at no charge, through some standard or customary
|
||||
means of facilitating copying of software. This Corresponding Source
|
||||
shall include the Corresponding Source for any work covered by version 3
|
||||
of the GNU General Public License that is incorporated pursuant to the
|
||||
following paragraph.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the work with which it is combined will remain governed by version
|
||||
3 of the GNU General Public License.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU Affero General Public License from time to time. Such new versions
|
||||
will be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU Affero General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU Affero General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU Affero General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If your software can interact with users remotely through a computer
|
||||
network, you should also make sure that it provides a way for users to
|
||||
get its source. For example, if your program is a web application, its
|
||||
interface could display a "Source" link that leads users to an archive
|
||||
of the code. There are many ways you could offer source, and different
|
||||
solutions will be better for different programs; see section 13 for the
|
||||
specific requirements.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU AGPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
36
deps/extension/README.md
vendored
Normal file
36
deps/extension/README.md
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
# Overview
|
||||
|
||||
Signal-Sqlcipher-Extension bundles:
|
||||
|
||||
- [Signal-FTS5-Extension](https://github.com/signalapp/Signal-FTS5-Extension)
|
||||
- Rust-based cryptography provider
|
||||
|
||||
into a single .a (.lib on Windows) file that could be linked into relevant
|
||||
sqlcipher builds.
|
||||
|
||||
# Build Instructions
|
||||
|
||||
For x86_64:
|
||||
|
||||
```sh
|
||||
cargo build --release
|
||||
```
|
||||
|
||||
For arm64
|
||||
|
||||
```sh
|
||||
RUSTFLAGS="--cfg aes_armv8" cargo build --release
|
||||
```
|
||||
|
||||
# Usage
|
||||
|
||||
The resulting `.a`/`.lib` file needs to be linked with sqlcipher, and built with
|
||||
`-DSQLCIPHER_CRYPTO_CUSTOM=signal_crypto_provider_setup`.
|
||||
|
||||
# Legal things
|
||||
|
||||
## License
|
||||
|
||||
Copyright 2024 Signal Messenger, LLC.
|
||||
|
||||
Licensed under the AGPLv3: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
57
deps/extension/build.rs
vendored
Normal file
57
deps/extension/build.rs
vendored
Normal file
@ -0,0 +1,57 @@
|
||||
extern crate cbindgen;
|
||||
|
||||
use cbindgen::{Config, EnumConfig, ExportConfig, ItemType, Language, Style};
|
||||
use std::env;
|
||||
|
||||
fn main() {
|
||||
let crate_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
|
||||
|
||||
let mut config = Config {
|
||||
language: Language::C,
|
||||
header: Some(
|
||||
"/*\nCopyright (C) 2024 Signal Messenger, LLC.\nSPDX-License-Identifier: AGPL-3.0-only\n*/"
|
||||
.into(),
|
||||
),
|
||||
style: Style::Type,
|
||||
cpp_compat: true,
|
||||
enumeration: EnumConfig {
|
||||
prefix_with_name: true,
|
||||
..Default::default()
|
||||
},
|
||||
include_guard: Some("SIGNAL_FTS5_TOKENIZER_H_".into()),
|
||||
export: ExportConfig {
|
||||
item_types: vec![
|
||||
ItemType::Functions,
|
||||
ItemType::OpaqueItems,
|
||||
ItemType::Structs,
|
||||
ItemType::Typedefs,
|
||||
],
|
||||
..Default::default()
|
||||
},
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
config
|
||||
.export
|
||||
.rename
|
||||
.insert("Sqlite3".into(), "sqlite3".into());
|
||||
config
|
||||
.export
|
||||
.rename
|
||||
.insert("SqliteAPIRoutines3".into(), "sqlite3_api_routines".into());
|
||||
config
|
||||
.export
|
||||
.rename
|
||||
.insert("TokenFunction".into(), "sqlite3__fts5_token_fn".into());
|
||||
config.defines.insert(
|
||||
"feature = extension".into(),
|
||||
"SIGNAL_FTS5_TOKENIZER_EXTENSION_H_".into(),
|
||||
);
|
||||
|
||||
cbindgen::Builder::new()
|
||||
.with_crate_and_name(crate_dir, "signal-tokenizer")
|
||||
.with_config(config)
|
||||
.generate()
|
||||
.expect("Unable to generate bindings")
|
||||
.write_to_file("target/signal-tokenizer.h");
|
||||
}
|
||||
21
deps/extension/cargo-wrap.js
vendored
Normal file
21
deps/extension/cargo-wrap.js
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
/* v8 ignore start */
|
||||
// Copyright 2025 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
const { spawnSync } = require('node:child_process');
|
||||
const { basename } = require('node:path');
|
||||
|
||||
const target = process.argv[2];
|
||||
const args = ['build', '--release', '--target', basename(target)];
|
||||
|
||||
console.log('Running: cargo with args:', args);
|
||||
spawnSync('cargo', args, {
|
||||
stdio: [null, 'inherit', 'inherit'],
|
||||
cwd: __dirname,
|
||||
env: {
|
||||
...process.env,
|
||||
MACOSX_DEPLOYMENT_TARGET: '11.0',
|
||||
CFLAGS: process.platform === 'win32' ? undefined : '-Wa,--noexecstack',
|
||||
RUSTFLAGS: target.includes('aarch64') ? '--cfg aes_armv8' : '',
|
||||
},
|
||||
});
|
||||
84
deps/extension/extension.gyp
vendored
Normal file
84
deps/extension/extension.gyp
vendored
Normal file
@ -0,0 +1,84 @@
|
||||
{
|
||||
'variables': {
|
||||
'conditions': [
|
||||
['OS == "mac" and target_arch == "x64"', {
|
||||
'rust_arch': 'x86_64-apple-darwin',
|
||||
'rust_prefix': 'lib',
|
||||
'rust_ext': 'a',
|
||||
}],
|
||||
['OS == "mac" and target_arch == "arm64"', {
|
||||
'rust_arch': 'aarch64-apple-darwin',
|
||||
'rust_prefix': 'lib',
|
||||
'rust_ext': 'a',
|
||||
}],
|
||||
['OS == "linux" and target_arch == "x64"', {
|
||||
'rust_arch': 'x86_64-unknown-linux-gnu',
|
||||
'rust_prefix': 'lib',
|
||||
'rust_ext': 'a',
|
||||
}],
|
||||
['OS == "linux" and target_arch == "arm64"', {
|
||||
'rust_arch': 'aarch64-unknown-linux-gnu',
|
||||
'rust_prefix': 'lib',
|
||||
'rust_ext': 'a',
|
||||
}],
|
||||
['OS == "win" and target_arch == "x64"', {
|
||||
'rust_arch': 'x86_64-pc-windows-msvc',
|
||||
'rust_prefix': '',
|
||||
'rust_ext': 'lib',
|
||||
}],
|
||||
['OS == "win" and target_arch == "arm64"', {
|
||||
'rust_arch': 'aarch64-pc-windows-msvc',
|
||||
'rust_prefix': '',
|
||||
'rust_ext': 'lib',
|
||||
}],
|
||||
],
|
||||
},
|
||||
'targets': [{
|
||||
'target_name': 'extension',
|
||||
'type': 'none',
|
||||
'direct_dependent_settings': {
|
||||
'include_dirs': [
|
||||
'target',
|
||||
],
|
||||
'conditions': [
|
||||
['OS == "win"', {
|
||||
'link_settings': {
|
||||
'libraries': [
|
||||
'-l<(rust_prefix)signal_sqlcipher_extension.<(rust_ext)',
|
||||
],
|
||||
'library_dirs': [
|
||||
'<(SHARED_INTERMEDIATE_DIR)',
|
||||
]
|
||||
}
|
||||
}, {
|
||||
'link_settings': {
|
||||
'libraries': [
|
||||
'<(SHARED_INTERMEDIATE_DIR)/<(rust_prefix)signal_sqlcipher_extension.<(rust_ext)',
|
||||
]
|
||||
},
|
||||
}],
|
||||
],
|
||||
},
|
||||
'hard_dependency': 1,
|
||||
'actions': [{
|
||||
'action_name': 'build',
|
||||
'process_outputs_as_sources': 1,
|
||||
'inputs': [],
|
||||
'outputs': [
|
||||
'target/signal-tokenizer.h',
|
||||
'target/<(rust_arch)/release/<(rust_prefix)signal_sqlcipher_extension.<(rust_ext)',
|
||||
],
|
||||
'action': [
|
||||
'node',
|
||||
'cargo-wrap.js',
|
||||
'target/<(rust_arch)',
|
||||
],
|
||||
}],
|
||||
'copies': [{
|
||||
'files': [
|
||||
'target/<(rust_arch)/release/<(rust_prefix)signal_sqlcipher_extension.<(rust_ext)',
|
||||
],
|
||||
'destination': '<(SHARED_INTERMEDIATE_DIR)',
|
||||
}],
|
||||
}],
|
||||
}
|
||||
10
deps/extension/package.json
vendored
Normal file
10
deps/extension/package.json
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"private": true,
|
||||
"name": "@signalapp/sqlcipher-extension",
|
||||
"version": "0.0.0",
|
||||
"license": "AGPL-3.0-only",
|
||||
"author": {
|
||||
"name": "Signal Messenger, LLC",
|
||||
"email": "support@signal.org"
|
||||
}
|
||||
}
|
||||
215
deps/extension/src/lib.rs
vendored
Normal file
215
deps/extension/src/lib.rs
vendored
Normal file
@ -0,0 +1,215 @@
|
||||
//
|
||||
// Copyright 2024 Signal Messenger, LLC.
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
//
|
||||
|
||||
use crate::sqlcipher::*;
|
||||
use crate::sqlite::*;
|
||||
use aes::cipher::{block_padding::NoPadding, BlockDecryptMut, BlockEncryptMut, KeyIvInit};
|
||||
use core::ffi::{c_char, c_int, c_uchar, c_void};
|
||||
use hmac::{Hmac, Mac};
|
||||
use pbkdf2::pbkdf2_hmac;
|
||||
use rand_core::{OsRng, RngCore};
|
||||
use sha2::Sha512;
|
||||
|
||||
pub use signal_tokenizer;
|
||||
|
||||
mod sqlcipher;
|
||||
mod sqlite;
|
||||
|
||||
type Aes256CbcEnc = cbc::Encryptor<aes::Aes256>;
|
||||
type Aes256CbcDec = cbc::Decryptor<aes::Aes256>;
|
||||
|
||||
extern "C" fn activate(_ctx: *mut c_void) -> c_int {
|
||||
// Not called
|
||||
SQLITE_OK
|
||||
}
|
||||
|
||||
extern "C" fn deactivate(_ctx: *mut c_void) -> c_int {
|
||||
// Not called
|
||||
SQLITE_OK
|
||||
}
|
||||
|
||||
extern "C" fn ctx_init(_ctx: *mut *mut c_void) -> c_int {
|
||||
// Not called
|
||||
SQLITE_OK
|
||||
}
|
||||
|
||||
extern "C" fn ctx_free(_ctx: *mut *mut c_void) -> c_int {
|
||||
// Not called
|
||||
SQLITE_OK
|
||||
}
|
||||
|
||||
extern "C" fn get_provider_name(_ctx: *mut c_void) -> *const c_char {
|
||||
return concat!(env!("CARGO_PKG_NAME"), "\0").as_bytes().as_ptr() as *const c_char;
|
||||
}
|
||||
|
||||
extern "C" fn get_provider_version(_ctx: *mut c_void) -> *const c_char {
|
||||
return concat!(env!("CARGO_PKG_VERSION"), "\0").as_bytes().as_ptr() as *const c_char;
|
||||
}
|
||||
|
||||
extern "C" fn fips_status(_ctx: *mut c_void) -> c_int {
|
||||
// Off
|
||||
0
|
||||
}
|
||||
|
||||
extern "C" fn add_random(_ctx: *mut c_void, _buf: *mut c_void, _length: c_int) -> c_int {
|
||||
// Not needed
|
||||
SQLITE_OK
|
||||
}
|
||||
|
||||
extern "C" fn random(_ctx: *mut c_void, buf: *mut c_void, length: c_int) -> c_int {
|
||||
if buf.is_null() {
|
||||
return SQLITE_ERROR;
|
||||
}
|
||||
let slice = unsafe { core::slice::from_raw_parts_mut(buf as *mut c_uchar, length as usize) };
|
||||
OsRng.fill_bytes(slice);
|
||||
SQLITE_OK
|
||||
}
|
||||
|
||||
extern "C" fn get_hmac_sz(_ctx: *mut c_void, algorithm: c_int) -> c_int {
|
||||
match algorithm {
|
||||
SQLCIPHER_HMAC_SHA512 => 64,
|
||||
_ => 0,
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" fn hmac(
|
||||
_ctx: *mut c_void,
|
||||
algorithm: c_int,
|
||||
hmac_key: *const c_uchar,
|
||||
key_sz: c_int,
|
||||
in1: *const c_uchar,
|
||||
in1_sz: c_int,
|
||||
in2: *const c_uchar,
|
||||
in2_sz: c_int,
|
||||
out: *mut c_uchar,
|
||||
) -> c_int {
|
||||
if algorithm != SQLCIPHER_HMAC_SHA512 {
|
||||
return SQLITE_ERROR;
|
||||
}
|
||||
if hmac_key.is_null() || in1.is_null() || out.is_null() {
|
||||
return SQLITE_ERROR;
|
||||
}
|
||||
let key = unsafe { core::slice::from_raw_parts(hmac_key as *mut c_uchar, key_sz as usize) };
|
||||
let in1 = unsafe { core::slice::from_raw_parts(in1 as *const c_uchar, in1_sz as usize) };
|
||||
let in2 = if in2.is_null() {
|
||||
None
|
||||
} else {
|
||||
Some(unsafe { core::slice::from_raw_parts(in2 as *mut c_uchar, in2_sz as usize) })
|
||||
};
|
||||
|
||||
let Ok(mut mac) = Hmac::<Sha512>::new_from_slice(key) else {
|
||||
return SQLITE_ERROR;
|
||||
};
|
||||
mac.update(in1);
|
||||
if let Some(in2) = in2 {
|
||||
mac.update(in2);
|
||||
}
|
||||
let digest = mac.finalize().into_bytes();
|
||||
unsafe {
|
||||
out.copy_from(digest.as_ptr(), digest.len());
|
||||
};
|
||||
SQLITE_OK
|
||||
}
|
||||
|
||||
extern "C" fn pbkdf(
|
||||
_ctx: *mut c_void,
|
||||
algorithm: c_int,
|
||||
pass: *const c_uchar,
|
||||
pass_sz: c_int,
|
||||
salt: *const c_uchar,
|
||||
salt_sz: c_int,
|
||||
workfactor: c_int,
|
||||
key_sz: c_int,
|
||||
key: *mut c_uchar,
|
||||
) -> c_int {
|
||||
if algorithm != SQLCIPHER_PBKDF2_HMAC_SHA512 {
|
||||
return SQLITE_ERROR;
|
||||
}
|
||||
if pass.is_null() || salt.is_null() || key.is_null() {
|
||||
return SQLITE_ERROR;
|
||||
}
|
||||
let password = unsafe { core::slice::from_raw_parts(pass as *const c_uchar, pass_sz as usize) };
|
||||
let salt = unsafe { core::slice::from_raw_parts(salt as *const c_uchar, salt_sz as usize) };
|
||||
let buf = unsafe { core::slice::from_raw_parts_mut(key as *mut c_uchar, key_sz as usize) };
|
||||
pbkdf2_hmac::<Sha512>(password, salt, workfactor as u32, buf);
|
||||
SQLITE_OK
|
||||
}
|
||||
|
||||
extern "C" fn get_cipher(_ctx: *mut c_void) -> *const c_char {
|
||||
return "aes-256-cbc\0".as_bytes().as_ptr() as *const c_char;
|
||||
}
|
||||
|
||||
extern "C" fn get_key_sz(_ctx: *mut c_void) -> c_int {
|
||||
// AES-256-CBC
|
||||
32
|
||||
}
|
||||
|
||||
extern "C" fn get_iv_sz(ctx: *mut c_void) -> c_int {
|
||||
get_block_sz(ctx)
|
||||
}
|
||||
|
||||
extern "C" fn get_block_sz(_ctx: *mut c_void) -> c_int {
|
||||
// AES-256-CBC
|
||||
16
|
||||
}
|
||||
|
||||
extern "C" fn cipher(
|
||||
ctx: *mut c_void,
|
||||
mode: c_int,
|
||||
key: *const c_uchar,
|
||||
key_sz: c_int,
|
||||
iv: *const c_uchar,
|
||||
in1: *const c_uchar,
|
||||
in1_sz: c_int,
|
||||
out: *mut c_uchar,
|
||||
) -> c_int {
|
||||
let key = unsafe { core::slice::from_raw_parts(key as *const c_uchar, key_sz as usize) };
|
||||
let iv = unsafe { core::slice::from_raw_parts(iv as *const c_uchar, get_iv_sz(ctx) as usize) };
|
||||
let in1 = unsafe { core::slice::from_raw_parts(in1 as *const c_uchar, in1_sz as usize) };
|
||||
let out = unsafe { core::slice::from_raw_parts_mut(out as *mut c_uchar, in1_sz as usize) };
|
||||
let res = if mode == CIPHER_ENCRYPT {
|
||||
Aes256CbcEnc::new(key.into(), iv.into())
|
||||
.encrypt_padded_b2b_mut::<NoPadding>(in1, out)
|
||||
.map_err(|_| ())
|
||||
} else {
|
||||
Aes256CbcDec::new(key.into(), iv.into())
|
||||
.decrypt_padded_b2b_mut::<NoPadding>(in1, out)
|
||||
.map_err(|_| ())
|
||||
};
|
||||
match res {
|
||||
Ok(_) => SQLITE_OK,
|
||||
Err(_) => SQLITE_ERROR,
|
||||
}
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn signal_crypto_provider_setup(provider: *mut SqlCipherProvider) -> c_int {
|
||||
if provider.is_null() {
|
||||
return SQLITE_ERROR;
|
||||
}
|
||||
|
||||
unsafe {
|
||||
provider.write(SqlCipherProvider {
|
||||
activate,
|
||||
deactivate,
|
||||
get_provider_name,
|
||||
add_random,
|
||||
random,
|
||||
hmac,
|
||||
pbkdf,
|
||||
cipher,
|
||||
get_cipher,
|
||||
get_key_sz,
|
||||
get_iv_sz,
|
||||
get_block_sz,
|
||||
get_hmac_sz,
|
||||
ctx_init,
|
||||
ctx_free,
|
||||
fips_status,
|
||||
get_provider_version,
|
||||
});
|
||||
}
|
||||
SQLITE_OK
|
||||
}
|
||||
63
deps/extension/src/sqlcipher.rs
vendored
Normal file
63
deps/extension/src/sqlcipher.rs
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
//
|
||||
// Copyright 2024 Signal Messenger, LLC.
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
//
|
||||
|
||||
use core::ffi::{c_char, c_int, c_uchar, c_void};
|
||||
|
||||
// From: sqlcipher.h
|
||||
|
||||
pub const SQLCIPHER_HMAC_SHA512: c_int = 2;
|
||||
pub const SQLCIPHER_PBKDF2_HMAC_SHA512: c_int = 2;
|
||||
|
||||
pub const CIPHER_ENCRYPT: c_int = 1;
|
||||
|
||||
#[repr(C)]
|
||||
pub struct SqlCipherProvider {
|
||||
pub activate: extern "C" fn(ctx: *mut c_void) -> c_int,
|
||||
pub deactivate: extern "C" fn(ctx: *mut c_void) -> c_int,
|
||||
pub get_provider_name: extern "C" fn(ctx: *mut c_void) -> *const c_char,
|
||||
pub add_random: extern "C" fn(ctx: *mut c_void, buf: *mut c_void, length: c_int) -> c_int,
|
||||
pub random: extern "C" fn(ctx: *mut c_void, buf: *mut c_void, length: c_int) -> c_int,
|
||||
pub hmac: extern "C" fn(
|
||||
ctx: *mut c_void,
|
||||
algorithm: c_int,
|
||||
hmac_key: *const c_uchar,
|
||||
key_sz: c_int,
|
||||
in1: *const c_uchar,
|
||||
in1_sz: c_int,
|
||||
in2: *const c_uchar,
|
||||
in2_sz: c_int,
|
||||
out: *mut c_uchar,
|
||||
) -> c_int,
|
||||
pub pbkdf: extern "C" fn(
|
||||
ctx: *mut c_void,
|
||||
algorithm: c_int,
|
||||
pass: *const c_uchar,
|
||||
pass_sz: c_int,
|
||||
salt: *const c_uchar,
|
||||
salt_sz: c_int,
|
||||
workfactor: c_int,
|
||||
key_sz: c_int,
|
||||
key: *mut c_uchar,
|
||||
) -> c_int,
|
||||
pub cipher: extern "C" fn(
|
||||
ctx: *mut c_void,
|
||||
mode: c_int,
|
||||
key: *const c_uchar,
|
||||
key_sz: c_int,
|
||||
iv: *const c_uchar,
|
||||
in1: *const c_uchar,
|
||||
in1_sz: c_int,
|
||||
out: *mut c_uchar,
|
||||
) -> c_int,
|
||||
pub get_cipher: extern "C" fn(ctx: *mut c_void) -> *const c_char,
|
||||
pub get_key_sz: extern "C" fn(ctx: *mut c_void) -> c_int,
|
||||
pub get_iv_sz: extern "C" fn(ctx: *mut c_void) -> c_int,
|
||||
pub get_block_sz: extern "C" fn(ctx: *mut c_void) -> c_int,
|
||||
pub get_hmac_sz: extern "C" fn(ctx: *mut c_void, algorithm: c_int) -> c_int,
|
||||
pub ctx_init: extern "C" fn(ctx: *mut *mut c_void) -> c_int,
|
||||
pub ctx_free: extern "C" fn(ctx: *mut *mut c_void) -> c_int,
|
||||
pub fips_status: extern "C" fn(ctx: *mut c_void) -> c_int,
|
||||
pub get_provider_version: extern "C" fn(ctx: *mut c_void) -> *const c_char,
|
||||
}
|
||||
11
deps/extension/src/sqlite.rs
vendored
Normal file
11
deps/extension/src/sqlite.rs
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
//
|
||||
// Copyright 2024 Signal Messenger, LLC.
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
//
|
||||
|
||||
use core::ffi::c_int;
|
||||
|
||||
// From: sqlite.h
|
||||
|
||||
pub const SQLITE_OK: c_int = 0;
|
||||
pub const SQLITE_ERROR: c_int = 1;
|
||||
24
deps/sqlcipher/LICENSE.md
vendored
Normal file
24
deps/sqlcipher/LICENSE.md
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
Copyright (c) 2008-2023, ZETETIC LLC
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the ZETETIC LLC nor the
|
||||
names of its contributors may be used to endorse or promote products
|
||||
derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY ZETETIC LLC ''AS IS'' AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL ZETETIC LLC BE LIABLE FOR ANY
|
||||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
24
deps/sqlcipher/patches/sqlcipher/custom-crypto-provider.diff
vendored
Normal file
24
deps/sqlcipher/patches/sqlcipher/custom-crypto-provider.diff
vendored
Normal file
@ -0,0 +1,24 @@
|
||||
diff --git a/src/sqlcipher.c b/src/sqlcipher.c
|
||||
index 8be4bc92..9cafc366 100644
|
||||
--- a/src/sqlcipher.c
|
||||
+++ b/src/sqlcipher.c
|
||||
@@ -76,7 +76,8 @@ void sqlite3pager_reset(Pager *pPager);
|
||||
#if !defined (SQLCIPHER_CRYPTO_CC) \
|
||||
&& !defined (SQLCIPHER_CRYPTO_LIBTOMCRYPT) \
|
||||
&& !defined (SQLCIPHER_CRYPTO_NSS) \
|
||||
- && !defined (SQLCIPHER_CRYPTO_OPENSSL)
|
||||
+ && !defined (SQLCIPHER_CRYPTO_OPENSSL) \
|
||||
+ && !defined (SQLCIPHER_CRYPTO_CUSTOM)
|
||||
#define SQLCIPHER_CRYPTO_OPENSSL
|
||||
#endif
|
||||
|
||||
@@ -540,6 +541,9 @@ static void sqlcipher_activate() {
|
||||
#elif defined (SQLCIPHER_CRYPTO_OSSL3)
|
||||
extern int sqlcipher_ossl3_setup(sqlcipher_provider *p);
|
||||
sqlcipher_ossl3_setup(p);
|
||||
+#elif defined (SQLCIPHER_CRYPTO_CUSTOM)
|
||||
+ extern int SQLCIPHER_CRYPTO_CUSTOM(sqlcipher_provider *p);
|
||||
+ SQLCIPHER_CRYPTO_CUSTOM(p);
|
||||
#else
|
||||
#error "NO DEFAULT SQLCIPHER CRYPTO PROVIDER DEFINED"
|
||||
#endif
|
||||
15
deps/sqlcipher/patches/sqlcipher/fix-constant-expression-for-msvc-arm64-6c103aee6f146869.diff
vendored
Normal file
15
deps/sqlcipher/patches/sqlcipher/fix-constant-expression-for-msvc-arm64-6c103aee6f146869.diff
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
diff --git a/src/date.c b/src/date.c
|
||||
index d74cecb..8a609ae 100644
|
||||
--- a/src/date.c
|
||||
+++ b/src/date.c
|
||||
@@ -667,8 +667,8 @@ static const struct {
|
||||
/* 1 */ { 6, "minute", 7.7379e+12, 60.0 },
|
||||
/* 2 */ { 4, "hour", 1.2897e+11, 3600.0 },
|
||||
/* 3 */ { 3, "day", 5373485.0, 86400.0 },
|
||||
- /* 4 */ { 5, "month", 176546.0, 30.0*86400.0 },
|
||||
- /* 5 */ { 4, "year", 14713.0, 365.0*86400.0 },
|
||||
+ /* 4 */ { 5, "month", 176546.0, 2592000.0 },
|
||||
+ /* 5 */ { 4, "year", 14713.0, 31536000.0 },
|
||||
};
|
||||
|
||||
/*
|
||||
108
deps/sqlcipher/sqlcipher.gyp
vendored
Executable file
108
deps/sqlcipher/sqlcipher.gyp
vendored
Executable file
@ -0,0 +1,108 @@
|
||||
# ===
|
||||
# This configuration defines options specific to compiling SQLite3 itself.
|
||||
# Compile-time options are loaded by the auto-generated file "defines.gypi".
|
||||
# Before SQLite3 is compiled, it gets extracted from "sqlcipher.tar.gz".
|
||||
# The --sqlite3 option can be provided to use a custom amalgamation instead.
|
||||
# ===
|
||||
|
||||
{
|
||||
'targets': [
|
||||
{
|
||||
'target_name': 'sqlcipher',
|
||||
'type': 'static_library',
|
||||
'sources': ['sqlite3.c'],
|
||||
'include_dirs': ['.'],
|
||||
'direct_dependent_settings': {
|
||||
'include_dirs': [
|
||||
'.',
|
||||
],
|
||||
},
|
||||
'cflags': ['-std=c99', '-w'],
|
||||
'xcode_settings': {
|
||||
'OTHER_CFLAGS': ['-std=c99'],
|
||||
'WARNING_CFLAGS': ['-w'],
|
||||
},
|
||||
'defines': [
|
||||
'SQLITE_LIKE_DOESNT_MATCH_BLOBS',
|
||||
'SQLITE_THREADSAFE=2',
|
||||
'SQLITE_USE_URI=0',
|
||||
'SQLITE_DEFAULT_MEMSTATUS=0',
|
||||
'SQLITE_OMIT_AUTOINIT',
|
||||
'SQLITE_OMIT_DEPRECATED',
|
||||
'SQLITE_OMIT_DESERIALIZE',
|
||||
'SQLITE_OMIT_GET_TABLE',
|
||||
'SQLITE_OMIT_TCL_VARIABLE',
|
||||
'SQLITE_OMIT_PROGRESS_CALLBACK',
|
||||
'SQLITE_OMIT_SHARED_CACHE',
|
||||
'SQLITE_OMIT_UTF16',
|
||||
'SQLITE_OMIT_COMPLETE',
|
||||
'SQLITE_OMIT_GET_TABLE',
|
||||
'SQLITE_OMIT_AUTHORIZATION',
|
||||
'SQLITE_OMIT_LOAD_EXTENSION',
|
||||
'SQLITE_TRACE_SIZE_LIMIT=32',
|
||||
'SQLITE_DEFAULT_CACHE_SIZE=-16000',
|
||||
'SQLITE_DEFAULT_FOREIGN_KEYS=1',
|
||||
'SQLITE_DEFAULT_WAL_SYNCHRONOUS=1',
|
||||
'SQLITE_DQS=0',
|
||||
'SQLITE_ENABLE_MATH_FUNCTIONS',
|
||||
'SQLITE_ENABLE_DESERIALIZE',
|
||||
'SQLITE_ENABLE_COLUMN_METADATA',
|
||||
'SQLITE_ENABLE_UPDATE_DELETE_LIMIT',
|
||||
'SQLITE_ENABLE_STAT4',
|
||||
'SQLITE_ENABLE_FTS5',
|
||||
'SQLITE_ENABLE_JSON1',
|
||||
'SQLITE_INTROSPECTION_PRAGMAS',
|
||||
|
||||
'SQLCIPHER_CRYPTO_CUSTOM=signal_crypto_provider_setup',
|
||||
|
||||
'HAVE_STDINT_H=1',
|
||||
'HAVE_INT8_T=1',
|
||||
'HAVE_INT16_T=1',
|
||||
'HAVE_INT32_T=1',
|
||||
'HAVE_UINT8_T=1',
|
||||
'HAVE_INT8_T=1',
|
||||
'HAVE_STDINT_H=1',
|
||||
'HAVE_UINT16_T=1',
|
||||
'HAVE_UINT32_T=1',
|
||||
|
||||
# SQLCipher-specific options
|
||||
'SQLITE_HAS_CODEC',
|
||||
'SQLITE_TEMP_STORE=2',
|
||||
'SQLITE_SECURE_DELETE',
|
||||
],
|
||||
'conditions': [
|
||||
['OS == "win"', {
|
||||
'defines': [
|
||||
'WIN32'
|
||||
],
|
||||
'link_settings': {
|
||||
'libraries': [
|
||||
'-luserenv.lib',
|
||||
'-lntdll.lib',
|
||||
'-lbcrypt.lib',
|
||||
'-lcrypt32.lib',
|
||||
'-lsignal_sqlcipher_extension.lib'
|
||||
],
|
||||
'library_dirs': [
|
||||
'<(PRODUCT_DIR)',
|
||||
]
|
||||
}
|
||||
}, {
|
||||
'link_settings': {
|
||||
'libraries': [
|
||||
'<(SHARED_INTERMEDIATE_DIR)/libsignal_sqlcipher_extension.a',
|
||||
]
|
||||
},
|
||||
}],
|
||||
],
|
||||
'configurations': {
|
||||
'Debug': {
|
||||
'msvs_settings': { 'VCCLCompilerTool': { 'RuntimeLibrary': 1 } }, # static debug
|
||||
},
|
||||
'Release': {
|
||||
'msvs_settings': { 'VCCLCompilerTool': { 'RuntimeLibrary': 0 } }, # static release
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
262991
deps/sqlcipher/sqlite3.c
vendored
Normal file
262991
deps/sqlcipher/sqlite3.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
13485
deps/sqlcipher/sqlite3.h
vendored
Normal file
13485
deps/sqlcipher/sqlite3.h
vendored
Normal file
File diff suppressed because it is too large
Load Diff
18
deps/sqlcipher/update.sh
vendored
Executable file
18
deps/sqlcipher/update.sh
vendored
Executable file
@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
set -e
|
||||
set -x
|
||||
|
||||
tag=${1?Pass a valid sqlcipher version as an argument}
|
||||
|
||||
rm -rf .tmp/sqlcipher
|
||||
git clone --branch $tag --filter=blob:none git@github.com:sqlcipher/sqlcipher.git .tmp/sqlcipher
|
||||
cd .tmp/sqlcipher
|
||||
git apply ../../patches/sqlcipher/custom-crypto-provider.diff
|
||||
git apply ../../patches/sqlcipher/fix-constant-expression-for-msvc-arm64-6c103aee6f146869.diff
|
||||
./configure --enable-update-limit
|
||||
make sqlite3.h sqlite3.c sqlite3ext.h shell.c
|
||||
cd -
|
||||
|
||||
cp -rf .tmp/sqlcipher/sqlite3.h ./
|
||||
cp -rf .tmp/sqlcipher/sqlite3.c ./
|
||||
cp -rf .tmp/sqlcipher/LICENSE.md ./
|
||||
35
docker-prebuildify.sh
Executable file
35
docker-prebuildify.sh
Executable file
@ -0,0 +1,35 @@
|
||||
#!/bin/bash
|
||||
# shellcheck disable=SC1004
|
||||
|
||||
#
|
||||
# Copyright 2022 Signal Messenger, LLC.
|
||||
# SPDX-License-Identifier: AGPL-3.0-only
|
||||
#
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
DOCKER_IMAGE=sqlcipher-builder
|
||||
|
||||
IS_TTY=""
|
||||
if [[ -t 0 ]]; then
|
||||
IS_TTY="yes"
|
||||
fi
|
||||
|
||||
# Build specifically using linux/amd64 to make it reproducible.
|
||||
docker build --platform=linux/amd64 --build-arg "UID=${UID:-501}" --build-arg "GID=${GID:-501}" --build-arg "NODE_VERSION=$(cat .nvmrc)" -t ${DOCKER_IMAGE} -f Dockerfile .
|
||||
|
||||
# We build both architectures in the same run action to save on intermediates
|
||||
# (including downloading dependencies)
|
||||
# We run `npm ci` to make sure the correct prebuildify version is used.
|
||||
docker run ${IS_TTY:+ -it} --init --rm -v "${PWD}":/home/sqlcipher/src ${DOCKER_IMAGE} sh -c '
|
||||
cd src &&
|
||||
npm i -g pnpm &&
|
||||
pnpm install --frozen-lockfile &&
|
||||
env CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc \
|
||||
CC=aarch64-linux-gnu-gcc \
|
||||
CXX=aarch64-linux-gnu-g++ \
|
||||
CPATH=/usr/aarch64-linux-gnu/include \
|
||||
PREBUILD_STRIP_BIN=aarch64-linux-gnu-strip \
|
||||
pnpm prebuildify --target $(cat ./.nvmrc) --arch arm64 &&
|
||||
pnpm prebuildify --target $(cat ./.nvmrc) --arch x64
|
||||
'
|
||||
6
docker/apt.conf
Normal file
6
docker/apt.conf
Normal file
@ -0,0 +1,6 @@
|
||||
Acquire::Check-Valid-Until "false";
|
||||
Acquire::Languages "none";
|
||||
Binary::apt-get::Acquire::AllowInsecureRepositories "false";
|
||||
|
||||
APT::Install-Recommends "false";
|
||||
APT::Immediate-Configure "false";
|
||||
3
docker/sources.list
Normal file
3
docker/sources.list
Normal file
@ -0,0 +1,3 @@
|
||||
deb [snapshot=20240829T060900Z] http://archive.ubuntu.com/ubuntu/ focal main universe
|
||||
deb [snapshot=20240829T060900Z] http://archive.ubuntu.com/ubuntu/ focal-updates main universe
|
||||
deb [snapshot=20240829T060900Z] http://security.ubuntu.com/ubuntu focal-security main universe
|
||||
25
eslint.config.mjs
Normal file
25
eslint.config.mjs
Normal file
@ -0,0 +1,25 @@
|
||||
// @ts-check
|
||||
import prettier from 'eslint-config-prettier';
|
||||
import eslint from '@eslint/js';
|
||||
import tseslint from 'typescript-eslint';
|
||||
|
||||
export default tseslint.config(
|
||||
{
|
||||
ignores: ['dist/**', 'docs/**', 'deps/**'],
|
||||
},
|
||||
eslint.configs.recommended,
|
||||
tseslint.configs.recommended,
|
||||
{
|
||||
plugins: {
|
||||
prettier,
|
||||
},
|
||||
rules: {
|
||||
'no-restricted-syntax': 'off',
|
||||
'no-continue': 'off',
|
||||
'class-methods-use-this': 'off',
|
||||
'no-bitwise': 'error',
|
||||
'no-plusplus': 'error',
|
||||
yoda: 'off',
|
||||
},
|
||||
},
|
||||
);
|
||||
546
lib/index.ts
Normal file
546
lib/index.ts
Normal file
@ -0,0 +1,546 @@
|
||||
// Copyright 2025 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import assert from 'node:assert';
|
||||
import { runInThisContext } from 'node:vm';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { join } from 'node:path';
|
||||
import bindings from 'node-gyp-build';
|
||||
|
||||
/** @internal */
|
||||
type NativeDatabase = Readonly<{ __native_db: never }>;
|
||||
|
||||
/** @internal */
|
||||
type NativeStatement = Readonly<{ __native_stmt: never }>;
|
||||
|
||||
// esbuild is configured to replace:
|
||||
// - `import.meta.url` => `undefined` for CJS
|
||||
// - `__dirname` => `undefined` for ESM
|
||||
const ROOT_DIR = import.meta.url
|
||||
? fileURLToPath(new URL('..', import.meta.url))
|
||||
: join(__dirname, '..');
|
||||
|
||||
const addon = bindings<{
|
||||
statementNew(
|
||||
db: NativeDatabase,
|
||||
query: string,
|
||||
persistent: boolean,
|
||||
pluck: boolean,
|
||||
bigint: boolean,
|
||||
): NativeStatement;
|
||||
statementRun<Options extends StatementOptions>(
|
||||
stmt: NativeStatement,
|
||||
params: StatementParameters<Options> | undefined,
|
||||
result: [number, number],
|
||||
): void;
|
||||
statementStep<Options extends StatementOptions>(
|
||||
stmt: NativeStatement,
|
||||
params: StatementParameters<Options> | null | undefined,
|
||||
cache: Array<SqliteValue<Options>> | undefined,
|
||||
isGet: boolean,
|
||||
): Array<SqliteValue<Options>>;
|
||||
statementClose(stmt: NativeStatement): void;
|
||||
|
||||
databaseOpen(path: string): NativeDatabase;
|
||||
databaseExec(db: NativeDatabase, query: string): void;
|
||||
databaseClose(db: NativeDatabase): void;
|
||||
|
||||
signalTokenize(value: string): Array<string>;
|
||||
}>(ROOT_DIR);
|
||||
|
||||
export type RunResult = {
|
||||
/** Total number of affected rows */
|
||||
changes: number;
|
||||
/** Rowid of the last inserted row */
|
||||
lastInsertRowid: number;
|
||||
};
|
||||
|
||||
export type StatementOptions = Readonly<{
|
||||
/**
|
||||
* If `true` - the statement is assumed to be long-lived and some otherwise
|
||||
* costly optimizations are enabled.
|
||||
*
|
||||
* The default value is controlled by DatabaseOptions.
|
||||
*
|
||||
* @see {@link DatabaseOptions}
|
||||
*/
|
||||
persistent?: boolean;
|
||||
|
||||
/**
|
||||
* If `true` - `.get()` returns a single column and `.all()` returns a list
|
||||
* of column values.
|
||||
*
|
||||
* Note: the statement must not result in multi-column rows.
|
||||
*/
|
||||
pluck?: true;
|
||||
|
||||
/**
|
||||
* If `true` - all integers returned by query will be returned as big
|
||||
* integers instead of regular (floating-point) numbers.
|
||||
*/
|
||||
bigint?: true;
|
||||
}>;
|
||||
|
||||
/**
|
||||
* Parameters accepted by `.run()`/`.get()`/`.all()` methods of the statement.
|
||||
*/
|
||||
export type StatementParameters<Options extends StatementOptions> =
|
||||
| ReadonlyArray<SqliteValue<Options>>
|
||||
| Readonly<Record<string, SqliteValue<Options>>>;
|
||||
|
||||
/**
|
||||
* Possible SQL values given statement options.
|
||||
*/
|
||||
export type SqliteValue<Options extends StatementOptions> =
|
||||
| string
|
||||
| Uint8Array
|
||||
| number
|
||||
| null
|
||||
| (Options extends { bigint: true } ? bigint : never);
|
||||
|
||||
/**
|
||||
* Return value type of `.get()` and an element type of `.all()`
|
||||
*/
|
||||
export type RowType<Options extends StatementOptions> = Options extends {
|
||||
pluck: true;
|
||||
}
|
||||
? SqliteValue<Options>
|
||||
: Record<string, SqliteValue<Options>>;
|
||||
|
||||
/**
|
||||
* A compiled SQL statement class.
|
||||
*/
|
||||
class Statement<Options extends StatementOptions = object> {
|
||||
readonly #needsTranslation: boolean;
|
||||
|
||||
#cache: Array<SqliteValue<Options>> | undefined;
|
||||
#createRow: undefined | ((result: unknown) => RowType<Options>);
|
||||
#native: NativeStatement | undefined;
|
||||
#onClose: (() => void) | undefined;
|
||||
|
||||
/** @internal */
|
||||
constructor(
|
||||
db: NativeDatabase,
|
||||
query: string,
|
||||
{ persistent, pluck, bigint }: Options,
|
||||
onClose?: () => void,
|
||||
) {
|
||||
this.#needsTranslation = persistent === true && !pluck;
|
||||
|
||||
this.#native = addon.statementNew(
|
||||
db,
|
||||
query,
|
||||
persistent === true,
|
||||
pluck === true,
|
||||
bigint === true,
|
||||
);
|
||||
|
||||
this.#onClose = onClose;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the statement's query without returning any rows.
|
||||
*
|
||||
* @param params - Parameters to be bound to query placeholders before
|
||||
* executing the statement.
|
||||
* @returns An object with `changes` and `lastInsertedRowid` integers.
|
||||
*/
|
||||
public run(params?: StatementParameters<Options>): RunResult {
|
||||
if (this.#native === undefined) {
|
||||
throw new Error('Statement closed');
|
||||
}
|
||||
const result: [number, number] = [0, 0];
|
||||
this.#checkParams(params);
|
||||
addon.statementRun(this.#native, params, result);
|
||||
return { changes: result[0], lastInsertRowid: result[1] };
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the statement's query and return the first row of the result or
|
||||
* `undefined` if no rows matched.
|
||||
*
|
||||
* @param params - Parameters to be bound to query placeholders before
|
||||
* executing the statement.
|
||||
* @returns A row object or a single column if `pluck: true` is set in the
|
||||
* statement options.
|
||||
*/
|
||||
public get<Row extends RowType<Options> = RowType<Options>>(
|
||||
params?: StatementParameters<Options>,
|
||||
): Row | undefined {
|
||||
if (this.#native === undefined) {
|
||||
throw new Error('Statement closed');
|
||||
}
|
||||
this.#checkParams(params);
|
||||
const result = addon.statementStep(this.#native, params, this.#cache, true);
|
||||
if (result === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
if (!this.#needsTranslation) {
|
||||
return result as unknown as Row | undefined;
|
||||
}
|
||||
const createRow = this.#updateCache(result);
|
||||
return createRow(result) as Row;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the statement's query and return the all rows of the result or
|
||||
* `undefined` if no rows matched.
|
||||
*
|
||||
* @param params - Parameters to be bound to query placeholders before
|
||||
* executing the statement.
|
||||
* @returns A list of row objects or single columns if `pluck: true` is set in
|
||||
* the statement options.
|
||||
*/
|
||||
public all<Row extends RowType<Options> = RowType<Options>>(
|
||||
params?: StatementParameters<Options>,
|
||||
): Array<Row> {
|
||||
if (this.#native === undefined) {
|
||||
throw new Error('Statement closed');
|
||||
}
|
||||
const result = [];
|
||||
this.#checkParams(params);
|
||||
let singleUseParams: StatementParameters<Options> | undefined | null =
|
||||
params;
|
||||
while (true) {
|
||||
const single = addon.statementStep(
|
||||
this.#native,
|
||||
singleUseParams,
|
||||
this.#cache,
|
||||
false,
|
||||
);
|
||||
singleUseParams = null;
|
||||
if (single === undefined) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (!this.#needsTranslation) {
|
||||
result.push(single);
|
||||
continue;
|
||||
}
|
||||
|
||||
const createRow = this.#updateCache(single);
|
||||
result.push(createRow(single));
|
||||
}
|
||||
return result as unknown as Array<Row>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the statement and release the used memory.
|
||||
*/
|
||||
public close(): void {
|
||||
if (this.#native === undefined) {
|
||||
throw new Error('Statement already closed');
|
||||
}
|
||||
addon.statementClose(this.#native);
|
||||
this.#native = undefined;
|
||||
this.#onClose?.();
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
#updateCache(
|
||||
result: Array<SqliteValue<Options>>,
|
||||
): (result: unknown) => RowType<Options> {
|
||||
if (this.#cache === result) {
|
||||
assert(this.#createRow !== undefined);
|
||||
return this.#createRow;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-bitwise
|
||||
const half = result.length >>> 1;
|
||||
const lines = [];
|
||||
for (let i = 0; i < half; i += 1) {
|
||||
lines.push(`${JSON.stringify(result[i])}: value[${half} + ${i}],`);
|
||||
}
|
||||
|
||||
this.#cache = result;
|
||||
const createRow = runInThisContext(`(function createRow(value) {
|
||||
return {
|
||||
${lines.join('\n')}
|
||||
};
|
||||
})`);
|
||||
this.#createRow = createRow;
|
||||
|
||||
return createRow;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
#checkParams(params: StatementParameters<Options> | undefined): void {
|
||||
if (params === undefined) {
|
||||
return;
|
||||
}
|
||||
if (typeof params !== 'object') {
|
||||
throw new TypeError('Params must be either object or array');
|
||||
}
|
||||
if (params === null) {
|
||||
throw new TypeError('Params cannot be null');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export { type Statement };
|
||||
|
||||
/**
|
||||
* Options for `db.pragma()` method.
|
||||
*
|
||||
* If `simple` is `true` - pragma returns the first column of the first row of
|
||||
* the result.
|
||||
*/
|
||||
export type PragmaOptions = Readonly<{
|
||||
simple?: true;
|
||||
}>;
|
||||
|
||||
/**
|
||||
* Result of `db.pragma()` method.
|
||||
*
|
||||
* Either a list of rows a single column from the first row depending on the
|
||||
* options.
|
||||
*/
|
||||
export type PragmaResult<Options extends PragmaOptions> = Options extends {
|
||||
simple: true;
|
||||
}
|
||||
? RowType<{ pluck: true }> | undefined
|
||||
: Array<RowType<object>>;
|
||||
|
||||
/** @internal */
|
||||
type TransactionStatement = Statement<{ persistent: true; pluck: true }>;
|
||||
|
||||
export type DatabaseOptions = Readonly<{
|
||||
/**
|
||||
* If `true` - all statements are persistent by default (unless
|
||||
* `persistent` is set to `false` in `StatementOptions`, and persistent
|
||||
* statements are automatically cached and reused until closed.
|
||||
*
|
||||
* @see {@link StatementOptions}
|
||||
*/
|
||||
cacheStatements?: boolean;
|
||||
}>;
|
||||
|
||||
/**
|
||||
* A sqlite database class.
|
||||
*/
|
||||
export default class Database {
|
||||
#native: NativeDatabase | undefined;
|
||||
#transactionDepth = 0;
|
||||
#isCacheEnabled: boolean;
|
||||
#statementCache = new Map<string, Statement>();
|
||||
|
||||
#transactionStmts:
|
||||
| Readonly<{
|
||||
begin: TransactionStatement;
|
||||
rollback: TransactionStatement;
|
||||
commit: TransactionStatement;
|
||||
|
||||
savepoint: TransactionStatement;
|
||||
rollbackTo: TransactionStatement;
|
||||
release: TransactionStatement;
|
||||
}>
|
||||
| undefined;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param path - The path to the database file or ':memory:'/'' for opening
|
||||
* the in-memory database.
|
||||
*/
|
||||
constructor(path = ':memory:', { cacheStatements }: DatabaseOptions = {}) {
|
||||
if (typeof path !== 'string') {
|
||||
throw new TypeError('Invalid database path');
|
||||
}
|
||||
this.#native = addon.databaseOpen(path);
|
||||
this.#isCacheEnabled = cacheStatements === true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute one or multiple SQL statements in a given `sql` string.
|
||||
*
|
||||
* @param sql - one or multiple SQL statements
|
||||
*/
|
||||
public exec(sql: string): void {
|
||||
if (this.#native === undefined) {
|
||||
throw new Error('Database closed');
|
||||
}
|
||||
if (typeof sql !== 'string') {
|
||||
throw new TypeError('Invalid sql argument');
|
||||
}
|
||||
addon.databaseExec(this.#native, sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compile a single SQL statement.
|
||||
*
|
||||
* @param query - a single SQL statement.
|
||||
* @param options - statement options.
|
||||
* @returns Statement instance.
|
||||
*
|
||||
* @see {@link StatementOptions}
|
||||
*/
|
||||
public prepare<Options extends StatementOptions = StatementOptions>(
|
||||
query: string,
|
||||
options: Options,
|
||||
): Statement<Options>;
|
||||
|
||||
/**
|
||||
* Compile a single SQL statement.
|
||||
*
|
||||
* @param query - a single SQL statement.
|
||||
* @returns Statement instance.
|
||||
*/
|
||||
public prepare(query: string): Statement<object>;
|
||||
|
||||
public prepare<Options extends StatementOptions = StatementOptions>(
|
||||
query: string,
|
||||
options: Options = {} as Options,
|
||||
): Statement<Options> {
|
||||
if (this.#native === undefined) {
|
||||
throw new Error('Database closed');
|
||||
}
|
||||
if (typeof query !== 'string') {
|
||||
throw new TypeError('Invalid query argument');
|
||||
}
|
||||
|
||||
if (!this.#isCacheEnabled || options.persistent === false) {
|
||||
return new Statement(this.#native, query, options);
|
||||
}
|
||||
|
||||
// Persistent statements are cached until closed.
|
||||
const cacheKey = `${options.pluck}:${options.bigint}:${query}`;
|
||||
const cached = this.#statementCache.get(cacheKey);
|
||||
if (cached !== undefined) {
|
||||
return cached;
|
||||
}
|
||||
|
||||
const stmt = new Statement(
|
||||
this.#native,
|
||||
query,
|
||||
{
|
||||
persistent: true,
|
||||
pluck: options.pluck,
|
||||
bigint: options.bigint,
|
||||
} as Options,
|
||||
() => this.#statementCache.delete(cacheKey),
|
||||
);
|
||||
this.#statementCache.set(cacheKey, stmt);
|
||||
return stmt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the database and all associated statements.
|
||||
*/
|
||||
public close(): void {
|
||||
if (this.#native === undefined) {
|
||||
throw new Error('Database already closed');
|
||||
}
|
||||
|
||||
addon.databaseClose(this.#native);
|
||||
this.#native = undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run a pragma statement and return the result.
|
||||
*
|
||||
* @param source - pragma query source
|
||||
* @param options - options to control the return value of `.pragma()`
|
||||
* @returns Either multiple rows returned by the statement, or the first
|
||||
* column of the first row (or `undefined`) if `options` has
|
||||
* `simple: true`.
|
||||
*
|
||||
* @see {@link PragmaOptions}
|
||||
*/
|
||||
public pragma<Options extends PragmaOptions>(
|
||||
source: string,
|
||||
{ simple }: Options,
|
||||
): PragmaResult<Options>;
|
||||
|
||||
/**
|
||||
* Run a pragma statement and return the result.
|
||||
*
|
||||
* @param source - pragma query source
|
||||
* @returns Either multiple rows returned by the statement.
|
||||
*/
|
||||
public pragma(source: string): PragmaResult<object>;
|
||||
|
||||
public pragma<Options extends PragmaOptions = object>(
|
||||
source: string,
|
||||
{ simple }: Options = {} as Options,
|
||||
): PragmaResult<Options> {
|
||||
if (typeof source !== 'string') {
|
||||
throw new TypeError('Invalid pragma argument');
|
||||
}
|
||||
if (simple === true) {
|
||||
const stmt = this.prepare(`PRAGMA ${source}`, { pluck: true });
|
||||
return stmt.get() as unknown as PragmaResult<Options>;
|
||||
}
|
||||
const stmt = this.prepare(`PRAGMA ${source}`);
|
||||
return stmt.all() as unknown as PragmaResult<Options>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap `fn()` in a transaction.
|
||||
*
|
||||
* @param fn - a function to be executed within a transaction.
|
||||
* @returns The value returned by `fn()`.
|
||||
*/
|
||||
public transaction<Params extends [], Result>(
|
||||
fn: (...params: Params) => Result,
|
||||
): typeof fn {
|
||||
return (...params: Params) => {
|
||||
if (this.#transactionStmts === undefined) {
|
||||
const options = { persistent: true as const, pluck: true as const };
|
||||
this.#transactionStmts = {
|
||||
begin: this.prepare('BEGIN', options),
|
||||
rollback: this.prepare('ROLLBACK', options),
|
||||
commit: this.prepare('COMMIT', options),
|
||||
|
||||
savepoint: this.prepare('SAVEPOINT signalappsqlcipher', options),
|
||||
rollbackTo: this.prepare('ROLLBACK TO signalappsqlcipher', options),
|
||||
release: this.prepare('RELEASE signalappsqlcipher', options),
|
||||
};
|
||||
}
|
||||
|
||||
this.#transactionDepth += 1;
|
||||
|
||||
let begin: TransactionStatement;
|
||||
let rollback: TransactionStatement;
|
||||
let commit: TransactionStatement;
|
||||
if (this.#transactionDepth === 1) {
|
||||
({ begin, rollback, commit } = this.#transactionStmts);
|
||||
} else {
|
||||
({
|
||||
savepoint: begin,
|
||||
rollbackTo: rollback,
|
||||
release: commit,
|
||||
} = this.#transactionStmts);
|
||||
}
|
||||
|
||||
begin.run();
|
||||
try {
|
||||
const result = fn(...params);
|
||||
commit.run();
|
||||
return result;
|
||||
} catch (error) {
|
||||
rollback.run();
|
||||
throw error;
|
||||
} finally {
|
||||
this.#transactionDepth -= 1;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Tokenize a given sentence with a Signal-FTS5-Extension.
|
||||
*
|
||||
* @param value - a sentence
|
||||
* @returns a list of word-like tokens.
|
||||
*
|
||||
* @see {@link https://github.com/signalapp/Signal-FTS5-Extension}
|
||||
*/
|
||||
public signalTokenize(value: string): Array<string> {
|
||||
if (typeof value !== 'string') {
|
||||
throw new TypeError('Invalid value');
|
||||
}
|
||||
|
||||
return addon.signalTokenize(value);
|
||||
}
|
||||
}
|
||||
|
||||
export { Database };
|
||||
6
lib/node-gyp-build.d.ts
vendored
Normal file
6
lib/node-gyp-build.d.ts
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
// Copyright 2025 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
declare module 'node-gyp-build' {
|
||||
export default function load<Addon>(dir: string): Addon;
|
||||
}
|
||||
82
package.json
Normal file
82
package.json
Normal file
@ -0,0 +1,82 @@
|
||||
{
|
||||
"name": "@signalapp/sqlcipher",
|
||||
"version": "1.0.0",
|
||||
"description": "A fast N-API-based Node.js addon wrapping sqlcipher and FTS5 segmenting APIs",
|
||||
"homepage": "http://github.com/signalapp/node-sqlcipher.git",
|
||||
"license": "AGPL-3.0-only",
|
||||
"author": {
|
||||
"name": "Signal Messenger, LLC",
|
||||
"email": "support@signal.org"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/signalapp/node-sqlcipher.git"
|
||||
},
|
||||
"type": "module",
|
||||
"main": "dist/index.cjs",
|
||||
"module": "dist/index.mjs",
|
||||
"exports": {
|
||||
"import": "./dist/index.mjs",
|
||||
"require": "./dist/index.cjs"
|
||||
},
|
||||
"types": "dist/lib/index.d.ts",
|
||||
"files": [
|
||||
"dist/index.cjs",
|
||||
"dist/index.mjs",
|
||||
"dist/lib/index.d.ts",
|
||||
"prebuilds",
|
||||
"!prebuilds/**/*.sym",
|
||||
"README.md"
|
||||
],
|
||||
"dependencies": {
|
||||
"node-addon-api": "*",
|
||||
"node-gyp-build": "^4.8.4"
|
||||
},
|
||||
"scripts": {
|
||||
"watch": "tsc --watch",
|
||||
"build": "run-p --print-label build:ts build:esm build:cjs",
|
||||
"build:ts": "tsc",
|
||||
"build:esm": "esbuild --target=node20 --define:__dirname=undefined lib/index.ts --outfile=dist/index.mjs",
|
||||
"build:cjs": "esbuild --target=node20 --define:import.meta.url=undefined lib/index.ts --format=cjs --outfile=dist/index.cjs",
|
||||
"build:docs": "typedoc lib/index.ts --includeVersion",
|
||||
"install": "node-gyp-build",
|
||||
"prebuildify": "prebuildify --strip --napi",
|
||||
"test": "vitest --coverage --pool threads",
|
||||
"format": "run-p --print-label format:c format:js",
|
||||
"format:c": "xcrun clang-format --style=chromium -Werror --verbose -i src/*.cc",
|
||||
"format:js": "prettier --cache --write .",
|
||||
"lint": "run-p --print-label check:eslint check:format",
|
||||
"check:eslint": "eslint --cache .",
|
||||
"check:format": "prettier --cache --check .",
|
||||
"prepare": "run-s build"
|
||||
},
|
||||
"keywords": [
|
||||
"sqlite",
|
||||
"sqlcipher"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@eslint/js": "^9.21.0",
|
||||
"@types/node": "^22.13.9",
|
||||
"@vitest/coverage-v8": "^3.0.8",
|
||||
"esbuild": "^0.25.0",
|
||||
"eslint": "^9.21.0",
|
||||
"eslint-config-prettier": "^10.0.2",
|
||||
"node-gyp": "^11.1.0",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"prebuildify": "^6.0.1",
|
||||
"prettier": "^3.5.3",
|
||||
"typedoc": "^0.27.9",
|
||||
"typescript": "^5.8.2",
|
||||
"typescript-eslint": "^8.26.0",
|
||||
"vitest": "^3.0.8"
|
||||
},
|
||||
"pnpm": {
|
||||
"onlyBuiltDependencies": [
|
||||
"@signalapp/better-sqlite3",
|
||||
"esbuild"
|
||||
],
|
||||
"patchedDependencies": {
|
||||
"prebuildify": "patches/prebuildify.patch"
|
||||
}
|
||||
}
|
||||
}
|
||||
82
patches/prebuildify.patch
Normal file
82
patches/prebuildify.patch
Normal file
@ -0,0 +1,82 @@
|
||||
diff --git a/index.js b/index.js
|
||||
index 7729aaf873cef95e613f356d37cf55909e8b5a6d..9c248ebad8bd3c5ef07c5080da28072fb02b753c 100644
|
||||
--- a/index.js
|
||||
+++ b/index.js
|
||||
@@ -157,7 +157,7 @@ function copySharedLibs (builds, folder, opts, cb) {
|
||||
if (err) return cb()
|
||||
|
||||
var libs = files.filter(function (name) {
|
||||
- return /\.dylib$/.test(name) || /\.so(\.\d+)?$/.test(name) || /\.dll$/.test(name)
|
||||
+ return /\.dylib$/.test(name) || /\.so(\.\d+)?$/.test(name) || /\.dll$/.test(name) || /\.sym$/.test(name)
|
||||
})
|
||||
|
||||
loop()
|
||||
@@ -167,9 +167,17 @@ function copySharedLibs (builds, folder, opts, cb) {
|
||||
var next = libs.shift()
|
||||
if (!next) return cb()
|
||||
|
||||
- strip(path.join(builds, next), opts, function (err) {
|
||||
- if (err) return cb(err)
|
||||
+ if (/\.sym$/.test(next)) {
|
||||
copy(path.join(builds, next), path.join(folder, next), loop)
|
||||
+ return
|
||||
+ }
|
||||
+
|
||||
+ dumpSymbols(path.join(builds, next), opts, function (err) {
|
||||
+ if (err) return cb(err)
|
||||
+ strip(path.join(builds, next), opts, function (err) {
|
||||
+ if (err) return cb(err)
|
||||
+ copy(path.join(builds, next), path.join(folder, next), loop)
|
||||
+ })
|
||||
})
|
||||
}
|
||||
})
|
||||
@@ -241,9 +249,13 @@ function build (target, runtime, opts, cb) {
|
||||
findBuild(opts.output, function (err, output) {
|
||||
if (err) return cb(err)
|
||||
|
||||
- strip(output, opts, function (err) {
|
||||
+ dumpSymbols(output, opts, function (err) {
|
||||
if (err) return cb(err)
|
||||
- cb(null, output)
|
||||
+
|
||||
+ strip(output, opts, function (err) {
|
||||
+ if (err) return cb(err)
|
||||
+ cb(null, output)
|
||||
+ })
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -263,11 +275,31 @@ function findBuild (dir, cb) {
|
||||
})
|
||||
}
|
||||
|
||||
+function dumpSymbols (file, opts, cb) {
|
||||
+ var platform = os.platform()
|
||||
+ if (!opts.strip) return cb()
|
||||
+
|
||||
+ var extensionRe = /\.(dylib|so|dll|node)$/
|
||||
+ var input = platform === 'win32' ? file.replace(extensionRe, '.pdb') : file
|
||||
+ var output = file.replace(extensionRe, '.sym')
|
||||
+ var child = proc.spawn('dump_syms', [input, '-o', output], {
|
||||
+ stdio: 'ignore',
|
||||
+ shell: opts.shell,
|
||||
+ windowsHide: true
|
||||
+ })
|
||||
+
|
||||
+ child.on('exit', function (code) {
|
||||
+ if (code) return cb(spawnError('dymp_syms', code))
|
||||
+ cb()
|
||||
+ })
|
||||
+}
|
||||
+
|
||||
function strip (file, opts, cb) {
|
||||
var platform = os.platform()
|
||||
if (!opts.strip || (platform !== 'darwin' && platform !== 'linux')) return cb()
|
||||
|
||||
- var args = platform === 'darwin' ? [file, '-Sx'] : [file, '--strip-all']
|
||||
+ var args = platform === 'darwin' ?
|
||||
+ [file, '-Sx'] : [file, '--strip-all']
|
||||
var child = proc.spawn(opts.stripBin, args, {
|
||||
stdio: 'ignore',
|
||||
shell: opts.shell,
|
||||
4091
pnpm-lock.yaml
generated
Normal file
4091
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
1
rust-toolchain
Normal file
1
rust-toolchain
Normal file
@ -0,0 +1 @@
|
||||
nightly-2025-02-25
|
||||
707
src/addon.cc
Normal file
707
src/addon.cc
Normal file
@ -0,0 +1,707 @@
|
||||
// Copyright 2025 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
#include <assert.h>
|
||||
#include <list>
|
||||
|
||||
#include "addon.h"
|
||||
|
||||
#include "napi.h"
|
||||
#include "signal-tokenizer.h"
|
||||
#include "sqlite3.h"
|
||||
|
||||
// Signal Tokenizer
|
||||
|
||||
class SignalTokenizerModule {
|
||||
public:
|
||||
static void Destroy(void* p_ctx) {
|
||||
delete static_cast<SignalTokenizerModule*>(p_ctx);
|
||||
}
|
||||
|
||||
static fts5_tokenizer api_object;
|
||||
|
||||
private:
|
||||
static int Create(void* p_ctx, char const**, int, Fts5Tokenizer** pp_out) {
|
||||
SignalTokenizerModule* m = static_cast<SignalTokenizerModule*>(p_ctx);
|
||||
*pp_out = reinterpret_cast<Fts5Tokenizer*>(m);
|
||||
return SQLITE_OK;
|
||||
}
|
||||
|
||||
static void Delete(Fts5Tokenizer* tokenizer) {}
|
||||
};
|
||||
|
||||
fts5_tokenizer SignalTokenizerModule::api_object = {
|
||||
&Create,
|
||||
&Delete,
|
||||
signal_fts5_tokenize,
|
||||
};
|
||||
|
||||
static int SignalTokenizeCallback(void* tokens_ptr,
|
||||
int _flags,
|
||||
char const* token,
|
||||
int len,
|
||||
int _start,
|
||||
int _end) {
|
||||
std::vector<std::string>* tokens =
|
||||
reinterpret_cast<std::vector<std::string>*>(tokens_ptr);
|
||||
tokens->push_back(std::string(token, len));
|
||||
return SQLITE_OK;
|
||||
}
|
||||
|
||||
static Napi::Value SignalTokenize(const Napi::CallbackInfo& info) {
|
||||
auto env = info.Env();
|
||||
|
||||
auto value = info[0].As<Napi::String>();
|
||||
assert(value.IsString());
|
||||
|
||||
auto utf8 = value.Utf8Value();
|
||||
|
||||
std::vector<std::string> tokens;
|
||||
int status =
|
||||
signal_fts5_tokenize(nullptr, reinterpret_cast<void*>(&tokens), 0,
|
||||
utf8.c_str(), utf8.length(), SignalTokenizeCallback);
|
||||
if (status != SQLITE_OK) {
|
||||
NAPI_THROW(Napi::Error::New(env, "Failed to tokenize"), Napi::Value());
|
||||
}
|
||||
|
||||
auto result = Napi::Array::New(env, tokens.size());
|
||||
int i = 0;
|
||||
for (auto& str : tokens) {
|
||||
result[i++] = str.c_str();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Utils
|
||||
|
||||
Napi::Error FormatError(Napi::Env env, const char* format, ...) {
|
||||
va_list args;
|
||||
|
||||
// Get buffer size
|
||||
va_start(args, format);
|
||||
auto size = vsnprintf(nullptr, 0, format, args);
|
||||
va_end(args);
|
||||
|
||||
// Allocate and fill the string
|
||||
auto buf = new char[size + 1];
|
||||
va_start(args, format);
|
||||
vsnprintf(buf, size + 1, format, args);
|
||||
va_end(args);
|
||||
|
||||
auto err = Napi::Error::New(env, std::string(buf, size));
|
||||
delete[] buf;
|
||||
return err;
|
||||
}
|
||||
|
||||
// Database
|
||||
|
||||
Napi::Object Database::Init(Napi::Env env, Napi::Object exports) {
|
||||
exports["databaseOpen"] = Napi::Function::New(env, &Database::Open);
|
||||
exports["databaseClose"] = Napi::Function::New(env, &Database::Close);
|
||||
exports["databaseExec"] = Napi::Function::New(env, &Database::Exec);
|
||||
return exports;
|
||||
}
|
||||
|
||||
Database::Database(Napi::Env env, sqlite3* handle) : handle_(handle) {
|
||||
auto external = Napi::External<Database>::New(
|
||||
env, this, [](Napi::Env env, Database* db) { delete db; });
|
||||
self_ref_ = Napi::Persistent(external);
|
||||
}
|
||||
|
||||
Database::~Database() {
|
||||
// Manually closed
|
||||
if (handle_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
int r = sqlite3_close(handle_);
|
||||
if (r != SQLITE_OK) {
|
||||
fprintf(stderr, "Cleanup: sqlite3_close failure\n");
|
||||
abort();
|
||||
}
|
||||
handle_ = nullptr;
|
||||
}
|
||||
|
||||
Database* Database::FromExternal(const Napi::Value value) {
|
||||
auto external = value.As<Napi::External<Database>>();
|
||||
|
||||
auto db = external.Data();
|
||||
|
||||
if (db->handle_ == nullptr) {
|
||||
NAPI_THROW(Napi::Error::New(value.Env(), "Database closed"), nullptr);
|
||||
}
|
||||
|
||||
return db;
|
||||
}
|
||||
|
||||
Napi::Value Database::Open(const Napi::CallbackInfo& info) {
|
||||
auto env = info.Env();
|
||||
|
||||
auto path = info[0].As<Napi::String>();
|
||||
assert(path.IsString());
|
||||
|
||||
auto path_utf8 = path.Utf8Value();
|
||||
|
||||
int flags = SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE;
|
||||
|
||||
sqlite3* handle = nullptr;
|
||||
int r = sqlite3_open_v2(path_utf8.c_str(), &handle, flags, nullptr);
|
||||
if (r != SQLITE_OK) {
|
||||
NAPI_THROW(FormatError(env, "sqlite open error: %s", sqlite3_errstr(r)),
|
||||
Napi::Value());
|
||||
}
|
||||
|
||||
auto db = new Database(env, handle);
|
||||
|
||||
r = sqlite3_extended_result_codes(handle, 1);
|
||||
if (r != SQLITE_OK) {
|
||||
return db->ThrowSqliteError(env, r);
|
||||
}
|
||||
|
||||
fts5_api* fts5 = db->GetFTS5API(env);
|
||||
|
||||
if (fts5 == nullptr) {
|
||||
return Napi::Value();
|
||||
}
|
||||
SignalTokenizerModule* icu = new SignalTokenizerModule();
|
||||
r = fts5->xCreateTokenizer(fts5, "signal_tokenizer", icu, &icu->api_object,
|
||||
&SignalTokenizerModule::Destroy);
|
||||
if (r != SQLITE_OK) {
|
||||
delete icu;
|
||||
return db->ThrowSqliteError(env, r);
|
||||
}
|
||||
|
||||
return db->self_ref_.Value();
|
||||
}
|
||||
|
||||
Napi::Value Database::Close(const Napi::CallbackInfo& info) {
|
||||
auto env = info.Env();
|
||||
|
||||
auto db = FromExternal(info[0]);
|
||||
if (db == nullptr) {
|
||||
return Napi::Value();
|
||||
}
|
||||
|
||||
// Close all active statements (otherwise `sqlite3_close()` is going to error)
|
||||
for (const auto& stmt : db->statements_) {
|
||||
int r = sqlite3_finalize(stmt->handle_);
|
||||
if (r != SQLITE_OK) {
|
||||
return db->ThrowSqliteError(env, r);
|
||||
}
|
||||
stmt->handle_ = nullptr;
|
||||
stmt->db_ = nullptr;
|
||||
}
|
||||
db->statements_.clear();
|
||||
|
||||
int r = sqlite3_close(db->handle_);
|
||||
if (r != SQLITE_OK) {
|
||||
return db->ThrowSqliteError(env, r);
|
||||
}
|
||||
db->handle_ = nullptr;
|
||||
return Napi::Value();
|
||||
}
|
||||
|
||||
Napi::Value Database::Exec(const Napi::CallbackInfo& info) {
|
||||
auto env = info.Env();
|
||||
|
||||
auto db = FromExternal(info[0]);
|
||||
auto query = info[1].As<Napi::String>();
|
||||
assert(query.IsString());
|
||||
|
||||
if (db == nullptr) {
|
||||
return Napi::Value();
|
||||
}
|
||||
|
||||
auto query_utf8 = query.Utf8Value();
|
||||
|
||||
if (db->handle_ == nullptr) {
|
||||
NAPI_THROW(Napi::Error::New(env, "Database closed"), Napi::Value());
|
||||
}
|
||||
|
||||
int r =
|
||||
sqlite3_exec(db->handle_, query_utf8.c_str(), nullptr, nullptr, nullptr);
|
||||
if (r != SQLITE_OK) {
|
||||
return db->ThrowSqliteError(env, r);
|
||||
}
|
||||
return Napi::Value();
|
||||
}
|
||||
|
||||
Napi::Value Database::ThrowSqliteError(Napi::Env env, int error) {
|
||||
assert(handle_ != nullptr);
|
||||
const char* msg = sqlite3_errmsg(handle_);
|
||||
int offset = sqlite3_error_offset(handle_);
|
||||
int extended = sqlite3_extended_errcode(handle_);
|
||||
if (offset == -1) {
|
||||
NAPI_THROW(FormatError(env, "sqlite error(%d): %s", extended, msg),
|
||||
Napi::Value());
|
||||
} else {
|
||||
NAPI_THROW(FormatError(env, "sqlite error(%d): %s, offset: %d", extended,
|
||||
msg, offset),
|
||||
Napi::Value());
|
||||
}
|
||||
}
|
||||
|
||||
fts5_api* Database::GetFTS5API(Napi::Env env) {
|
||||
sqlite3_stmt* stmt_ = nullptr;
|
||||
|
||||
int r = sqlite3_prepare(handle_, "SELECT fts5(?1)", -1, &stmt_, 0);
|
||||
if (r != SQLITE_OK) {
|
||||
ThrowSqliteError(env, r);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
fts5_api* fts5 = nullptr;
|
||||
sqlite3_bind_pointer(stmt_, 1, reinterpret_cast<void*>(&fts5), "fts5_api_ptr",
|
||||
nullptr);
|
||||
sqlite3_step(stmt_);
|
||||
r = sqlite3_finalize(stmt_);
|
||||
if (r != SQLITE_OK) {
|
||||
ThrowSqliteError(env, r);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
assert(fts5 != nullptr);
|
||||
return fts5;
|
||||
}
|
||||
|
||||
std::list<Statement*>::const_iterator Database::TrackStatement(
|
||||
Statement* stmt) {
|
||||
// Keep database instance alive while any statement is
|
||||
self_ref_.Ref();
|
||||
|
||||
statements_.emplace_back(stmt);
|
||||
auto end = statements_.end();
|
||||
end--;
|
||||
return end;
|
||||
}
|
||||
|
||||
void Database::UntrackStatement(std::list<Statement*>::const_iterator iter) {
|
||||
self_ref_.Unref();
|
||||
statements_.erase(iter);
|
||||
}
|
||||
|
||||
// Statement
|
||||
|
||||
Napi::Object Statement::Init(Napi::Env env, Napi::Object exports) {
|
||||
exports["statementNew"] = Napi::Function::New(env, &Statement::New);
|
||||
exports["statementClose"] = Napi::Function::New(env, &Statement::Close);
|
||||
exports["statementRun"] = Napi::Function::New(env, &Statement::Run);
|
||||
exports["statementStep"] = Napi::Function::New(env, &Statement::Step);
|
||||
return exports;
|
||||
}
|
||||
|
||||
Statement::Statement(Database* db,
|
||||
Napi::Value db_obj,
|
||||
sqlite3_stmt* handle,
|
||||
bool is_persistent,
|
||||
bool is_pluck,
|
||||
bool is_bigint)
|
||||
: db_(db),
|
||||
handle_(handle),
|
||||
is_persistent_(is_persistent),
|
||||
is_pluck_(is_pluck),
|
||||
is_bigint_(is_bigint) {
|
||||
db_iter_ = db_->TrackStatement(this);
|
||||
}
|
||||
|
||||
Statement::~Statement() {
|
||||
// Manually closed
|
||||
if (handle_ == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
int r = sqlite3_finalize(handle_);
|
||||
if (r != SQLITE_OK) {
|
||||
fprintf(stderr, "Cleanup: sqlite3_finalize failure\n");
|
||||
abort();
|
||||
}
|
||||
db_->UntrackStatement(db_iter_);
|
||||
db_ = nullptr;
|
||||
handle_ = nullptr;
|
||||
}
|
||||
|
||||
Napi::Value Statement::New(const Napi::CallbackInfo& info) {
|
||||
auto env = info.Env();
|
||||
|
||||
auto db_external = info[0].As<Napi::External<Database>>();
|
||||
auto query = info[1].As<Napi::String>();
|
||||
auto is_persistent = info[2].As<Napi::Boolean>();
|
||||
auto is_pluck = info[3].As<Napi::Boolean>();
|
||||
auto is_bigint = info[4].As<Napi::Boolean>();
|
||||
|
||||
assert(db_external.IsExternal());
|
||||
assert(query.IsString());
|
||||
assert(is_persistent.IsBoolean());
|
||||
assert(is_pluck.IsBoolean());
|
||||
assert(is_bigint.IsBoolean());
|
||||
|
||||
auto db = db_external.Data();
|
||||
|
||||
auto utf8 = query.Utf8Value();
|
||||
sqlite3_stmt* handle = nullptr;
|
||||
|
||||
const char* tail;
|
||||
int r = sqlite3_prepare_v3(db->handle(), utf8.c_str(), utf8.length(),
|
||||
is_persistent ? SQLITE_PREPARE_PERSISTENT : 0,
|
||||
&handle, &tail);
|
||||
if (r != SQLITE_OK) {
|
||||
return db->ThrowSqliteError(env, r);
|
||||
}
|
||||
|
||||
// Verify no further statements
|
||||
if (HasTail(tail)) {
|
||||
r = sqlite3_finalize(handle);
|
||||
if (r == SQLITE_OK) {
|
||||
NAPI_THROW(Napi::Error::New(env, "Can't prepare more than one statement"),
|
||||
Napi::Value());
|
||||
} else {
|
||||
return db->ThrowSqliteError(env, r);
|
||||
}
|
||||
}
|
||||
|
||||
auto stmt = new Statement(db, db_external, handle, is_persistent, is_pluck,
|
||||
is_bigint);
|
||||
|
||||
return Napi::External<Statement>::New(
|
||||
env, stmt, [](Napi::Env env, Statement* stmt) { delete stmt; });
|
||||
}
|
||||
|
||||
Statement* Statement::FromExternal(const Napi::Value& value) {
|
||||
auto external = value.As<Napi::External<Statement>>();
|
||||
assert(external.IsExternal());
|
||||
|
||||
auto stmt = external.Data();
|
||||
|
||||
if (stmt->handle_ == nullptr) {
|
||||
NAPI_THROW(Napi::Error::New(external.Env(), "Statement closed"), nullptr);
|
||||
}
|
||||
|
||||
return stmt;
|
||||
}
|
||||
|
||||
Napi::Value Statement::Close(const Napi::CallbackInfo& info) {
|
||||
auto env = info.Env();
|
||||
|
||||
auto stmt = FromExternal(info[0]);
|
||||
|
||||
int r = sqlite3_finalize(stmt->handle_);
|
||||
if (r != SQLITE_OK) {
|
||||
return stmt->db_->ThrowSqliteError(env, r);
|
||||
}
|
||||
stmt->handle_ = nullptr;
|
||||
stmt->db_->UntrackStatement(stmt->db_iter_);
|
||||
stmt->db_ = nullptr;
|
||||
return Napi::Value();
|
||||
}
|
||||
|
||||
Napi::Value Statement::Run(const Napi::CallbackInfo& info) {
|
||||
auto env = info.Env();
|
||||
|
||||
auto stmt = FromExternal(info[0]);
|
||||
auto params = info[1];
|
||||
auto result = info[2].As<Napi::Array>();
|
||||
|
||||
assert(params.IsObject() || params.IsUndefined());
|
||||
assert(result.IsArray());
|
||||
|
||||
if (stmt->handle_ == nullptr) {
|
||||
NAPI_THROW(Napi::Error::New(env, "Statement closed"), Napi::Value());
|
||||
}
|
||||
|
||||
if (!stmt->BindParams(env, params)) {
|
||||
// BindParams threw an exception
|
||||
return Napi::Value();
|
||||
}
|
||||
|
||||
int total_changes_before = sqlite3_total_changes(stmt->db_->handle());
|
||||
|
||||
int r = sqlite3_step(stmt->handle_);
|
||||
stmt->Reset();
|
||||
if (r != SQLITE_DONE && r != SQLITE_ROW) {
|
||||
return stmt->db_->ThrowSqliteError(env, r);
|
||||
}
|
||||
|
||||
int total_changes_after = sqlite3_total_changes(stmt->db_->handle());
|
||||
int64_t last_rowid = sqlite3_last_insert_rowid(stmt->db_->handle());
|
||||
|
||||
result[static_cast<uint32_t>(0)] = total_changes_after == total_changes_before
|
||||
? 0
|
||||
: sqlite3_changes(stmt->db_->handle());
|
||||
result[static_cast<uint32_t>(1)] = last_rowid;
|
||||
|
||||
return Napi::Value();
|
||||
}
|
||||
|
||||
Napi::Value Statement::Step(const Napi::CallbackInfo& info) {
|
||||
auto env = info.Env();
|
||||
|
||||
auto stmt = FromExternal(info[0]);
|
||||
auto params = info[1];
|
||||
auto cache = info[2];
|
||||
auto is_get = info[3].As<Napi::Boolean>();
|
||||
|
||||
// Note: `null` is only allowed in `run` to keep the bound parameters
|
||||
assert(params.IsObject() || params.IsUndefined() || params.IsNull());
|
||||
assert(cache.IsArray() || cache.IsUndefined());
|
||||
assert(is_get.IsBoolean());
|
||||
|
||||
if (stmt->handle_ == nullptr) {
|
||||
NAPI_THROW(Napi::Error::New(env, "Statement closed"), Napi::Value());
|
||||
}
|
||||
|
||||
if (!stmt->BindParams(env, params)) {
|
||||
// BindParams threw an exception
|
||||
return Napi::Value();
|
||||
}
|
||||
|
||||
int r = sqlite3_step(stmt->handle_);
|
||||
|
||||
// No more rows
|
||||
if (r == SQLITE_DONE) {
|
||||
stmt->Reset();
|
||||
return Napi::Value();
|
||||
}
|
||||
|
||||
AutoResetStatement _(stmt, is_get.Value());
|
||||
if (r != SQLITE_ROW) {
|
||||
return stmt->db_->ThrowSqliteError(env, r);
|
||||
}
|
||||
|
||||
int column_count = sqlite3_column_count(stmt->handle_);
|
||||
|
||||
// In pluck mode - return the value of the first column
|
||||
if (stmt->is_pluck_) {
|
||||
if (column_count != 1) {
|
||||
NAPI_THROW(Napi::Error::New(env, "Invalid column count for pluck"),
|
||||
Napi::Value());
|
||||
}
|
||||
|
||||
auto result = stmt->GetColumnValue(env, 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
// In non-persistent mode - construct the JS object with column names as keys
|
||||
// and row values as values.
|
||||
if (!stmt->is_persistent_) {
|
||||
auto result = Napi::Object::New(env);
|
||||
for (int i = 0; i < column_count; i++) {
|
||||
result[sqlite3_column_name(stmt->handle_, i)] =
|
||||
stmt->GetColumnValue(env, i);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// Track when the statement gets recompiled due to a schema change. When it
|
||||
// happens - we need to invalidate the cached JS wrapper function that
|
||||
// translates an array of column names and values into a JS object.
|
||||
auto recompiled =
|
||||
sqlite3_stmt_status(stmt->handle_, SQLITE_STMTSTATUS_REPREPARE, 1);
|
||||
|
||||
Napi::Array result;
|
||||
if (recompiled || cache.IsUndefined()) {
|
||||
result = Napi::Array::New(env, 2 * column_count);
|
||||
for (int i = 0; i < column_count; i++) {
|
||||
result[i] = sqlite3_column_name(stmt->handle_, i);
|
||||
}
|
||||
} else {
|
||||
result = cache.As<Napi::Array>();
|
||||
}
|
||||
|
||||
for (int i = 0; i < column_count; i++) {
|
||||
result[column_count + i] = stmt->GetColumnValue(env, i);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool Statement::BindParams(Napi::Env env, Napi::Value params) {
|
||||
int key_count = sqlite3_bind_parameter_count(handle_);
|
||||
|
||||
if (params.IsNull()) {
|
||||
// `.all()` executes `Step()` multiple times, but only binds `params` once.
|
||||
// Passing `null` allows to keep bound params as is until the last `Step()`
|
||||
// where they will get reset.
|
||||
} else if (params.IsUndefined()) {
|
||||
if (key_count == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
NAPI_THROW(FormatError(env, "Expected %d parameters, got 0", key_count),
|
||||
false);
|
||||
} else if (params.IsArray()) {
|
||||
auto list = params.As<Napi::Array>();
|
||||
auto list_len = static_cast<int>(list.Length());
|
||||
if (list_len != key_count) {
|
||||
NAPI_THROW(FormatError(env, "Expected %d parameters, got %d", key_count,
|
||||
list_len),
|
||||
false);
|
||||
}
|
||||
|
||||
for (int i = 1; i <= list_len; i++) {
|
||||
auto name = sqlite3_bind_parameter_name(handle_, i);
|
||||
if (name != nullptr) {
|
||||
NAPI_THROW(FormatError(env, "Unexpected named param %s at %d", name, i),
|
||||
false);
|
||||
}
|
||||
|
||||
auto error = BindParam(env, i, list[i - 1]);
|
||||
if (error != nullptr) {
|
||||
NAPI_THROW(
|
||||
FormatError(env, "Failed to bind param %d, error %s", i, error),
|
||||
false);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
auto obj = params.As<Napi::Object>();
|
||||
|
||||
for (int i = 1; i <= key_count; i++) {
|
||||
auto name = sqlite3_bind_parameter_name(handle_, i);
|
||||
if (name == nullptr) {
|
||||
NAPI_THROW(FormatError(env, "Unexpected anonymous param at %d", i),
|
||||
false);
|
||||
}
|
||||
|
||||
// Skip "$"
|
||||
name = name + 1;
|
||||
auto value = obj[name];
|
||||
auto error = BindParam(env, i, value);
|
||||
if (error != nullptr) {
|
||||
NAPI_THROW(
|
||||
FormatError(env, "Failed to bind param %s, error %s", name, error),
|
||||
false);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
const char* Statement::BindParam(Napi::Env env, int column, Napi::Value param) {
|
||||
int r;
|
||||
switch (param.Type()) {
|
||||
case napi_null:
|
||||
r = sqlite3_bind_null(handle_, column);
|
||||
break;
|
||||
case napi_number:
|
||||
r = sqlite3_bind_double(handle_, column,
|
||||
param.As<Napi::Number>().DoubleValue());
|
||||
break;
|
||||
case napi_string: {
|
||||
auto val = napi_value(param.As<Napi::String>());
|
||||
|
||||
size_t length;
|
||||
napi_status status =
|
||||
napi_get_value_string_utf8(env, val, nullptr, 0, &length);
|
||||
if (status != napi_ok) {
|
||||
return "failed to get string length";
|
||||
}
|
||||
|
||||
char* data = new char[length + 1];
|
||||
status = napi_get_value_string_utf8(env, val, data, length + 1, nullptr);
|
||||
if (status != napi_ok) {
|
||||
delete[] data;
|
||||
return "failed to copy string data";
|
||||
}
|
||||
|
||||
r = sqlite3_bind_text(handle_, column, data, length, DestroyString);
|
||||
break;
|
||||
}
|
||||
case napi_bigint: {
|
||||
bool lossless;
|
||||
auto value = param.As<Napi::BigInt>().Int64Value(&lossless);
|
||||
if (!lossless) {
|
||||
return "failed to convert bigint to int64";
|
||||
}
|
||||
r = sqlite3_bind_int64(handle_, column, value);
|
||||
break;
|
||||
}
|
||||
case napi_object:
|
||||
if (param.IsTypedArray()) {
|
||||
auto val = param.As<Napi::TypedArray>();
|
||||
|
||||
auto data = val.ArrayBuffer();
|
||||
const uint8_t* view = reinterpret_cast<const uint8_t*>(data.Data());
|
||||
|
||||
r = sqlite3_bind_blob(handle_, column, view + val.ByteOffset(),
|
||||
val.ByteLength(), SQLITE_TRANSIENT);
|
||||
break;
|
||||
} else {
|
||||
return "unexpected type `object`";
|
||||
}
|
||||
case napi_boolean:
|
||||
return "unexpected type `boolean`";
|
||||
case napi_external:
|
||||
return "unexpected type `external`";
|
||||
case napi_function:
|
||||
return "unexpected type `function`";
|
||||
case napi_undefined:
|
||||
return "unexpected type `undefined`";
|
||||
case napi_symbol:
|
||||
return "unexpected type `symbol`";
|
||||
default:
|
||||
return "unknown parameter type";
|
||||
}
|
||||
if (r != SQLITE_OK) {
|
||||
return sqlite3_errmsg(db_->handle());
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void Statement::DestroyString(void* param) {
|
||||
delete[] reinterpret_cast<char*>(param);
|
||||
}
|
||||
|
||||
Napi::Value Statement::GetColumnValue(Napi::Env env, int column) {
|
||||
int type = sqlite3_column_type(handle_, column);
|
||||
switch (type) {
|
||||
case SQLITE_INTEGER: {
|
||||
auto val = sqlite3_column_int64(handle_, column);
|
||||
if (is_bigint_) {
|
||||
return Napi::BigInt::New(env, static_cast<int64_t>(val));
|
||||
}
|
||||
if (static_cast<int64_t>(INT32_MIN) <= val &&
|
||||
val <= static_cast<int64_t>(INT32_MAX)) {
|
||||
napi_value n_value;
|
||||
NAPI_THROW_IF_FAILED(
|
||||
env, napi_create_int32(env, static_cast<int32_t>(val), &n_value),
|
||||
Napi::Value());
|
||||
return Napi::Value(env, n_value);
|
||||
} else {
|
||||
return Napi::Number::New(env, val);
|
||||
}
|
||||
}
|
||||
case SQLITE_TEXT:
|
||||
return Napi::String::New(
|
||||
env,
|
||||
reinterpret_cast<const char*>(sqlite3_column_text(handle_, column)),
|
||||
sqlite3_column_bytes(handle_, column));
|
||||
case SQLITE_FLOAT:
|
||||
return Napi::Number::New(env, sqlite3_column_double(handle_, column));
|
||||
case SQLITE_BLOB:
|
||||
return Napi::Buffer<uint8_t>::Copy(
|
||||
env,
|
||||
reinterpret_cast<const uint8_t*>(
|
||||
sqlite3_column_blob(handle_, column)),
|
||||
sqlite3_column_bytes(handle_, column));
|
||||
case SQLITE_NULL:
|
||||
return env.Null();
|
||||
}
|
||||
return Napi::Value();
|
||||
}
|
||||
|
||||
AutoResetStatement::~AutoResetStatement() {
|
||||
if (enabled_) {
|
||||
stmt_->Reset();
|
||||
}
|
||||
}
|
||||
|
||||
Napi::Object Init(Napi::Env env, Napi::Object exports) {
|
||||
sqlite3_initialize();
|
||||
|
||||
Database::Init(env, exports);
|
||||
Statement::Init(env, exports);
|
||||
exports["signalTokenize"] = Napi::Function::New(env, &SignalTokenize);
|
||||
return exports;
|
||||
}
|
||||
|
||||
NODE_API_MODULE(node_sqlcipher, Init)
|
||||
159
src/addon.h
Normal file
159
src/addon.h
Normal file
@ -0,0 +1,159 @@
|
||||
// Copyright 2025 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
#ifndef SRC_ADDON_H_
|
||||
|
||||
#include <list>
|
||||
|
||||
#include "napi.h"
|
||||
#include "sqlite3.h"
|
||||
|
||||
class Statement;
|
||||
|
||||
class Database {
|
||||
public:
|
||||
static Napi::Object Init(Napi::Env env, Napi::Object exports);
|
||||
|
||||
Napi::Value ThrowSqliteError(Napi::Env env, int error);
|
||||
|
||||
std::list<Statement*>::const_iterator TrackStatement(Statement* stmt);
|
||||
void UntrackStatement(std::list<Statement*>::const_iterator);
|
||||
|
||||
inline sqlite3* handle() { return handle_; }
|
||||
|
||||
protected:
|
||||
Database(Napi::Env env, sqlite3* handle);
|
||||
~Database();
|
||||
|
||||
static Database* FromExternal(const Napi::Value value);
|
||||
static Napi::Value Open(const Napi::CallbackInfo& info);
|
||||
static Napi::Value Close(const Napi::CallbackInfo& info);
|
||||
static Napi::Value Exec(const Napi::CallbackInfo& info);
|
||||
|
||||
fts5_api* GetFTS5API(Napi::Env env);
|
||||
|
||||
sqlite3* handle_;
|
||||
|
||||
// A reference to the `external` object. Initially only a weak reference, it
|
||||
// gets it's ref count incremented on every `TrackStatement` call (new
|
||||
// statement creation) and decremented on every `UntrackStatement` (statement
|
||||
// close or GC/destructor).
|
||||
Napi::Reference<Napi::External<Database>> self_ref_;
|
||||
|
||||
// All currently open statements for this database. Used to close all open
|
||||
// statements when closing the database.
|
||||
std::list<Statement*> statements_;
|
||||
};
|
||||
|
||||
class AutoResetStatement {
|
||||
public:
|
||||
AutoResetStatement(Statement* stmt, bool enabled)
|
||||
: stmt_(stmt), enabled_(enabled) {}
|
||||
|
||||
~AutoResetStatement();
|
||||
|
||||
private:
|
||||
Statement* stmt_;
|
||||
bool enabled_;
|
||||
};
|
||||
|
||||
class Statement {
|
||||
public:
|
||||
static Napi::Object Init(Napi::Env env, Napi::Object exports);
|
||||
|
||||
Statement(Database* db,
|
||||
Napi::Value db_obj,
|
||||
sqlite3_stmt* handle,
|
||||
bool is_persistent,
|
||||
bool is_pluck,
|
||||
bool is_bigint);
|
||||
|
||||
~Statement();
|
||||
|
||||
inline void Reset() {
|
||||
sqlite3_reset(handle_);
|
||||
sqlite3_clear_bindings(handle_);
|
||||
}
|
||||
|
||||
// Check if the remainder of the SQL query string has any additional
|
||||
// statements.
|
||||
//
|
||||
// If return value `false` - only whitespace and comments remain.
|
||||
//
|
||||
// Note: we use `rfind(..., 0)` for effectively a prefix check.
|
||||
static inline bool HasTail(std::string const& tail) {
|
||||
std::string p(tail);
|
||||
while (!p.empty()) {
|
||||
auto ch = p.front();
|
||||
// Various whitespace or statement separator
|
||||
if (std::isspace(ch) || ch == ';') {
|
||||
p = p.substr(1);
|
||||
|
||||
} else if (p.rfind("--", 0) == 0) {
|
||||
// Line comment: "--"
|
||||
p = p.substr(2);
|
||||
|
||||
// Skip until the end of the line
|
||||
auto end = p.find("\n");
|
||||
if (end == p.npos) {
|
||||
return false;
|
||||
}
|
||||
|
||||
p = p.substr(end + 1);
|
||||
|
||||
} else if (p.rfind("/*", 0) == 0) {
|
||||
// Block comment
|
||||
p = p.substr(2);
|
||||
|
||||
auto end = p.find("*/");
|
||||
if (end == p.npos) {
|
||||
return false;
|
||||
}
|
||||
|
||||
p = p.substr(end + 2);
|
||||
} else {
|
||||
// Not whitespace or comments
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Napi::Value Finalize(Napi::Env env);
|
||||
|
||||
protected:
|
||||
static Napi::Value New(const Napi::CallbackInfo& info);
|
||||
static Statement* FromExternal(const Napi::Value& value);
|
||||
static Napi::Value Close(const Napi::CallbackInfo& info);
|
||||
static Napi::Value Run(const Napi::CallbackInfo& info);
|
||||
static Napi::Value Step(const Napi::CallbackInfo& info);
|
||||
|
||||
bool BindParams(Napi::Env env, Napi::Value params);
|
||||
|
||||
const char* BindParam(Napi::Env env, int column, Napi::Value param);
|
||||
|
||||
static void DestroyString(void* param);
|
||||
|
||||
Napi::Value GetColumnValue(Napi::Env env, int column);
|
||||
|
||||
Database* db_;
|
||||
sqlite3_stmt* handle_;
|
||||
|
||||
// If `true` - `Step()` uses provided cache array and returns raw column names
|
||||
// and values instead of constructing JS objects in C++.
|
||||
bool is_persistent_;
|
||||
|
||||
// If `true` - `Step()` returns the first column value instead of full row.
|
||||
bool is_pluck_;
|
||||
|
||||
// If `true` - `Step()` returns BigInt instance for all INTEGER column values
|
||||
bool is_bigint_;
|
||||
|
||||
// Iterator into the Database's `statements_` `std::list`. Used for untracking
|
||||
// the statement.
|
||||
std::list<Statement*>::const_iterator db_iter_;
|
||||
|
||||
friend class Database;
|
||||
};
|
||||
|
||||
#endif // SRC_ADDON_H_
|
||||
67
test/disk.test.ts
Normal file
67
test/disk.test.ts
Normal file
@ -0,0 +1,67 @@
|
||||
import { mkdtemp, rm } from 'node:fs/promises';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { join } from 'node:path';
|
||||
import { expect, test, beforeEach, afterEach } from 'vitest';
|
||||
|
||||
import Database from '../lib/index.js';
|
||||
|
||||
let dir: string;
|
||||
let db: Database;
|
||||
|
||||
beforeEach(async () => {
|
||||
dir = await mkdtemp(join(tmpdir(), 'sqlcipher-'));
|
||||
db = new Database(join(dir, 'db.sqlite'));
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
try {
|
||||
db.close();
|
||||
} finally {
|
||||
try {
|
||||
await rm(dir, { recursive: true });
|
||||
} catch {
|
||||
// Best-effort
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test.each([[false], [true]])('ciphertext=%j', (ciphertext) => {
|
||||
if (ciphertext) {
|
||||
db.pragma(`key = 'hello world'`);
|
||||
}
|
||||
db.pragma('journal_mode = WAL');
|
||||
db.pragma('synchronous = FULL');
|
||||
|
||||
db.exec(`
|
||||
CREATE TABLE t (
|
||||
id INTEGER PRIMARY KEY NOT NULL,
|
||||
name TEXT NOT NULL,
|
||||
value TEXT NOT NULL
|
||||
);
|
||||
`);
|
||||
|
||||
const stmt = db.prepare(
|
||||
`INSERT INTO t (name, value) VALUES ($name, $value) RETURNING id`,
|
||||
{ pluck: true },
|
||||
);
|
||||
|
||||
const id = db.transaction(() => {
|
||||
const result = stmt.get<number>({ name: 'Adam', value: 'Sandler' });
|
||||
expect(result).not.toBeUndefined();
|
||||
if (result === undefined) {
|
||||
throw new Error('Pacify typescript');
|
||||
}
|
||||
|
||||
return result;
|
||||
})();
|
||||
|
||||
const row = db
|
||||
.prepare(
|
||||
`
|
||||
SELECT name, value FROM t WHERE id IS $id
|
||||
`,
|
||||
)
|
||||
.get({ id });
|
||||
|
||||
expect(row).toEqual({ name: 'Adam', value: 'Sandler' });
|
||||
});
|
||||
446
test/memory.test.ts
Normal file
446
test/memory.test.ts
Normal file
@ -0,0 +1,446 @@
|
||||
import { describe, expect, test, beforeEach, afterEach } from 'vitest';
|
||||
|
||||
import Database from '../lib/index.js';
|
||||
|
||||
const rows = [
|
||||
{
|
||||
a: 1,
|
||||
b: '123',
|
||||
c: Buffer.from('abba', 'hex'),
|
||||
},
|
||||
{
|
||||
a: 2,
|
||||
b: '456',
|
||||
c: Buffer.from('dada', 'hex'),
|
||||
},
|
||||
{
|
||||
a: 3,
|
||||
b: '789',
|
||||
c: null,
|
||||
},
|
||||
];
|
||||
|
||||
let db: Database;
|
||||
beforeEach(() => {
|
||||
db = new Database();
|
||||
|
||||
db.exec(`
|
||||
CREATE TABLE t (a INTEGER, b TEXT, c BLOB);
|
||||
|
||||
INSERT INTO t (a, b, c) VALUES
|
||||
(1, '123', x'abba'),
|
||||
(2, '456', x'dada'),
|
||||
(3, '789', NULL);
|
||||
`);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
db.close();
|
||||
});
|
||||
|
||||
test('db.close', () => {
|
||||
db.close();
|
||||
expect(() => db.close()).toThrowError('Database already closed');
|
||||
|
||||
expect(() => db.exec('')).toThrowError('Database closed');
|
||||
expect(() => db.prepare('')).toThrowError('Database closed');
|
||||
|
||||
// Just to fix afterEach
|
||||
db = new Database();
|
||||
});
|
||||
|
||||
test('statement.close', () => {
|
||||
const stmt = db.prepare('SELECT 1');
|
||||
stmt.close();
|
||||
|
||||
expect(() => stmt.close()).toThrowError('Statement already closed');
|
||||
});
|
||||
|
||||
test('statement.run', () => {
|
||||
expect(db.prepare('SELECT * FROM t').run()).toEqual({
|
||||
changes: 0,
|
||||
lastInsertRowid: 3,
|
||||
});
|
||||
|
||||
expect(
|
||||
db.prepare(`INSERT INTO t (a, b, c) VALUES (4, '4', NULL)`).run(),
|
||||
).toEqual({
|
||||
changes: 1,
|
||||
lastInsertRowid: 4,
|
||||
});
|
||||
});
|
||||
|
||||
test('statement.run after close', () => {
|
||||
const stmt = db.prepare('SELECT 1');
|
||||
stmt.close();
|
||||
expect(() => stmt.run()).toThrowError('Statement closed');
|
||||
});
|
||||
|
||||
test('statement.get', () => {
|
||||
expect(
|
||||
db
|
||||
.prepare('SELECT * FROM t')
|
||||
.get<{ a: number; b: string; c: Uint8Array }>(),
|
||||
).toEqual(rows[0]);
|
||||
});
|
||||
|
||||
test('statement.get after close', () => {
|
||||
const stmt = db.prepare('SELECT 1');
|
||||
stmt.close();
|
||||
expect(() => stmt.get()).toThrowError('Statement closed');
|
||||
});
|
||||
|
||||
test('statement.all', () => {
|
||||
expect(db.prepare('SELECT * FROM t').all()).toEqual(rows);
|
||||
});
|
||||
|
||||
test('statement.all after close', () => {
|
||||
const stmt = db.prepare('SELECT 1');
|
||||
stmt.close();
|
||||
expect(() => stmt.all()).toThrowError('Statement closed');
|
||||
});
|
||||
|
||||
test('statement.get persistent=true', () => {
|
||||
expect(db.prepare('SELECT * FROM t', { persistent: true }).get()).toEqual(
|
||||
rows[0],
|
||||
);
|
||||
});
|
||||
|
||||
test('statement.get persistent=true with undefined', () => {
|
||||
db.exec('DELETE FROM t');
|
||||
expect(
|
||||
db.prepare('SELECT * FROM t', { persistent: true }).get(),
|
||||
).toBeUndefined();
|
||||
});
|
||||
|
||||
test('statement.all persistent=true', () => {
|
||||
expect(db.prepare('SELECT * FROM t', { persistent: true }).all()).toEqual(
|
||||
rows,
|
||||
);
|
||||
});
|
||||
|
||||
test('statement.get pluck=true', () => {
|
||||
expect(db.prepare('SELECT a FROM t', { pluck: true }).get()).toEqual(1);
|
||||
});
|
||||
|
||||
test('statement.all pluck=true', () => {
|
||||
expect(db.prepare('SELECT a FROM t', { pluck: true }).all()).toEqual([
|
||||
1, 2, 3,
|
||||
]);
|
||||
});
|
||||
|
||||
test('statement.get persistent=true, pluck=true', () => {
|
||||
expect(
|
||||
db.prepare('SELECT a FROM t', { persistent: true, pluck: true }).get(),
|
||||
).toEqual(1);
|
||||
});
|
||||
|
||||
test('statement.all persistent=true, pluck=true', () => {
|
||||
expect(
|
||||
db.prepare('SELECT a FROM t', { persistent: true, pluck: true }).all(),
|
||||
).toEqual([1, 2, 3]);
|
||||
});
|
||||
|
||||
test('pragma', () => {
|
||||
db.pragma('user_version = 123');
|
||||
expect(db.pragma('user_version')).toEqual([{ user_version: 123 }]);
|
||||
});
|
||||
|
||||
test('smple pragma', () => {
|
||||
db.pragma('user_version = 123');
|
||||
expect(db.pragma('user_version', { simple: true })).toEqual(123);
|
||||
});
|
||||
|
||||
test('too many columns for pluck', () => {
|
||||
const stmt = db.prepare('SELECT * FROM t', { pluck: true });
|
||||
expect(() => stmt.get()).toThrowError('Invalid column count for pluck');
|
||||
});
|
||||
|
||||
test('persistent statement recompilation', () => {
|
||||
const stmt = db.prepare('SELECT * FROM t', { persistent: true });
|
||||
expect(stmt.get()).toEqual(rows[0]);
|
||||
|
||||
db.exec(`ALTER TABLE t ADD COLUMN d TEXT DEFAULT 'hello'`);
|
||||
|
||||
expect(stmt.get()).toEqual({
|
||||
a: 1,
|
||||
b: '123',
|
||||
c: Buffer.from('abba', 'hex'),
|
||||
d: 'hello',
|
||||
});
|
||||
});
|
||||
|
||||
describe('list parameters', () => {
|
||||
test('correct count', () => {
|
||||
expect(db.prepare('SELECT * FROM t WHERE a > ?').get([2])).toEqual(rows[2]);
|
||||
});
|
||||
|
||||
test('incorrect count', () => {
|
||||
const stmt = db.prepare('SELECT * FROM t WHERE a > ?');
|
||||
expect(() => stmt.get([2, 3])).toThrowError('Expected 1 parameters, got 2');
|
||||
});
|
||||
|
||||
test('absent parameters', () => {
|
||||
const stmt = db.prepare('SELECT * FROM t WHERE a > ?');
|
||||
expect(() => stmt.get()).toThrowError('Expected 1 parameters, got 0');
|
||||
});
|
||||
|
||||
test('object parameters', () => {
|
||||
const stmt = db.prepare('SELECT * FROM t WHERE a > ?');
|
||||
expect(() => stmt.get({})).toThrowError('Unexpected anonymous param at 1');
|
||||
});
|
||||
|
||||
test('against named parameters', () => {
|
||||
const stmt = db.prepare('SELECT * FROM t WHERE a > $a');
|
||||
expect(() => stmt.get([2])).toThrowError('Unexpected named param $a at 1');
|
||||
});
|
||||
});
|
||||
|
||||
describe('object parameters', () => {
|
||||
test('correct count', () => {
|
||||
expect(db.prepare('SELECT * FROM t WHERE a > $a').get({ a: 2 })).toEqual(
|
||||
rows[2],
|
||||
);
|
||||
});
|
||||
|
||||
test('undefined param', () => {
|
||||
const stmt = db.prepare('SELECT * FROM t WHERE a > $a');
|
||||
expect(() => stmt.get({})).toThrowError(
|
||||
'Failed to bind param a, error unexpected type `undefined`',
|
||||
);
|
||||
});
|
||||
|
||||
test('absent parameters', () => {
|
||||
const stmt = db.prepare('SELECT * FROM t WHERE a > $a');
|
||||
expect(() => stmt.get()).toThrowError('Expected 1 parameters, got 0');
|
||||
});
|
||||
|
||||
test('against anonymous parameters', () => {
|
||||
const stmt = db.prepare('SELECT * FROM t WHERE a > ?');
|
||||
expect(() => stmt.get({ a: 1 })).toThrowError(
|
||||
'Unexpected anonymous param at 1',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('tail', () => {
|
||||
test('allow trailing --', () => {
|
||||
db.prepare('SELECT 1; --');
|
||||
});
|
||||
|
||||
test('allow trailing /*', () => {
|
||||
db.prepare('SELECT 1; /*');
|
||||
});
|
||||
|
||||
test('disallow statement after comments', () => {
|
||||
expect(() =>
|
||||
db.prepare('SELECT 1; -- asdfasdf\n/*\n*/SELECT 2'),
|
||||
).toThrowError("Can't prepare more than one statement");
|
||||
});
|
||||
|
||||
test('disallow trailing /', () => {
|
||||
expect(() => db.prepare('SELECT 1; /')).toThrowError(
|
||||
"Can't prepare more than one statement",
|
||||
);
|
||||
});
|
||||
|
||||
test('disallow trailing -', () => {
|
||||
expect(() => db.prepare('SELECT 1; -')).toThrowError(
|
||||
"Can't prepare more than one statement",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
test('invalid null params', () => {
|
||||
const stmt = db.prepare('SELECT 1');
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
expect(() => stmt.get(null as any)).toThrowError('Params cannot be null');
|
||||
});
|
||||
|
||||
test('invalid params', () => {
|
||||
const stmt = db.prepare('SELECT 1');
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
expect(() => stmt.get(123 as any)).toThrowError(
|
||||
'Params must be either object or array',
|
||||
);
|
||||
});
|
||||
|
||||
test('invalid database path', () => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
expect(() => new Database(123 as any)).toThrowError('Invalid database path');
|
||||
});
|
||||
|
||||
test('invalid exec query', () => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
expect(() => db.exec(123 as any)).toThrowError('Invalid sql argument');
|
||||
});
|
||||
|
||||
test('invalid prepare query', () => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
expect(() => db.prepare(123 as any)).toThrowError('Invalid query argument');
|
||||
});
|
||||
|
||||
test('invalid pragma query', () => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
expect(() => db.pragma(123 as any)).toThrowError('Invalid pragma argument');
|
||||
});
|
||||
|
||||
describe('transaction', () => {
|
||||
test('commit', () => {
|
||||
db.transaction(() => {
|
||||
db.prepare(`INSERT INTO t (a, b) VALUES (42, 'success')`).run();
|
||||
})();
|
||||
|
||||
expect(
|
||||
db.prepare('SELECT b FROM t WHERE a IS 42', { pluck: true }).get(),
|
||||
).toEqual('success');
|
||||
});
|
||||
|
||||
test('rollback', () => {
|
||||
db.prepare(`INSERT INTO t (a, b) VALUES (42, 'success')`).run();
|
||||
|
||||
expect(() =>
|
||||
db.transaction(() => {
|
||||
db.prepare(`UPDATE t SET b = 'fail' WHERE A is 42`).run();
|
||||
throw new Error('rollback');
|
||||
})(),
|
||||
).toThrowError('rollback');
|
||||
|
||||
expect(
|
||||
db.prepare('SELECT b FROM t WHERE a IS 42', { pluck: true }).get(),
|
||||
).toEqual('success');
|
||||
});
|
||||
|
||||
test('nested rollback', () => {
|
||||
db.transaction(() => {
|
||||
db.prepare(`INSERT INTO t (a, b) VALUES (42, 'success')`).run();
|
||||
|
||||
expect(() =>
|
||||
db.transaction(() => {
|
||||
db.prepare(`UPDATE t SET b = 'fail' WHERE A is 42`).run();
|
||||
throw new Error('rollback');
|
||||
})(),
|
||||
).toThrowError('rollback');
|
||||
})();
|
||||
|
||||
expect(
|
||||
db.prepare('SELECT b FROM t WHERE a IS 42', { pluck: true }).get(),
|
||||
).toEqual('success');
|
||||
});
|
||||
});
|
||||
|
||||
test('single-copy strings', () => {
|
||||
db.exec(`
|
||||
DROP TABLE t;
|
||||
|
||||
CREATE TABLE t (rowid INTEGER PRIMARY KEY NOT NULL, value TEXT NOT NULL);
|
||||
|
||||
INSERT INTO t (value) VALUES ('0a'), ('0a'), ('0a'), ('0a'), ('0a');
|
||||
`);
|
||||
|
||||
expect(
|
||||
db
|
||||
.prepare('SELECT rowid FROM t WHERE value IS ?', {
|
||||
pluck: true,
|
||||
})
|
||||
.all(['0a']),
|
||||
).toEqual([1, 2, 3, 4, 5]);
|
||||
});
|
||||
|
||||
test('number mode', () => {
|
||||
db.exec(
|
||||
`
|
||||
DELETE FROM t;
|
||||
-- MAX_INT64
|
||||
INSERT INTO t (a) VALUES (1152921504606846975);
|
||||
`,
|
||||
);
|
||||
|
||||
expect(db.prepare('SELECT a FROM t', { pluck: true }).get()).toEqual(
|
||||
1152921504606847000,
|
||||
);
|
||||
});
|
||||
|
||||
test('bigint mode', () => {
|
||||
db.exec(`
|
||||
DELETE FROM t;
|
||||
`);
|
||||
|
||||
const n = 0x7fff_ffff_ffff_ffffn;
|
||||
|
||||
db.prepare(
|
||||
`
|
||||
INSERT INTO t (a) VALUES (?);
|
||||
`,
|
||||
{ bigint: true },
|
||||
).run([n]);
|
||||
|
||||
expect(
|
||||
db.prepare('SELECT a FROM t', { pluck: true, bigint: true }).get(),
|
||||
).toEqual(n);
|
||||
});
|
||||
|
||||
test('signalTokenize', () => {
|
||||
expect(db.signalTokenize('a b c')).toEqual(['a', 'b', 'c']);
|
||||
});
|
||||
|
||||
test('invalid argument for signalTokenize', () => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
expect(() => db.signalTokenize(123 as any)).toThrowError('Invalid value');
|
||||
});
|
||||
|
||||
test('does not cache statements', () => {
|
||||
expect(db.prepare('SELECT 1')).not.toBe(db.prepare('SELECT 1'));
|
||||
});
|
||||
|
||||
describe('statement cache', () => {
|
||||
let cachedDb: Database;
|
||||
beforeEach(() => {
|
||||
cachedDb = new Database(':memory:', { cacheStatements: true });
|
||||
|
||||
cachedDb.exec(`
|
||||
CREATE TABLE t (a INTEGER, b TEXT, c BLOB);
|
||||
|
||||
INSERT INTO t (a, b, c) VALUES
|
||||
(1, '123', x'abba'),
|
||||
(2, '456', x'dada'),
|
||||
(3, '789', NULL);
|
||||
`);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
cachedDb.close();
|
||||
});
|
||||
|
||||
test('caches statements', () => {
|
||||
expect(cachedDb.prepare('SELECT 1')).toBe(cachedDb.prepare('SELECT 1'));
|
||||
});
|
||||
|
||||
test('uses query in cache key', () => {
|
||||
expect(cachedDb.prepare('SELECT 1')).not.toBe(cachedDb.prepare('SELECT 2'));
|
||||
});
|
||||
|
||||
test('uses pluck in cache key', () => {
|
||||
expect(cachedDb.prepare('SELECT 1')).not.toBe(
|
||||
cachedDb.prepare('SELECT 1', { pluck: true }),
|
||||
);
|
||||
});
|
||||
|
||||
test('uses bigint in cache key', () => {
|
||||
expect(cachedDb.prepare('SELECT 1')).not.toBe(
|
||||
cachedDb.prepare('SELECT 1', { bigint: true }),
|
||||
);
|
||||
});
|
||||
|
||||
test('invalidates cache on close', () => {
|
||||
const stmt = cachedDb.prepare('SELECT 1');
|
||||
stmt.close();
|
||||
expect(stmt).not.toBe(cachedDb.prepare('SELECT 1'));
|
||||
});
|
||||
|
||||
test('does not cache persistent=false statements', () => {
|
||||
expect(cachedDb.prepare('SELECT 1', { persistent: false })).not.toBe(
|
||||
cachedDb.prepare('SELECT 1', { persistent: false }),
|
||||
);
|
||||
});
|
||||
});
|
||||
39
tsconfig.json
Normal file
39
tsconfig.json
Normal file
@ -0,0 +1,39 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
/* Visit https://aka.ms/tsconfig to read more about this file */
|
||||
|
||||
/* Language and Environment */
|
||||
"target": "es2022" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
|
||||
"module": "nodenext" /* Specify what module code is generated. */,
|
||||
"moduleResolution": "nodenext",
|
||||
|
||||
/* Emit */
|
||||
"emitDeclarationOnly": true,
|
||||
"declaration": true,
|
||||
"outDir": "./dist" /* Specify an output folder for all emitted files. */,
|
||||
"stripInternal": true,
|
||||
|
||||
/* Interop Constraints */
|
||||
"esModuleInterop": true,
|
||||
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
|
||||
|
||||
/* Type Checking */
|
||||
"strict": true /* Enable all strict type-checking options. */,
|
||||
"noImplicitAny": true /* Enable error reporting for expressions and declarations with an implied 'any' type. */,
|
||||
"strictNullChecks": true /* When type checking, take into account 'null' and 'undefined'. */,
|
||||
"strictFunctionTypes": true /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */,
|
||||
"strictBindCallApply": true /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */,
|
||||
"strictPropertyInitialization": true /* Check for class properties that are declared but not set in the constructor. */,
|
||||
"noImplicitThis": true /* Enable error reporting when 'this' is given the type 'any'. */,
|
||||
"useUnknownInCatchVariables": true /* Default catch clause variables as 'unknown' instead of 'any'. */,
|
||||
"noUnusedParameters": true /* Raise an error when a function parameter isn't read. */,
|
||||
"exactOptionalPropertyTypes": true /* Interpret optional property types as written, rather than adding 'undefined'. */,
|
||||
"noImplicitReturns": true /* Enable error reporting for codepaths that do not explicitly return in a function. */,
|
||||
"noFallthroughCasesInSwitch": true /* Enable error reporting for fallthrough cases in switch statements. */,
|
||||
"noUncheckedIndexedAccess": true /* Add 'undefined' to a type when accessed using an index. */,
|
||||
"noImplicitOverride": true /* Ensure overriding members in derived classes are marked with an override modifier. */,
|
||||
"noPropertyAccessFromIndexSignature": true /* Enforces using indexed accessors for keys declared using an indexed type. */
|
||||
|
||||
/* Completeness */
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user