Socket
Book a DemoInstallSign in
Socket

@cipherstash/stashjs-adapter

Package Overview
Dependencies
Maintainers
6
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

@cipherstash/stashjs-adapter

Adapter helpers for Stash.js and popular ORMs like Prisma

0.2.0
unpublished
latest
Source
npmnpm
Version published
Maintainers
6
Created
Source

Stash.js Adapter

This package provides an adapter class to simplify migrating types from existing databases (such as Prisma) to a CipherStash collection.

For new applications we recommend using Stash.js which this library uses under the hood anyway.

The main component of this package is the CollectionAPI<T> class which takes a type with a numeric id ({id: number}) and maps it to a CipherStash (which uses UUID) for IDs. CollectionAPI<T> exposes a simple API as described below. It does not attempt to mirror existing ORM interfaces like Prisma (though it may offer than in the future).

The primary goals of this module are:

  • To abstract the mapping of numeric to "secure" IDs
  • To provide an API to CipherStash that uses an existing type

Usage

First create a module to represent a model (say User) in CipherStash.

// -- user-vault.ts ==
// Existing User type
import { User } from "@prisma/client"
import CollectionAPI from "@cipherstash/stashjs-adapter"

const ID_NAMESPACE = "1b671a64-40d5-491e-99b0-da01ff1f3341"

export const UserVault = new CollectionAPI<User>("users", ID_NAMESPACE)

Then use in other parts of your application. For example, in an API:

import type { NextApiRequest, NextApiResponse } from "next"
import UserVault from "user-vault"

export default async function handler(_req: NextApiRequest, res: NextApiResponse<any>) {
  const users = await UserVault.list()
  res.status(200).json(users)
}

FAQs

Package last updated on 08 Dec 2022

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.