Skip to content

fix(ts): some types polyshing, shorten filenames in web package dist/worker folder#1015

Open
delagen wants to merge 1 commit into
powersync-ja:mainfrom
delagen:fix-types
Open

fix(ts): some types polyshing, shorten filenames in web package dist/worker folder#1015
delagen wants to merge 1 commit into
powersync-ja:mainfrom
delagen:fix-types

Conversation

@delagen

@delagen delagen commented Jun 30, 2026

Copy link
Copy Markdown

Fixed errors with skipLibCheck:false

Multiple errors as

TS2503: Cannot find namespace 'Logger'
    node_modules/@powersync/common/lib/utils/Logger.d.ts:11:10:
      11 │     WARN: Logger.ILogLevel;
         ╵           ~~~~~~

Allow to use HEX key for encryption as stated in https://utelle.github.io/SQLite3MultipleCiphers/docs/configuration/config_sql_pragmas/#pragma-key--hexkey
by replacing quotes and forcefully set ChaCha20 as cipher, because under hood it's seems not default as stated in docs

@changeset-bot

changeset-bot Bot commented Jun 30, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 2e1443d

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@simolus3 simolus3 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While the logger type changes look reasonable to me, we're also working on a new major version of the SDK on the v2 branch that removes js-logger entirely. We're aiming to at least have a dev release for that out soon. So I'm not sure if it still makes sense to merge this.

Comment on lines +48 to +49
const escapedKey = this.options.encryptionKey.replace(/"/g, `""`);
await this.executeRaw(`PRAGMA key = "${escapedKey}"`);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would we use double quotes here? It should be a string literal, which uses single quotes. We don't currently support hexkeys, doing that would also require a new option to not break existing users.

@rkistner rkistner Jun 30, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the SQLCipher docs https://www.zetetic.net/sqlcipher/sqlcipher-api/#PRAGMA_key docs https://utelle.github.io/SQLite3MultipleCiphers/docs/configuration/config_sql_pragmas/#pragma-key--hexkey:

-- Example of a raw key for the SQLCipher scheme
PRAGMA key = "x'54686973206973206D792076657279207365637265742070617373776F72642E'";

Note that there is a difference between providing a raw key like that without key derivation, and providing a "passphrase" in hex to support binary data, using PRAGMA hexkey.

I'm not sure it's a good idea to let the user specify it in the above formats directly, but it could be nice to accept a Uint8Array key and/or raw key and do this conversion automatically.

Regardless, the current replace("'", "''") is a bug, since it would only replace the first quote.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, current is bugged, and doesn't accept other key types.

I thought about UInt8Array, but I didn't decide to change API, cause it doesn't solve other types, as Raw for example.

Introducing additional option may require additional validation to prevent provide both option at once.

@delagen delagen Jun 30, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted quotes back to literal, currently prefer using 'raw:hex' value. Also forced to using chacha20 cipher stated in docs, because seems it's not default

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created MR to v2 #1016

@delagen delagen force-pushed the fix-types branch 6 times, most recently from 6ff37fe to ec7b21f Compare June 30, 2026 14:04
…worker folder, shorten worker chunks names in dist folder
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants