diff --git a/apps/demo/CHANGELOG.md b/apps/demo/CHANGELOG.md index 8055a42..de977dd 100644 --- a/apps/demo/CHANGELOG.md +++ b/apps/demo/CHANGELOG.md @@ -1,5 +1,11 @@ # @authhero/demo +## 0.0.9 + +### Patch Changes + +- authhero@0.2.11 + ## 0.0.8 ### Patch Changes diff --git a/apps/demo/package.json b/apps/demo/package.json index cc857f3..479a458 100644 --- a/apps/demo/package.json +++ b/apps/demo/package.json @@ -1,7 +1,7 @@ { "name": "@authhero/demo", "private": true, - "version": "0.0.8", + "version": "0.0.9", "scripts": { "dev": "bun --watch src/bun.ts" }, diff --git a/packages/adapter-interfaces/CHANGELOG.md b/packages/adapter-interfaces/CHANGELOG.md index 9b6c3f1..274d897 100644 --- a/packages/adapter-interfaces/CHANGELOG.md +++ b/packages/adapter-interfaces/CHANGELOG.md @@ -1,5 +1,11 @@ # @authhero/adapter-interfaces +## 0.11.1 + +### Patch Changes + +- Update the application types + ## 0.11.0 ### Minor Changes diff --git a/packages/adapter-interfaces/package.json b/packages/adapter-interfaces/package.json index 9b62ddc..fb951f6 100644 --- a/packages/adapter-interfaces/package.json +++ b/packages/adapter-interfaces/package.json @@ -11,7 +11,7 @@ "type": "git", "url": "https://github.com/markusahlstrand/authhero" }, - "version": "0.11.0", + "version": "0.11.1", "files": [ "dist" ], diff --git a/packages/adapter-interfaces/src/adapters/Applications.ts b/packages/adapter-interfaces/src/adapters/Applications.ts index 198e927..0a34b30 100644 --- a/packages/adapter-interfaces/src/adapters/Applications.ts +++ b/packages/adapter-interfaces/src/adapters/Applications.ts @@ -1,23 +1,8 @@ -import { Application, Totals } from "../types"; +import { Application, ApplicationInsert, Totals } from "../types"; import { ListParams } from "../types/ListParams"; -export interface CreateApplicationParams { - name: string; - allowed_web_origins: string; - allowed_callback_urls: string; - allowed_logout_urls: string; - email_validation: "enabled" | "disabled" | "enforced"; - client_secret: string; - id: string; - disable_sign_ups: boolean; - addons?: Record>; -} - export interface ApplicationsAdapter { - create( - tenant_id: string, - params: CreateApplicationParams, - ): Promise; + create(tenant_id: string, params: ApplicationInsert): Promise; get(tenant_id: string, id: string): Promise; remove(tenant_id: string, id: string): Promise; list( diff --git a/packages/adapter-interfaces/src/types/Application.ts b/packages/adapter-interfaces/src/types/Application.ts index a177967..324e71d 100644 --- a/packages/adapter-interfaces/src/types/Application.ts +++ b/packages/adapter-interfaces/src/types/Application.ts @@ -27,6 +27,14 @@ export const applicationInsertSchema = z.object({ description: "Comma-separated list of allowed origins for use with Cross-Origin Authentication, Device Flow, and web message response mode.", }), + allowed_logout_urls: z + .string() + .transform((val) => (val === null ? "" : val)) + .default("") + .openapi({ + description: + "Comma-separated list of URLs that are valid to redirect to after logout from Auth0. Wildcards are allowed for subdomains.", + }), addons: z .record(z.string(), z.record(z.string(), z.union([z.string(), z.number()]))) .optional() @@ -43,10 +51,7 @@ export const applicationInsertSchema = z.object({ .string() .transform((val) => (val === null ? "" : val)) .default(""), - allowed_logout_urls: z - .string() - .transform((val) => (val === null ? "" : val)) - .default(""), + email_validation: z .enum(["enabled", "disabled", "enforced"]) .default("enforced") diff --git a/packages/authhero/CHANGELOG.md b/packages/authhero/CHANGELOG.md index 0eec8c8..9110ba8 100644 --- a/packages/authhero/CHANGELOG.md +++ b/packages/authhero/CHANGELOG.md @@ -1,5 +1,12 @@ # authhero +## 0.2.11 + +### Patch Changes + +- Updated dependencies + - @authhero/adapter-interfaces@0.11.1 + ## 0.2.10 ### Patch Changes diff --git a/packages/authhero/package.json b/packages/authhero/package.json index e1db45c..be0296c 100644 --- a/packages/authhero/package.json +++ b/packages/authhero/package.json @@ -1,6 +1,6 @@ { "name": "authhero", - "version": "0.2.10", + "version": "0.2.11", "files": [ "dist" ], diff --git a/packages/drizzle/CHANGELOG.md b/packages/drizzle/CHANGELOG.md index 306b11e..531015e 100644 --- a/packages/drizzle/CHANGELOG.md +++ b/packages/drizzle/CHANGELOG.md @@ -1,5 +1,12 @@ # @authhero/drizzle +## 0.1.27 + +### Patch Changes + +- Updated dependencies + - @authhero/adapter-interfaces@0.11.1 + ## 0.1.26 ### Patch Changes diff --git a/packages/drizzle/package.json b/packages/drizzle/package.json index 3535aa1..8555020 100644 --- a/packages/drizzle/package.json +++ b/packages/drizzle/package.json @@ -11,7 +11,7 @@ "type": "git", "url": "https://github.com/markusahlstrand/authhero" }, - "version": "0.1.26", + "version": "0.1.27", "files": [ "dist" ], diff --git a/packages/kysely/CHANGELOG.md b/packages/kysely/CHANGELOG.md index cbeba32..2844049 100644 --- a/packages/kysely/CHANGELOG.md +++ b/packages/kysely/CHANGELOG.md @@ -1,5 +1,13 @@ # @authhero/kysely-adapter +## 0.7.1 + +### Patch Changes + +- Update the application types +- Updated dependencies + - @authhero/adapter-interfaces@0.11.1 + ## 0.7.0 ### Minor Changes diff --git a/packages/kysely/package.json b/packages/kysely/package.json index 4201605..6d11e2c 100644 --- a/packages/kysely/package.json +++ b/packages/kysely/package.json @@ -11,7 +11,7 @@ "type": "git", "url": "https://github.com/markusahlstrand/authhero" }, - "version": "0.7.0", + "version": "0.7.1", "files": [ "dist" ], diff --git a/packages/kysely/src/applications/create.ts b/packages/kysely/src/applications/create.ts index 82340ad..6be9331 100644 --- a/packages/kysely/src/applications/create.ts +++ b/packages/kysely/src/applications/create.ts @@ -1,26 +1,38 @@ import { Kysely } from "kysely"; -import { - Application, - CreateApplicationParams, -} from "@authhero/adapter-interfaces"; +import { Application, ApplicationInsert } from "@authhero/adapter-interfaces"; import { Database } from "../db"; export function create(db: Kysely) { return async ( tenant_id: string, - params: CreateApplicationParams, + params: ApplicationInsert, ): Promise => { - const application: any = { + const application: Application = { created_at: new Date().toISOString(), updated_at: new Date().toISOString(), ...params, - disable_sign_ups: params.disable_sign_ups ? 1 : 0, - addons: params.addons ? JSON.stringify(params.addons) : null, + // TODO: remove fallbacks + allowed_web_origins: params.allowed_origins, + allowed_callback_urls: params.callbacks, + allowed_origins: params.allowed_origins, }; + const allowed_origins = JSON.stringify(params.allowed_origins.split(",")); + const allowed_callback_urls = JSON.stringify(params.callbacks.split(",")); + const callbacks = JSON.stringify(params.callbacks.split(",")); + await db .insertInto("applications") - .values({ ...application, tenant_id }) + .values({ + ...application, + tenant_id, + disable_sign_ups: params.disable_sign_ups ? 1 : 0, + addons: params.addons ? JSON.stringify(params.addons) : "{}", + callbacks, + allowed_web_origins: allowed_origins, + allowed_callback_urls, + allowed_origins, + }) .execute(); return application; diff --git a/packages/kysely/src/applications/get.ts b/packages/kysely/src/applications/get.ts index c5d5aac..d578c05 100644 --- a/packages/kysely/src/applications/get.ts +++ b/packages/kysely/src/applications/get.ts @@ -19,11 +19,15 @@ export function get(db: Kysely) { return null; } - application.disable_sign_ups = !!application.disable_sign_ups; - application.addons = application.addons - ? JSON.parse(application.addons) - : {}; - - return removeNullProperties(application); + return removeNullProperties({ + ...application, + disable_sign_ups: !!application.disable_sign_ups, + addons: JSON.parse(application.addons), + // TODO: add callbacks + callback: JSON.parse(application.callbacks), + allowed_origins: JSON.parse(application.allowed_origins), + allowed_callback_urls: JSON.parse(application.allowed_callback_urls), + allowed_web_origins: JSON.parse(application.allowed_web_origins), + }); }; } diff --git a/packages/kysely/src/applications/update.ts b/packages/kysely/src/applications/update.ts index 4b58c51..b2f9614 100644 --- a/packages/kysely/src/applications/update.ts +++ b/packages/kysely/src/applications/update.ts @@ -8,14 +8,28 @@ export function update(db: Kysely) { application_id: string, application: Partial, ): Promise => { - const sqlConnection = { + const sqlApplication = { ...application, updated_at: new Date().toISOString(), + allowed_origins: application.allowed_origins + ? JSON.stringify(application.allowed_origins) + : undefined, + allowed_callback_urls: application.allowed_callback_urls + ? JSON.stringify(application.allowed_callback_urls) + : undefined, + allowed_web_origins: application.allowed_web_origins + ? JSON.stringify(application.allowed_web_origins) + : undefined, + callbacks: application.callbacks + ? JSON.stringify(application.callbacks) + : undefined, + addons: application.addons ? JSON.stringify(application.addons) : "{}", + disable_sign_ups: application.disable_sign_ups ? 1 : 0, }; await db .updateTable("applications") - .set(sqlConnection) + .set(sqlApplication) .where("applications.id", "=", application_id) .where("applications.tenant_id", "=", tenant_id) .execute(); diff --git a/packages/kysely/src/db.ts b/packages/kysely/src/db.ts index 50d7c89..53c247e 100644 --- a/packages/kysely/src/db.ts +++ b/packages/kysely/src/db.ts @@ -3,7 +3,6 @@ import { SqlBranding } from "./branding/Branding"; import { SqlAuthenticationCode } from "./authenticationCodes/AuthenticationCode"; import { SqlUser } from "./users/User"; import { - Application, applicationSchema, Certificate, Code, @@ -37,7 +36,9 @@ const sqlApplicationSchema = z.object({ ...applicationSchema.shape, tenant_id: z.string(), // The addons will be stored as JSON in a text column - addons: z.string().optional(), + addons: z.string(), + disable_sign_ups: z.number(), + callbacks: z.string(), }); export interface Database {