From e72ced95f0fdaa1669e715887a996dd70ec4a700 Mon Sep 17 00:00:00 2001 From: Markus Ahlstrand Date: Mon, 2 Sep 2024 17:31:24 +0200 Subject: [PATCH] fix imports --- .changeset/serious-falcons-raise.md | 5 ---- apps/auth0-proxy/CHANGELOG.md | 6 +++++ apps/auth0-proxy/package.json | 2 +- apps/demo/CHANGELOG.md | 6 +++++ apps/demo/package.json | 2 +- packages/adapter-interfaces/CHANGELOG.md | 7 ++++++ packages/adapter-interfaces/package.json | 2 +- .../src/adapters/PromptSettings.ts | 6 +++++ .../adapter-interfaces/src/adapters/index.ts | 2 ++ .../src/types/Application.ts | 4 ++++ .../src/types/Connection.ts | 19 +++++++++++++-- .../src/types/LoginState.ts | 9 -------- .../src/types/PromptSetting.ts | 10 ++++++++ .../adapter-interfaces/src/types/index.ts | 2 +- packages/authhero/CHANGELOG.md | 8 +++++++ packages/authhero/package.json | 2 +- packages/drizzle/CHANGELOG.md | 8 +++++++ packages/drizzle/package.json | 2 +- packages/kysely/CHANGELOG.md | 13 +++++++++++ packages/kysely/package.json | 2 +- packages/kysely/src/connections/create.ts | 3 ++- packages/kysely/src/connections/get.ts | 3 ++- packages/kysely/src/connections/list.ts | 5 +++- packages/kysely/src/connections/update.ts | 3 ++- packages/kysely/src/db.ts | 11 +++++++-- packages/kysely/src/index.ts | 2 ++ packages/kysely/src/promptSettings/get.ts | 23 +++++++++++++++++++ packages/kysely/src/promptSettings/index.ts | 14 +++++++++++ packages/kysely/src/promptSettings/set.ts | 23 +++++++++++++++++++ 29 files changed, 175 insertions(+), 29 deletions(-) delete mode 100644 .changeset/serious-falcons-raise.md create mode 100644 packages/adapter-interfaces/src/adapters/PromptSettings.ts delete mode 100644 packages/adapter-interfaces/src/types/LoginState.ts create mode 100644 packages/adapter-interfaces/src/types/PromptSetting.ts create mode 100644 packages/kysely/src/promptSettings/get.ts create mode 100644 packages/kysely/src/promptSettings/index.ts create mode 100644 packages/kysely/src/promptSettings/set.ts diff --git a/.changeset/serious-falcons-raise.md b/.changeset/serious-falcons-raise.md deleted file mode 100644 index d593b2c..0000000 --- a/.changeset/serious-falcons-raise.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@authhero/auth0-proxy": patch ---- - -Fix to proxy the querystring diff --git a/apps/auth0-proxy/CHANGELOG.md b/apps/auth0-proxy/CHANGELOG.md index 7f3c98f..66e7d23 100644 --- a/apps/auth0-proxy/CHANGELOG.md +++ b/apps/auth0-proxy/CHANGELOG.md @@ -1,5 +1,11 @@ # @authhero/auth0-proxy +## 0.1.1 + +### Patch Changes + +- f1d020c: Fix to proxy the querystring + ## 0.1.0 ### Minor Changes diff --git a/apps/auth0-proxy/package.json b/apps/auth0-proxy/package.json index 17806cd..6ee7063 100644 --- a/apps/auth0-proxy/package.json +++ b/apps/auth0-proxy/package.json @@ -1,7 +1,7 @@ { "name": "@authhero/auth0-proxy", "private": true, - "version": "0.1.0", + "version": "0.1.1", "scripts": { "dev": "bun --watch src/index.ts --watch" }, diff --git a/apps/demo/CHANGELOG.md b/apps/demo/CHANGELOG.md index 90a3db5..f454f8d 100644 --- a/apps/demo/CHANGELOG.md +++ b/apps/demo/CHANGELOG.md @@ -1,5 +1,11 @@ # @authhero/demo +## 0.0.21 + +### Patch Changes + +- authhero@0.2.23 + ## 0.0.20 ### Patch Changes diff --git a/apps/demo/package.json b/apps/demo/package.json index dbf35e5..a50d435 100644 --- a/apps/demo/package.json +++ b/apps/demo/package.json @@ -1,7 +1,7 @@ { "name": "@authhero/demo", "private": true, - "version": "0.0.20", + "version": "0.0.21", "scripts": { "dev": "bun --watch src/bun.ts" }, diff --git a/packages/adapter-interfaces/CHANGELOG.md b/packages/adapter-interfaces/CHANGELOG.md index 8fd3165..44cd753 100644 --- a/packages/adapter-interfaces/CHANGELOG.md +++ b/packages/adapter-interfaces/CHANGELOG.md @@ -1,5 +1,12 @@ # @authhero/adapter-interfaces +## 0.15.0 + +### Minor Changes + +- Add prompt settings and update the connection entity +- Add prompt settings adapter + ## 0.14.0 ### Minor Changes diff --git a/packages/adapter-interfaces/package.json b/packages/adapter-interfaces/package.json index efb6fa3..8b1acb9 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.14.0", + "version": "0.15.0", "files": [ "dist" ], diff --git a/packages/adapter-interfaces/src/adapters/PromptSettings.ts b/packages/adapter-interfaces/src/adapters/PromptSettings.ts new file mode 100644 index 0000000..98c28b8 --- /dev/null +++ b/packages/adapter-interfaces/src/adapters/PromptSettings.ts @@ -0,0 +1,6 @@ +import { PromptSetting } from "../types"; + +export interface PromptSettingsAdapter { + set: (tenant_id: string, promptSetting: PromptSetting) => Promise; + get: (tenant_id: string) => Promise; +} diff --git a/packages/adapter-interfaces/src/adapters/index.ts b/packages/adapter-interfaces/src/adapters/index.ts index b7d4a2d..abb8d1f 100644 --- a/packages/adapter-interfaces/src/adapters/index.ts +++ b/packages/adapter-interfaces/src/adapters/index.ts @@ -14,6 +14,7 @@ import { HooksAdapter } from "./Hooks"; import { ClientsAdapter } from "./Clients"; import { ThemesAdapter } from "./Themes"; import { LoginsAdapter } from "./Logins"; +import { PromptSettingsAdapter } from "./PromptSettings"; export interface DataAdapters { applications: ApplicationsAdapter; @@ -27,6 +28,7 @@ export interface DataAdapters { logins: LoginsAdapter; logs: LogsDataAdapter; passwords: PasswordsAdapter; + promptSettings: PromptSettingsAdapter; sessions: SessionsAdapter; tenants: TenantsDataAdapter; themes: ThemesAdapter; diff --git a/packages/adapter-interfaces/src/types/Application.ts b/packages/adapter-interfaces/src/types/Application.ts index 7929bcc..ee083fa 100644 --- a/packages/adapter-interfaces/src/types/Application.ts +++ b/packages/adapter-interfaces/src/types/Application.ts @@ -38,6 +38,10 @@ export const applicationInsertSchema = z.object({ description: "Comma-separated list of URLs that are valid to redirect to after logout from Auth0. Wildcards are allowed for subdomains.", }), + allowed_clients: z.array(z.string()).openapi({ + description: + "Ids of clients that will be allowed to perform delegation requests. Clients that will be allowed to make delegation request. By default, all your clients will be allowed. This field allows you to specify specific clients", + }), addons: z .object({ samlp: samlpAddon.optional(), diff --git a/packages/adapter-interfaces/src/types/Connection.ts b/packages/adapter-interfaces/src/types/Connection.ts index d568466..676b077 100644 --- a/packages/adapter-interfaces/src/types/Connection.ts +++ b/packages/adapter-interfaces/src/types/Connection.ts @@ -7,11 +7,26 @@ import { export const connectionInsertSchema = z.object({ id: z.string().optional(), name: z.string(), - client_id: z.string().optional(), - client_secret: z.string().optional(), + strategy: z + .enum(["google-oauth2", "facebook", "vipps", "apple", "email"]) + .optional(), + options: z.object({ + kid: z.string().optional(), + team_id: z.string().optional(), + realms: z.string().optional(), + client_id: z.string().optional(), + client_secret: z.string().optional(), + app_secret: z.string().optional(), + scope: z.string().optional(), + }), + enabled_clients: z.array(z.string()).optional(), authorization_endpoint: z.string().optional(), response_type: z.custom().optional(), response_mode: z.custom().optional(), + + // Deprecated + client_id: z.string().optional(), + client_secret: z.string().optional(), private_key: z.string().optional(), kid: z.string().optional(), team_id: z.string().optional(), diff --git a/packages/adapter-interfaces/src/types/LoginState.ts b/packages/adapter-interfaces/src/types/LoginState.ts deleted file mode 100644 index d26cd22..0000000 --- a/packages/adapter-interfaces/src/types/LoginState.ts +++ /dev/null @@ -1,9 +0,0 @@ -// Deprecated: This file will be removed in the next version -import { AuthParams } from "./AuthParams"; - -export interface LoginState { - connection?: string; - authParams: AuthParams; - state: string; - errorMessage?: string; -} diff --git a/packages/adapter-interfaces/src/types/PromptSetting.ts b/packages/adapter-interfaces/src/types/PromptSetting.ts new file mode 100644 index 0000000..aef8401 --- /dev/null +++ b/packages/adapter-interfaces/src/types/PromptSetting.ts @@ -0,0 +1,10 @@ +import { z } from "@hono/zod-openapi"; + +export const promptSettingSchema = z.object({ + universal_login_experience: z.enum(["new", "classic"]).default("new"), + identifier_first: z.boolean().default(true), + password_first: z.boolean().default(false), + webauthn_platform_first_factor: z.boolean(), +}); + +export type PromptSetting = z.infer; diff --git a/packages/adapter-interfaces/src/types/index.ts b/packages/adapter-interfaces/src/types/index.ts index 9eb56c2..1ae5c02 100644 --- a/packages/adapter-interfaces/src/types/index.ts +++ b/packages/adapter-interfaces/src/types/index.ts @@ -18,7 +18,7 @@ export * from "./Tenant"; export * from "./Token"; export * from "./User"; export * from "./Theme"; +export * from "./PromptSetting"; // Deprecated: These files will be removed in the next version -export * from "./LoginState"; export * from "./Ticket"; diff --git a/packages/authhero/CHANGELOG.md b/packages/authhero/CHANGELOG.md index 2b9d370..50703ae 100644 --- a/packages/authhero/CHANGELOG.md +++ b/packages/authhero/CHANGELOG.md @@ -1,5 +1,13 @@ # authhero +## 0.2.23 + +### Patch Changes + +- Updated dependencies +- Updated dependencies + - @authhero/adapter-interfaces@0.15.0 + ## 0.2.22 ### Patch Changes diff --git a/packages/authhero/package.json b/packages/authhero/package.json index c189ae8..dd4c1fb 100644 --- a/packages/authhero/package.json +++ b/packages/authhero/package.json @@ -1,6 +1,6 @@ { "name": "authhero", - "version": "0.2.22", + "version": "0.2.23", "files": [ "dist" ], diff --git a/packages/drizzle/CHANGELOG.md b/packages/drizzle/CHANGELOG.md index 9296488..9cb1a7f 100644 --- a/packages/drizzle/CHANGELOG.md +++ b/packages/drizzle/CHANGELOG.md @@ -1,5 +1,13 @@ # @authhero/drizzle +## 0.1.39 + +### Patch Changes + +- Updated dependencies +- Updated dependencies + - @authhero/adapter-interfaces@0.15.0 + ## 0.1.38 ### Patch Changes diff --git a/packages/drizzle/package.json b/packages/drizzle/package.json index cdeea47..1c5ae0f 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.38", + "version": "0.1.39", "files": [ "dist" ], diff --git a/packages/kysely/CHANGELOG.md b/packages/kysely/CHANGELOG.md index f8c406d..0fbb357 100644 --- a/packages/kysely/CHANGELOG.md +++ b/packages/kysely/CHANGELOG.md @@ -1,5 +1,18 @@ # @authhero/kysely-adapter +## 0.9.0 + +### Minor Changes + +- Update kysely adapter for connection + +### Patch Changes + +- Add promptestting addapter +- Updated dependencies +- Updated dependencies + - @authhero/adapter-interfaces@0.15.0 + ## 0.8.1 ### Patch Changes diff --git a/packages/kysely/package.json b/packages/kysely/package.json index f7626d1..412d667 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.8.1", + "version": "0.9.0", "files": [ "dist" ], diff --git a/packages/kysely/src/connections/create.ts b/packages/kysely/src/connections/create.ts index 3b7ab52..e9ea6a5 100644 --- a/packages/kysely/src/connections/create.ts +++ b/packages/kysely/src/connections/create.ts @@ -2,6 +2,7 @@ import { nanoid } from "nanoid"; import { Kysely } from "kysely"; import { Connection, ConnectionInsert } from "@authhero/adapter-interfaces"; import { Database } from "../db"; +import { flattenObject } from "../flatten"; export function create(db: Kysely) { return async ( @@ -17,7 +18,7 @@ export function create(db: Kysely) { await db .insertInto("connections") - .values({ ...connection, tenant_id }) + .values({ ...flattenObject(connection), tenant_id }) .execute(); return connection; diff --git a/packages/kysely/src/connections/get.ts b/packages/kysely/src/connections/get.ts index daa008b..a820222 100644 --- a/packages/kysely/src/connections/get.ts +++ b/packages/kysely/src/connections/get.ts @@ -2,6 +2,7 @@ import { Kysely } from "kysely"; import { removeNullProperties } from "../helpers/remove-nulls"; import { Connection } from "@authhero/adapter-interfaces"; import { Database } from "../db"; +import { unflattenObject } from "../flatten"; export function get(db: Kysely) { return async ( @@ -19,6 +20,6 @@ export function get(db: Kysely) { return null; } - return removeNullProperties(connection); + return removeNullProperties(unflattenObject(connection, ["options"])); }; } diff --git a/packages/kysely/src/connections/list.ts b/packages/kysely/src/connections/list.ts index 0635922..63ddae1 100644 --- a/packages/kysely/src/connections/list.ts +++ b/packages/kysely/src/connections/list.ts @@ -7,6 +7,7 @@ import { } from "@authhero/adapter-interfaces"; import { Database } from "../db"; import getCountAsInt from "../utils/getCountAsInt"; +import { unflattenObject } from "../flatten"; export function list(db: Kysely) { return async ( @@ -32,7 +33,9 @@ export function list(db: Kysely) { .executeTakeFirstOrThrow(); return { - connections: connections.map(removeNullProperties), + connections: connections.map((connecction) => + removeNullProperties(unflattenObject(connecction, ["options"])), + ), start: params.page * params.per_page, limit: params.per_page, length: getCountAsInt(count), diff --git a/packages/kysely/src/connections/update.ts b/packages/kysely/src/connections/update.ts index dc114c1..796b142 100644 --- a/packages/kysely/src/connections/update.ts +++ b/packages/kysely/src/connections/update.ts @@ -1,6 +1,7 @@ import { Kysely } from "kysely"; import { ConnectionInsert } from "@authhero/adapter-interfaces"; import { Database } from "../db"; +import { flattenObject } from "../flatten"; export function update(db: Kysely) { return async ( @@ -15,7 +16,7 @@ export function update(db: Kysely) { await db .updateTable("connections") - .set(sqlConnection) + .set(flattenObject(sqlConnection)) .where("connections.id", "=", connection_id) .where("connections.tenant_id", "=", tenant_id) .execute(); diff --git a/packages/kysely/src/db.ts b/packages/kysely/src/db.ts index dcb1bfe..edaa868 100644 --- a/packages/kysely/src/db.ts +++ b/packages/kysely/src/db.ts @@ -4,11 +4,12 @@ import { SqlUser } from "./users/User"; import { applicationSchema, Code, - Connection, + connectionSchema, Domain, Hook, loginSchema, Password, + PromptSetting, Session, SigningKey, Tenant, @@ -29,6 +30,11 @@ const sqlLoginSchema = flattenSchema(loginSchema).extend({ }); type SqlLogin = z.infer; +const sqlConnectionSchema = flattenSchema(connectionSchema).extend({ + tenant_id: z.string(), +}); +type SqlConnection = z.infer; + const sqlApplicationSchema = z.object({ ...applicationSchema.shape, tenant_id: z.string(), @@ -45,13 +51,14 @@ export interface Database { applications: z.infer; branding: SqlBranding; codes: Code & { tenant_id: string }; - connections: Connection & { tenant_id: string }; + connections: SqlConnection; domains: Domain & { tenant_id: string }; hooks: Hook & { tenant_id: string }; keys: SigningKey & { created_at: string }; logins: SqlLogin; logs: SqlLog; passwords: Password & { tenant_id: string }; + promptSettings: PromptSetting & { tenant_id: string }; users: SqlUser; sessions: Session & { tenant_id: string }; tenants: Tenant; diff --git a/packages/kysely/src/index.ts b/packages/kysely/src/index.ts index be85139..7a7d8f1 100644 --- a/packages/kysely/src/index.ts +++ b/packages/kysely/src/index.ts @@ -17,6 +17,7 @@ import { createHooksAdapter } from "./hooks"; import { createThemesAdapter } from "./themes"; import { DataAdapters } from "@authhero/adapter-interfaces"; import { createLoginAdapter } from "./logins"; +import { createPromptSettingsAdapter } from "./promptSettings"; export default function createAdapters(db: Kysely): DataAdapters { return { @@ -31,6 +32,7 @@ export default function createAdapters(db: Kysely): DataAdapters { logins: createLoginAdapter(db), logs: createLogsAdapter(db), passwords: createPasswordAdapter(db), + promptSettings: createPromptSettingsAdapter(db), users: createUsersAdapter(db), sessions: createSessionsAdapter(db), tenants: createTenantsAdapter(db), diff --git a/packages/kysely/src/promptSettings/get.ts b/packages/kysely/src/promptSettings/get.ts new file mode 100644 index 0000000..6a82fb0 --- /dev/null +++ b/packages/kysely/src/promptSettings/get.ts @@ -0,0 +1,23 @@ +import { Kysely } from "kysely"; +import { removeNullProperties } from "../helpers/remove-nulls"; +import { PromptSetting } from "@authhero/adapter-interfaces"; +import { Database } from "../db"; + +export function get(db: Kysely) { + return async (tenant_id: string): Promise => { + const [promptSetting] = await db + .selectFrom("promptSettings") + .where("promptSettings.tenant_id", "=", tenant_id) + .selectAll() + .execute(); + + return removeNullProperties({ + identifier_first: !!promptSetting?.identifier_first, + password_first: !!promptSetting?.password_first, + webauthn_platform_first_factor: + !!promptSetting?.webauthn_platform_first_factor, + universal_login_experience: + promptSetting?.universal_login_experience || "new", + }); + }; +} diff --git a/packages/kysely/src/promptSettings/index.ts b/packages/kysely/src/promptSettings/index.ts new file mode 100644 index 0000000..46915bf --- /dev/null +++ b/packages/kysely/src/promptSettings/index.ts @@ -0,0 +1,14 @@ +import { PromptSettingsAdapter } from "@authhero/adapter-interfaces"; +import { get } from "./get"; +import { set } from "./set"; +import { Kysely } from "kysely"; +import { Database } from "../db"; + +export function createPromptSettingsAdapter( + db: Kysely, +): PromptSettingsAdapter { + return { + get: get(db), + set: set(db), + }; +} diff --git a/packages/kysely/src/promptSettings/set.ts b/packages/kysely/src/promptSettings/set.ts new file mode 100644 index 0000000..492317e --- /dev/null +++ b/packages/kysely/src/promptSettings/set.ts @@ -0,0 +1,23 @@ +import { PromptSetting } from "@authhero/adapter-interfaces"; +import { Kysely } from "kysely"; +import { Database } from "../db"; + +export function set(db: Kysely) { + return async (tenant_id: string, promptSetting: PromptSetting) => { + try { + await db + .insertInto("promptSettings") + .values({ + ...promptSetting, + tenant_id, + }) + .execute(); + } catch (error) { + await db + .updateTable("promptSettings") + .set(promptSetting) + .where("tenant_id", "=", tenant_id) + .execute(); + } + }; +}