diff --git a/packages/kysely/CHANGELOG.md b/packages/kysely/CHANGELOG.md index 2844049..5fcf24e 100644 --- a/packages/kysely/CHANGELOG.md +++ b/packages/kysely/CHANGELOG.md @@ -1,5 +1,11 @@ # @authhero/kysely-adapter +## 0.7.2 + +### Patch Changes + +- Handle empty allowed strings + ## 0.7.1 ### Patch Changes diff --git a/packages/kysely/package.json b/packages/kysely/package.json index 6d11e2c..3b39c7b 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.1", + "version": "0.7.2", "files": [ "dist" ], diff --git a/packages/kysely/src/applications/create.ts b/packages/kysely/src/applications/create.ts index 6be9331..050cf9f 100644 --- a/packages/kysely/src/applications/create.ts +++ b/packages/kysely/src/applications/create.ts @@ -2,6 +2,15 @@ import { Kysely } from "kysely"; import { Application, ApplicationInsert } from "@authhero/adapter-interfaces"; import { Database } from "../db"; +function toJsonString(value: string) { + return JSON.stringify( + value + .split(",") + .map((item) => item.trim()) + .filter((item) => item.length), + ); +} + export function create(db: Kysely) { return async ( tenant_id: string, @@ -17,9 +26,9 @@ export function create(db: Kysely) { 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(",")); + const allowed_origins = toJsonString(params.allowed_origins); + const allowed_callback_urls = toJsonString(params.callbacks); + const callbacks = toJsonString(params.callbacks); await db .insertInto("applications")