Socket
Book a DemoInstallSign in
Socket

kysely-hash

Package Overview
Dependencies
Maintainers
0
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kysely-hash

Hash plugin for kysely

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
0
Created
Source

kysely-hash

CI

NPM version

NPM downloads

js-prettier-style

Hash plugin for kysely fully typed, developed for Node.js but also runs on Deno and Bun; with this plugin you can hash fields using crypto-js library.

Install

npm i kysely kysely-hash

Usage

Options

  • fieldsToDecrypt: field to hash during insert and update, or in '=' and '!=' where condition (use alias if it is used)

  • hashAlgorithm: hash algorithm

How to use

WARNING: fields must be of string types

const kyselyInstance = new Kysely<Database>({
    dialect: new SqliteDialect({
        database: new Database(':memory:'),
    }),
})

await kyselyInstance.schema
    .createTable('person')
    .ifNotExists()
    .addColumn('id', 'integer', (col) => col.primaryKey())
    .addColumn('first_name', 'varchar(255)')
    .addColumn('last_name', 'varchar(255)')
    .addColumn('gender', 'varchar(255)')
    .execute()

await kyselyInstance
    .insertInto('person')
    .values([
        {
            first_name: 'Max',
            last_name: 'Jack',
            gender: 'man',
        },
        {
            first_name: 'George',
            last_name: 'Rossi',
            gender: 'man',
        },
    ])
    .withPlugin(
        new KyselyHashPlugin<Database>({
            fieldsToHash: ['last_name'],
            hashAlgorithm: 'SHA256',
        }),
    )
    .execute() 

License

Licensed under MIT.

Keywords

hash

FAQs

Package last updated on 07 Feb 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.