Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/context.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Context, RouteSchema } from 'elysia';
import type { GitHubDecorator } from './decorators/github';
import type { JwtDecorator } from './decorators/jwt';
import type { GitHubDecorator } from './decorators/auth/github';
import type { JwtDecorator } from './decorators/auth/jwt';

export type ApiContext<Route extends RouteSchema = RouteSchema> = Context<Route> & {
github: GitHubDecorator;
Expand Down
4 changes: 2 additions & 2 deletions src/decorators/github.ts → src/decorators/auth/github.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { z } from 'zod';
import { GitHubApiError } from '../errors';
import { assertNonNullish } from '../utils/assert';
import { GitHubApiError } from '../../errors';
import { assertNonNullish } from '../../utils/assert';

const GitHubUserSchema = z.object({
id: z.number(),
Expand Down
2 changes: 1 addition & 1 deletion src/decorators/jwt.ts → src/decorators/auth/jwt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
jwtVerify,
SignJWT
} from 'jose';
import { assertNonNullish } from '../utils/assert';
import { assertNonNullish } from '../../utils/assert';

const PRIVATE_KEY_PEM_PATH = process.env.JWT_PRIVATE_KEY_PATH;
const PUBLIC_KEY_PEM_PATH = process.env.JWT_PUBLIC_KEY_PATH;
Expand Down
4 changes: 2 additions & 2 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { cors } from '@elysiajs/cors';
import { openapi } from '@elysiajs/openapi';
import { Elysia } from 'elysia';
import packageJson from '../package.json';
import { GitHubDecorator } from './decorators/github';
import { JwtDecorator } from './decorators/jwt';
import { GitHubDecorator } from './decorators/auth/github';
import { JwtDecorator } from './decorators/auth/jwt';
import { GitHubApiError, GitHubAuthUnauthorizedError, NullishError } from './errors';
import {
GitHubAuthFinalizeSchema,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { afterEach, beforeEach, describe, expect, it, mock, spyOn } from 'bun:test';
import { GitHubDecorator } from '../../src/decorators/github';
import { GitHubApiError } from '../../src/errors';
import { GitHubDecorator } from '../../../src/decorators/auth/github';
import { GitHubApiError } from '../../../src/errors';

describe('decorators > github', () => {
let github: GitHubDecorator;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { beforeAll, describe, expect, it } from 'bun:test';
import { JwtDecorator } from '../../src/decorators/jwt';
import { JwtDecorator } from '../../../src/decorators/auth/jwt';

describe('decorators > jwt', () => {
let jwt: JwtDecorator;
Expand Down
2 changes: 1 addition & 1 deletion test/handlers/auth/github.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { afterEach, describe, expect, it, mock } from 'bun:test';
import type { ApiContext } from '../../../src/context';
import { JwtDecorator } from '../../../src/decorators/jwt';
import { JwtDecorator } from '../../../src/decorators/auth/jwt';
import { githubAuthInit } from '../../../src/handlers/auth/github';

describe('handlers > auth > github', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/handlers/auth/jwks.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, expect, it } from 'bun:test';
import type { ApiContext } from '../../../src/context';
import { JwtDecorator } from '../../../src/decorators/jwt';
import { JwtDecorator } from '../../../src/decorators/auth/jwt';
import { authJwks } from '../../../src/handlers/auth/jwks';

describe('handlers > auth > jwks', () => {
Expand Down
6 changes: 3 additions & 3 deletions test/server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('server', () => {
expect(data.state).toBeString();

// Verify the state JWT is valid
const { JwtDecorator } = await import('../src/decorators/jwt');
const { JwtDecorator } = await import('../src/decorators/auth/jwt');
const jwt = new JwtDecorator();
const verified = await jwt.verify(data.state);
expect(verified.valid).toBe(true);
Expand Down Expand Up @@ -82,7 +82,7 @@ describe('server', () => {
}) as typeof fetch);

// Create valid state token
const { JwtDecorator } = await import('../src/decorators/jwt');
const { JwtDecorator } = await import('../src/decorators/auth/jwt');
const jwt = new JwtDecorator();
const stateToken = await jwt.signOAuthJwt({
payload: {
Expand Down Expand Up @@ -144,7 +144,7 @@ describe('server', () => {
});

it('should return 401 on state mismatch', async () => {
const { JwtDecorator } = await import('../src/decorators/jwt');
const { JwtDecorator } = await import('../src/decorators/auth/jwt');
const jwt = new JwtDecorator();
const stateToken = await jwt.signOAuthJwt({
payload: { provider: 'github', token: 'a'.repeat(64), nonce: 'nonce' }
Expand Down
Loading