Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/src/packages/util/db-schema/api-keys.ts
Views: 687
import { Table } from "./types";1import { CREATED_BY, ID } from "./crm";23export interface ApiKey {4id: number;5account_id: string;6created: Date;7hash?: string; // usually NOT available8trunc: string;9project_id?: string; // only for project api keys10expire?: Date;11name: string;12last_active?: Date;13secret?: string; // only when initially creating the key (and never in database)14}1516Table({17name: "api_keys",18fields: {19id: ID,20account_id: CREATED_BY, // who made this api key21expire: {22type: "timestamp",23desc: "When this api key expires and is automatically deleted.",24},25created: {26type: "timestamp",27desc: "When this api key was created.",28},29hash: {30type: "string",31pg_type: "VARCHAR(173)",32desc: "Hash of the api key. This is the same hash as for user passwords, which is 1000 iterations of sha512 with salt of length 32.",33},34name: {35type: "string",36pg_type: "VARCHAR(128)",37desc: "user defined name of this key",38},39trunc: {40type: "string",41pg_type: "VARCHAR(16)",42desc: "Truncated version of the actual api key, suitable for display to remind user which key it is.",43},44project_id: {45type: "uuid",46desc: "Optional uuid of the project that this api key applies to. If not set, api key is global.",47},48last_active: {49type: "timestamp",50desc: "When this api key was last used.",51},52},53rules: {54primary_key: "id",55pg_indexes: [56"((created IS NOT NULL))",57"((account_id IS NOT NULL))",58"project_id",59],60},61});626364