Skip to content

Commit

Permalink
Merge pull request #16 from markusahlstrand/enter-email
Browse files Browse the repository at this point in the history
migrate enter-email page
  • Loading branch information
markusahlstrand authored Jan 14, 2025
2 parents 3faabc5 + 0484907 commit ec45fab
Show file tree
Hide file tree
Showing 80 changed files with 2,196 additions and 292 deletions.
19 changes: 19 additions & 0 deletions apps/demo/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# @authhero/demo

## 0.6.0

### Minor Changes

- migrate the enter-email page

### Patch Changes

- Updated dependencies
- [email protected]

## 0.5.16

### Patch Changes

- Updated dependencies
- @authhero/kysely-adapter@0.28.0
- [email protected]

## 0.5.15

### Patch Changes
Expand Down
9 changes: 5 additions & 4 deletions apps/demo/package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
{
"name": "@authhero/demo",
"private": true,
"version": "0.5.15",
"version": "0.6.0",
"scripts": {
"dev": "bun --watch src/bun.ts"
},
"dependencies": {
"@authhero/kysely-adapter": "^0.27.0",
"@authhero/kysely-adapter": "^0.28.1",
"@hono/swagger-ui": "^0.5.0",
"@hono/zod-openapi": "^0.18.3",
"@peculiar/x509": "^1.12.3",
"authhero": "^0.36.0",
"hono": "^4.6.13",
"authhero": "^0.37.0",
"hono": "^4.6.15",
"hono-openapi-middlewares": "^1.0.11",
"kysely": "^0.27.4",
"kysely-bun-sqlite": "^0.3.2",
"oslo": "^1.2.1"
}
Expand Down
28 changes: 3 additions & 25 deletions apps/demo/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ import {
registerComponent,
} from "hono-openapi-middlewares";
import packageJson from "../package.json";
import { Bindings } from "./types/Bindings";

export default function create(dataAdapter: DataAdapters) {
const app = new OpenAPIHono<{ Bindings: Bindings }>();
const { app } = init({
dataAdapter,
});

app
.onError((err, ctx) => {
Expand All @@ -31,29 +32,6 @@ export default function create(dataAdapter: DataAdapters) {
});
})
.get("/docs", swaggerUI({ url: "/spec" }));
app.use(createAuthMiddleware(app));
app.use(registerComponent(app));

const { managementApp, oauthApp } = init({
dataAdapter,
});

managementApp.doc("/spec", (c) => ({
openapi: "3.0.0",
info: {
version: "1.0.0",
title: "Management API",
},
servers: [
{
url: new URL(c.req.url).origin,
description: "Current environment",
},
],
}));

app.route("/api/v2", managementApp);
app.route("/", oauthApp);

return app;
}
6 changes: 6 additions & 0 deletions packages/adapter-interfaces/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @authhero/adapter-interfaces

## 0.36.0

### Minor Changes

- use default listparams

## 0.35.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.35.0",
"version": "0.36.0",
"files": [
"dist"
],
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-interfaces/src/adapters/Applications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export interface ApplicationsAdapter {
remove(tenant_id: string, id: string): Promise<boolean>;
list(
tenant_id: string,
params: ListParams,
params?: ListParams,
): Promise<{ applications: Application[]; totals?: Totals }>;
update(
tenant_id: string,
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-interfaces/src/adapters/Codes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export interface CodesAdapter {
code_id: string,
type: CodeType,
) => Promise<Code | null>;
list: (tenant_id: string, params: ListParams) => Promise<ListCodesResponse>;
list: (tenant_id: string, params?: ListParams) => Promise<ListCodesResponse>;
used: (tenant_id: string, code_id: string) => Promise<boolean>;
remove: (tenant_id: string, code_id: string) => Promise<boolean>;
}
5 changes: 4 additions & 1 deletion packages/adapter-interfaces/src/adapters/Connections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,8 @@ export interface ConnectionsAdapter {
connection_id: string,
params: Partial<ConnectionInsert>,
): Promise<boolean>;
list(tenant_id: string, params: ListParams): Promise<ListConnectionsResponse>;
list(
tenant_id: string,
params?: ListParams,
): Promise<ListConnectionsResponse>;
}
2 changes: 1 addition & 1 deletion packages/adapter-interfaces/src/adapters/Domains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ interface ListDomainsResponse extends Totals {

export interface DomainsAdapter {
create(tenant_id: string, params: Domain): Promise<Domain>;
list(tenant_id: string, params: ListParams): Promise<ListDomainsResponse>;
list(tenant_id: string, params?: ListParams): Promise<ListDomainsResponse>;
}
2 changes: 1 addition & 1 deletion packages/adapter-interfaces/src/adapters/Hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ export interface HooksAdapter {
hook_id: string,
hook: Partial<HookInsert>,
) => Promise<boolean>;
list: (tenant_id: string, params: ListParams) => Promise<ListHooksResponse>;
list: (tenant_id: string, params?: ListParams) => Promise<ListHooksResponse>;
}
2 changes: 1 addition & 1 deletion packages/adapter-interfaces/src/adapters/Logs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ interface ListLogsResponse extends Totals {

export interface LogsDataAdapter {
create(tenantId: string, params: Log): Promise<Log>;
list(tenantId: string, params: ListParams): Promise<ListLogsResponse>;
list(tenantId: string, params?: ListParams): Promise<ListLogsResponse>;
get(tenantId: string, logId: string): Promise<LogsResponse | null>;
}
2 changes: 1 addition & 1 deletion packages/adapter-interfaces/src/adapters/Sessions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export interface ListSesssionsResponse extends Totals {
export interface SessionsAdapter {
create: (tenant_id: string, session: SessionInsert) => Promise<Session>;
get: (tenant_id: string, id: string) => Promise<Session | null>;
list(tenantId: string, params: ListParams): Promise<ListSesssionsResponse>;
list(tenantId: string, params?: ListParams): Promise<ListSesssionsResponse>;
update: (
tenant_id: string,
id: string,
Expand Down
2 changes: 1 addition & 1 deletion packages/adapter-interfaces/src/adapters/Tenants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export interface CreateTenantParams {
export interface TenantsDataAdapter {
create(params: CreateTenantParams): Promise<Tenant>;
get(id: string): Promise<Tenant | null>;
list(params: ListParams): Promise<{ tenants: Tenant[]; totals?: Totals }>;
list(params?: ListParams): Promise<{ tenants: Tenant[]; totals?: Totals }>;
update(id: string, tenant: Partial<Tenant>): Promise<void>;
remove(tenantId: string): Promise<boolean>;
}
2 changes: 1 addition & 1 deletion packages/adapter-interfaces/src/adapters/Users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export interface UserDataAdapter {
get(tenant_id: string, id: string): Promise<User | null>;
create(tenantId: string, user: UserInsert): Promise<User>;
remove(tenantId: string, id: string): Promise<boolean>;
list(tenantId: string, params: ListParams): Promise<ListUsersResponse>;
list(tenantId: string, params?: ListParams): Promise<ListUsersResponse>;
update(tenantId: string, id: string, user: Partial<User>): Promise<boolean>;
unlink(
tenantId: string,
Expand Down
19 changes: 19 additions & 0 deletions packages/authhero/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# authhero

## 0.37.0

### Minor Changes

- migrate the enter-email page

## 0.36.2

### Patch Changes

- Remove list params where not needed

## 0.36.1

### Patch Changes

- Updated dependencies
- @authhero/adapter-interfaces@0.36.0

## 0.36.0

### Minor Changes
Expand Down
3 changes: 2 additions & 1 deletion packages/authhero/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "authhero",
"version": "0.36.0",
"version": "0.37.0",
"files": [
"dist"
],
Expand Down Expand Up @@ -39,6 +39,7 @@
"arctic": "^2.3.3",
"bcrypt": "^5.1.1",
"bcryptjs": "^2.4.3",
"classnames": "^2.5.1",
"i18next": "^24.2.0",
"nanoid": "^5.0.8",
"oslo": "^1.2.1",
Expand Down
52 changes: 0 additions & 52 deletions packages/authhero/src/auth-app.ts

This file was deleted.

24 changes: 24 additions & 0 deletions packages/authhero/src/components/AppLogo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { VendorSettings } from "@authhero/adapter-interfaces";
import type { FC } from "hono/jsx";

type AppLogoProps = {
vendorSettings: VendorSettings;
};

const AppLogo: FC<AppLogoProps> = ({ vendorSettings }) => {
if (vendorSettings?.logoUrl) {
return (
<div className="flex h-9 items-center">
<img
src={vendorSettings.logoUrl}
className="max-h-full"
alt="Vendor logo"
/>
</div>
);
}

return <></>;
};

export default AppLogo;
68 changes: 68 additions & 0 deletions packages/authhero/src/components/Button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
import cn from "classnames";
import Spinner from "./Spinner";
import { PropsWithChildren } from "hono/jsx";

// in React we would do
// interface Props extends ButtonHTMLAttributes<HTMLButtonElement>
// to get all the DOM attributes of a button
type Props = {
className?: string;
Component?: string;
variant?: "primary" | "secondary" | "custom";
// in Nextjs & React we use default DOM element types...
href?: string;
disabled?: boolean;
isLoading?: boolean;
id?: string;
};

const Button = ({
children,
className,
Component = "button",
variant = "primary",
href,
disabled,
isLoading,
id,
}: PropsWithChildren<Props>) => {
const hrefProps = Component === "a" ? { href } : {};
return (
// @ts-expect-error - refactor this when migrating to authhero
<Component
class={cn(
"relative w-full rounded-lg text-center",
className,
{
"px-4 py-5": variant !== "custom",
"bg-primary text-textOnPrimary hover:bg-primaryHover":
variant === "primary",
"border border-gray-300 bg-white text-black": variant === "secondary",
"pointer-events-none cursor-not-allowed opacity-40": disabled,
},
// focus styles
"focus:outline-none focus:ring",
)}
type="submit"
disabled={disabled}
id={id}
{...hrefProps}
>
<span
className={`
flex items-center justify-center space-x-2
${isLoading ? "invisible h-0" : "visible h-auto"}
`}
>
{children}
</span>
{isLoading && (
<div className="absolute left-0 top-0 flex h-full w-full items-center justify-center">
<Spinner size="medium" />
</div>
)}
</Component>
);
};

export default Button;
Loading

0 comments on commit ec45fab

Please sign in to comment.