Skip to content

Commit

Permalink
fix imports
Browse files Browse the repository at this point in the history
  • Loading branch information
markusahlstrand committed Sep 2, 2024
1 parent f1d020c commit e72ced9
Show file tree
Hide file tree
Showing 29 changed files with 175 additions and 29 deletions.
5 changes: 0 additions & 5 deletions .changeset/serious-falcons-raise.md

This file was deleted.

6 changes: 6 additions & 0 deletions apps/auth0-proxy/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @authhero/auth0-proxy

## 0.1.1

### Patch Changes

- f1d020c: Fix to proxy the querystring

## 0.1.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion apps/auth0-proxy/package.json
Original file line number Diff line number Diff line change
@@ -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"
},
Expand Down
6 changes: 6 additions & 0 deletions apps/demo/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @authhero/demo

## 0.0.21

### Patch Changes

- [email protected]

## 0.0.20

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion apps/demo/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@authhero/demo",
"private": true,
"version": "0.0.20",
"version": "0.0.21",
"scripts": {
"dev": "bun --watch src/bun.ts"
},
Expand Down
7 changes: 7 additions & 0 deletions packages/adapter-interfaces/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-interfaces/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"type": "git",
"url": "https://github.com/markusahlstrand/authhero"
},
"version": "0.14.0",
"version": "0.15.0",
"files": [
"dist"
],
Expand Down
6 changes: 6 additions & 0 deletions packages/adapter-interfaces/src/adapters/PromptSettings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { PromptSetting } from "../types";

export interface PromptSettingsAdapter {
set: (tenant_id: string, promptSetting: PromptSetting) => Promise<void>;
get: (tenant_id: string) => Promise<PromptSetting>;
}
2 changes: 2 additions & 0 deletions packages/adapter-interfaces/src/adapters/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -27,6 +28,7 @@ export interface DataAdapters {
logins: LoginsAdapter;
logs: LogsDataAdapter;
passwords: PasswordsAdapter;
promptSettings: PromptSettingsAdapter;
sessions: SessionsAdapter;
tenants: TenantsDataAdapter;
themes: ThemesAdapter;
Expand Down
4 changes: 4 additions & 0 deletions packages/adapter-interfaces/src/types/Application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
19 changes: 17 additions & 2 deletions packages/adapter-interfaces/src/types/Connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<AuthorizationResponseType>().optional(),
response_mode: z.custom<AuthorizationResponseMode>().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(),
Expand Down
9 changes: 0 additions & 9 deletions packages/adapter-interfaces/src/types/LoginState.ts

This file was deleted.

10 changes: 10 additions & 0 deletions packages/adapter-interfaces/src/types/PromptSetting.ts
Original file line number Diff line number Diff line change
@@ -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<typeof promptSettingSchema>;
2 changes: 1 addition & 1 deletion packages/adapter-interfaces/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
8 changes: 8 additions & 0 deletions packages/authhero/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/authhero/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "authhero",
"version": "0.2.22",
"version": "0.2.23",
"files": [
"dist"
],
Expand Down
8 changes: 8 additions & 0 deletions packages/drizzle/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/drizzle/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"type": "git",
"url": "https://github.com/markusahlstrand/authhero"
},
"version": "0.1.38",
"version": "0.1.39",
"files": [
"dist"
],
Expand Down
13 changes: 13 additions & 0 deletions packages/kysely/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/kysely/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"type": "git",
"url": "https://github.com/markusahlstrand/authhero"
},
"version": "0.8.1",
"version": "0.9.0",
"files": [
"dist"
],
Expand Down
3 changes: 2 additions & 1 deletion packages/kysely/src/connections/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Database>) {
return async (
Expand All @@ -17,7 +18,7 @@ export function create(db: Kysely<Database>) {

await db
.insertInto("connections")
.values({ ...connection, tenant_id })
.values({ ...flattenObject(connection), tenant_id })
.execute();

return connection;
Expand Down
3 changes: 2 additions & 1 deletion packages/kysely/src/connections/get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Database>) {
return async (
Expand All @@ -19,6 +20,6 @@ export function get(db: Kysely<Database>) {
return null;
}

return removeNullProperties(connection);
return removeNullProperties(unflattenObject(connection, ["options"]));
};
}
5 changes: 4 additions & 1 deletion packages/kysely/src/connections/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Database>) {
return async (
Expand All @@ -32,7 +33,9 @@ export function list(db: Kysely<Database>) {
.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),
Expand Down
3 changes: 2 additions & 1 deletion packages/kysely/src/connections/update.ts
Original file line number Diff line number Diff line change
@@ -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<Database>) {
return async (
Expand All @@ -15,7 +16,7 @@ export function update(db: Kysely<Database>) {

await db
.updateTable("connections")
.set(sqlConnection)
.set(flattenObject(sqlConnection))
.where("connections.id", "=", connection_id)
.where("connections.tenant_id", "=", tenant_id)
.execute();
Expand Down
11 changes: 9 additions & 2 deletions packages/kysely/src/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import { SqlUser } from "./users/User";
import {
applicationSchema,
Code,
Connection,
connectionSchema,
Domain,
Hook,
loginSchema,
Password,
PromptSetting,
Session,
SigningKey,
Tenant,
Expand All @@ -29,6 +30,11 @@ const sqlLoginSchema = flattenSchema(loginSchema).extend({
});
type SqlLogin = z.infer<typeof sqlLoginSchema>;

const sqlConnectionSchema = flattenSchema(connectionSchema).extend({
tenant_id: z.string(),
});
type SqlConnection = z.infer<typeof sqlConnectionSchema>;

const sqlApplicationSchema = z.object({
...applicationSchema.shape,
tenant_id: z.string(),
Expand All @@ -45,13 +51,14 @@ export interface Database {
applications: z.infer<typeof sqlApplicationSchema>;
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;
Expand Down
2 changes: 2 additions & 0 deletions packages/kysely/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Database>): DataAdapters {
return {
Expand All @@ -31,6 +32,7 @@ export default function createAdapters(db: Kysely<Database>): DataAdapters {
logins: createLoginAdapter(db),
logs: createLogsAdapter(db),
passwords: createPasswordAdapter(db),
promptSettings: createPromptSettingsAdapter(db),
users: createUsersAdapter(db),
sessions: createSessionsAdapter(db),
tenants: createTenantsAdapter(db),
Expand Down
23 changes: 23 additions & 0 deletions packages/kysely/src/promptSettings/get.ts
Original file line number Diff line number Diff line change
@@ -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<Database>) {
return async (tenant_id: string): Promise<PromptSetting> => {
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",
});
};
}
Loading

0 comments on commit e72ced9

Please sign in to comment.