models/DeviceAuthorization.ts

commonly · backend/models/DeviceAuthorization.ts · typescript · Apache-2.0
auth, tag:embed-classified

Mongoose schema for device authorization tokens, tracking status and timestamps.

// Source: https://github.com/Team-Commonly/commonly | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
import mongoose, { Document, Schema, Types } from 'mongoose';

export type DeviceAuthorizationStatus = 'pending' | 'authorized' | 'denied' | 'consumed';

export interface IDeviceAuthorization extends Document {
  deviceCodeHash: string;
  userCodeHash: string;
  clientName: string;
  clientVersion?: string;
  hostname: string;
  status: DeviceAuthorizationStatus;
  userId?: Types.ObjectId | null;
  createdAt: Date;
  lastPolledAt?: Date;
  authorizedAt?: Date;
  deniedAt?: Date;
  consumedAt?: Date;
  expiresAt: Date;
}

const DeviceAuthorizationSchema = new Schema<IDeviceAuthoriza

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key