// oauth2-client.js // Copyright (C) 2022 DTP Technologies, LLC // License: Apache-2.0 'use strict'; const mongoose = require('mongoose'); const Schema = mongoose.Schema; const OAuth2ClientSchema = new Schema({ created: { type: Date, default: Date.now, required: true }, updated: { type: Date, default: Date.now, required: true }, site: { domain: { type: String, required: true, index: 1 }, domainKey: { type: String, required: true, index: 1 }, name: { type: String, required: true }, description: { type: String, required: true }, company: { type: String, required: true }, }, secret: { type: String, required: true }, scopes: { type: [String], required: true }, callbackUrl: { type: String, required: true }, kaleidoscope: { token: { type: String, required: true, index: 1 }, }, flags: { isActive: { type: Boolean, default: true, required: true, index: 1 }, }, admin: { notes: { type: String }, }, }); OAuth2ClientSchema.index({ 'site.domain': 1, 'site.domainKey': 1, }, { name: 'unique_oauth_client_domain', unique: true, }); module.exports = (conn) => { return conn.model('OAuth2Client', OAuth2ClientSchema); };