You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

oauth2-server-model-prisma

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

oauth2-server-model-prisma

Prisma model for oauth2-server

0.9.0
latest
Source
npmnpm
Version published
Weekly downloads
7
-74.07%
Maintainers
1
Weekly downloads
 
Created
Source

Prisma model for node OAuth2 Server

Installation

Using Yarn

yarn add oauth2-server-model-prisma

Using NPM

npm install oauth2-server-model-prisma

Usage

  import model from 'oauth2-server-model-prisma';

  const server = new OAuth2Server({
    model: {
      ...model({ prisma }),
    },
    requireClientAuthentication: {
      password: false,
      refresh_token: false,
    },
  });

Prisma Schema


model OauthAccessToken {
  id                    String           @default(dbgenerated()) @id
  userId                String
  applicationId         String
  token                 String           @unique
  refreshToken          String?          @unique
  tokenExpiresAt        DateTime?        @db.Timestamptz(6)
  refreshTokenExpiresAt DateTime?        @db.Timestamptz(6)
  scopes                Json             @default("[]")
  createdAt             DateTime         @default(now()) @db.Timestamptz(6)
  updatedAt             DateTime         @default(now()) @updatedAt @db.Timestamptz(6)
  application           OauthApplication @relation(fields: [applicationId], references: [id])
  user                  User             @relation(fields: [userId], references: [id])

  @@index([applicationId])
  @@index([userId])
}

model OauthAccessGrant {
  id            String           @default(dbgenerated()) @id
  userId        String
  applicationId String
  token         String           @unique
  expiresAt     DateTime         @db.Timestamptz(6)
  redirectUri   String
  codeChallengeMethod String?
  codeChallenge String?
  scopes        Json             @default("[]")
  createdAt     DateTime         @default(now()) @db.Timestamptz(6)
  updatedAt     DateTime         @default(now()) @updatedAt @db.Timestamptz(6)
  application   OauthApplication @relation(fields: [applicationId], references: [id])
  user          User             @relation(fields: [userId], references: [id])

  @@index([applicationId])
  @@index([userId])
}

model OauthApplication {
  id           String             @default(dbgenerated()) @id
  name         String
  clientId     String             @unique
  clientSecret String
  redirectUris Json               @default("[]")
  scopes       Json               @default("[]")
  createdAt    DateTime           @default(now()) @db.Timestamptz(6)
  updatedAt    DateTime           @default(now()) @updatedAt @db.Timestamptz(6)
  grants       Json               @default("[]")
  accessTokens OauthAccessToken[]
  accessGrants OauthAccessGrant[]
}

model User {
  id                String             @default(dbgenerated()) @id
  name              String
  email             String             @unique
  encryptedPassword String
  createdAt         DateTime           @default(now()) @db.Timestamptz(6)
  updatedAt         DateTime           @default(now()) @updatedAt @db.Timestamptz(6)
  accessTokens      OauthAccessToken[]
  accessGrants      OauthAccessGrant[]
  identities        UserIdentity[]
}

model UserIdentity {
  id        String   @default(dbgenerated()) @id
  userId    String
  provider  String
  uid       String
  name      String?
  email     String?
  createdAt DateTime @default(now()) @db.Timestamptz(6)
  updatedAt DateTime @default(now()) @updatedAt @db.Timestamptz(6)
  user      User     @relation(fields: [userId], references: [id])

  @@index([userId])
  @@unique([provider, uid])
}

License

The package is available as open source under the terms of the MIT License.

Keywords

oauth

FAQs

Package last updated on 05 Jul 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