better-auth
Version:
The most comprehensive authentication framework for TypeScript.
1 lines • 5.96 kB
Source Map (JSON)
{"version":3,"file":"schema.mjs","names":[],"sources":["../../../src/plugins/oidc-provider/schema.ts"],"sourcesContent":["import type { BetterAuthPluginDBSchema } from \"@better-auth/core/db\";\nimport * as z from \"zod\";\n\nconst oAuthApplicationSchema = z.object({\n\t/**\n\t * Client ID\n\t *\n\t * size 32\n\t *\n\t * as described on https://www.rfc-editor.org/rfc/rfc6749.html#section-2.2\n\t */\n\tclientId: z.string(),\n\t/**\n\t * Client Secret\n\t *\n\t * A secret for the client, if required by the authorization server.\n\t * Optional for public clients using PKCE.\n\t *\n\t * size 32\n\t */\n\tclientSecret: z.string().optional(),\n\t/**\n\t * The client type\n\t *\n\t * as described on https://www.rfc-editor.org/rfc/rfc6749.html#section-2.1\n\t *\n\t * - web - A web application\n\t * - native - A mobile application\n\t * - user-agent-based - A user-agent-based application\n\t * - public - A public client (PKCE-enabled, no client_secret)\n\t */\n\ttype: z.enum([\"web\", \"native\", \"user-agent-based\", \"public\"]),\n\t/**\n\t * The name of the client.\n\t */\n\tname: z.string(),\n\t/**\n\t * The icon of the client.\n\t */\n\ticon: z.string().optional(),\n\t/**\n\t * Additional metadata about the client.\n\t */\n\tmetadata: z.string().optional(),\n\t/**\n\t * Whether the client is disabled or not.\n\t */\n\tdisabled: z.boolean().optional().default(false),\n\n\t// Database fields\n\tredirectUrls: z.string(),\n\tuserId: z.string().optional(),\n\tcreatedAt: z.date(),\n\tupdatedAt: z.date(),\n});\n\nexport type OAuthApplication = z.infer<typeof oAuthApplicationSchema>;\n\nexport const schema = {\n\toauthApplication: {\n\t\tmodelName: \"oauthApplication\",\n\t\tfields: {\n\t\t\tname: {\n\t\t\t\ttype: \"string\",\n\t\t\t},\n\t\t\ticon: {\n\t\t\t\ttype: \"string\",\n\t\t\t\trequired: false,\n\t\t\t},\n\t\t\tmetadata: {\n\t\t\t\ttype: \"string\",\n\t\t\t\trequired: false,\n\t\t\t},\n\t\t\tclientId: {\n\t\t\t\ttype: \"string\",\n\t\t\t\tunique: true,\n\t\t\t},\n\t\t\tclientSecret: {\n\t\t\t\ttype: \"string\",\n\t\t\t\trequired: false,\n\t\t\t},\n\t\t\tredirectUrls: {\n\t\t\t\ttype: \"string\",\n\t\t\t},\n\t\t\ttype: {\n\t\t\t\ttype: \"string\",\n\t\t\t},\n\t\t\tdisabled: {\n\t\t\t\ttype: \"boolean\",\n\t\t\t\trequired: false,\n\t\t\t\tdefaultValue: false,\n\t\t\t},\n\t\t\tuserId: {\n\t\t\t\ttype: \"string\",\n\t\t\t\trequired: false,\n\t\t\t\treferences: {\n\t\t\t\t\tmodel: \"user\",\n\t\t\t\t\tfield: \"id\",\n\t\t\t\t\tonDelete: \"cascade\",\n\t\t\t\t},\n\t\t\t\tindex: true,\n\t\t\t},\n\t\t\tcreatedAt: {\n\t\t\t\ttype: \"date\",\n\t\t\t},\n\t\t\tupdatedAt: {\n\t\t\t\ttype: \"date\",\n\t\t\t},\n\t\t},\n\t},\n\toauthAccessToken: {\n\t\tmodelName: \"oauthAccessToken\",\n\t\tfields: {\n\t\t\taccessToken: {\n\t\t\t\ttype: \"string\",\n\t\t\t\tunique: true,\n\t\t\t},\n\t\t\trefreshToken: {\n\t\t\t\ttype: \"string\",\n\t\t\t\tunique: true,\n\t\t\t},\n\t\t\taccessTokenExpiresAt: {\n\t\t\t\ttype: \"date\",\n\t\t\t},\n\t\t\trefreshTokenExpiresAt: {\n\t\t\t\ttype: \"date\",\n\t\t\t},\n\t\t\tclientId: {\n\t\t\t\ttype: \"string\",\n\t\t\t\treferences: {\n\t\t\t\t\tmodel: \"oauthApplication\",\n\t\t\t\t\tfield: \"clientId\",\n\t\t\t\t\tonDelete: \"cascade\",\n\t\t\t\t},\n\t\t\t\tindex: true,\n\t\t\t},\n\t\t\tuserId: {\n\t\t\t\ttype: \"string\",\n\t\t\t\trequired: false,\n\t\t\t\treferences: {\n\t\t\t\t\tmodel: \"user\",\n\t\t\t\t\tfield: \"id\",\n\t\t\t\t\tonDelete: \"cascade\",\n\t\t\t\t},\n\t\t\t\tindex: true,\n\t\t\t},\n\t\t\tscopes: {\n\t\t\t\ttype: \"string\",\n\t\t\t},\n\t\t\tcreatedAt: {\n\t\t\t\ttype: \"date\",\n\t\t\t},\n\t\t\tupdatedAt: {\n\t\t\t\ttype: \"date\",\n\t\t\t},\n\t\t},\n\t},\n\toauthConsent: {\n\t\tmodelName: \"oauthConsent\",\n\t\tfields: {\n\t\t\tclientId: {\n\t\t\t\ttype: \"string\",\n\t\t\t\treferences: {\n\t\t\t\t\tmodel: \"oauthApplication\",\n\t\t\t\t\tfield: \"clientId\",\n\t\t\t\t\tonDelete: \"cascade\",\n\t\t\t\t},\n\t\t\t\tindex: true,\n\t\t\t},\n\t\t\tuserId: {\n\t\t\t\ttype: \"string\",\n\t\t\t\treferences: {\n\t\t\t\t\tmodel: \"user\",\n\t\t\t\t\tfield: \"id\",\n\t\t\t\t\tonDelete: \"cascade\",\n\t\t\t\t},\n\t\t\t\tindex: true,\n\t\t\t},\n\t\t\tscopes: {\n\t\t\t\ttype: \"string\",\n\t\t\t},\n\t\t\tcreatedAt: {\n\t\t\t\ttype: \"date\",\n\t\t\t},\n\t\t\tupdatedAt: {\n\t\t\t\ttype: \"date\",\n\t\t\t},\n\t\t\tconsentGiven: {\n\t\t\t\ttype: \"boolean\",\n\t\t\t},\n\t\t},\n\t},\n} satisfies BetterAuthPluginDBSchema;\n"],"mappings":";;;AAG+B,EAAE,OAAO;CAQvC,UAAU,EAAE,QAAQ;CASpB,cAAc,EAAE,QAAQ,CAAC,UAAU;CAWnC,MAAM,EAAE,KAAK;EAAC;EAAO;EAAU;EAAoB;EAAS,CAAC;CAI7D,MAAM,EAAE,QAAQ;CAIhB,MAAM,EAAE,QAAQ,CAAC,UAAU;CAI3B,UAAU,EAAE,QAAQ,CAAC,UAAU;CAI/B,UAAU,EAAE,SAAS,CAAC,UAAU,CAAC,QAAQ,MAAM;CAG/C,cAAc,EAAE,QAAQ;CACxB,QAAQ,EAAE,QAAQ,CAAC,UAAU;CAC7B,WAAW,EAAE,MAAM;CACnB,WAAW,EAAE,MAAM;CACnB,CAAC;AAIF,MAAa,SAAS;CACrB,kBAAkB;EACjB,WAAW;EACX,QAAQ;GACP,MAAM,EACL,MAAM,UACN;GACD,MAAM;IACL,MAAM;IACN,UAAU;IACV;GACD,UAAU;IACT,MAAM;IACN,UAAU;IACV;GACD,UAAU;IACT,MAAM;IACN,QAAQ;IACR;GACD,cAAc;IACb,MAAM;IACN,UAAU;IACV;GACD,cAAc,EACb,MAAM,UACN;GACD,MAAM,EACL,MAAM,UACN;GACD,UAAU;IACT,MAAM;IACN,UAAU;IACV,cAAc;IACd;GACD,QAAQ;IACP,MAAM;IACN,UAAU;IACV,YAAY;KACX,OAAO;KACP,OAAO;KACP,UAAU;KACV;IACD,OAAO;IACP;GACD,WAAW,EACV,MAAM,QACN;GACD,WAAW,EACV,MAAM,QACN;GACD;EACD;CACD,kBAAkB;EACjB,WAAW;EACX,QAAQ;GACP,aAAa;IACZ,MAAM;IACN,QAAQ;IACR;GACD,cAAc;IACb,MAAM;IACN,QAAQ;IACR;GACD,sBAAsB,EACrB,MAAM,QACN;GACD,uBAAuB,EACtB,MAAM,QACN;GACD,UAAU;IACT,MAAM;IACN,YAAY;KACX,OAAO;KACP,OAAO;KACP,UAAU;KACV;IACD,OAAO;IACP;GACD,QAAQ;IACP,MAAM;IACN,UAAU;IACV,YAAY;KACX,OAAO;KACP,OAAO;KACP,UAAU;KACV;IACD,OAAO;IACP;GACD,QAAQ,EACP,MAAM,UACN;GACD,WAAW,EACV,MAAM,QACN;GACD,WAAW,EACV,MAAM,QACN;GACD;EACD;CACD,cAAc;EACb,WAAW;EACX,QAAQ;GACP,UAAU;IACT,MAAM;IACN,YAAY;KACX,OAAO;KACP,OAAO;KACP,UAAU;KACV;IACD,OAAO;IACP;GACD,QAAQ;IACP,MAAM;IACN,YAAY;KACX,OAAO;KACP,OAAO;KACP,UAAU;KACV;IACD,OAAO;IACP;GACD,QAAQ,EACP,MAAM,UACN;GACD,WAAW,EACV,MAAM,QACN;GACD,WAAW,EACV,MAAM,QACN;GACD,cAAc,EACb,MAAM,WACN;GACD;EACD;CACD"}