testing generic deploy

This commit is contained in:
Devin Zuczek
2026-06-29 21:52:50 -04:00
parent 3affabd280
commit 69b89e2dc4
79 changed files with 399 additions and 307 deletions
+2 -2
View File
@@ -21,7 +21,7 @@ export const SCHEMA_DDL: string[] = [
`CREATE INDEX IF NOT EXISTS idx_accounts_username_lower ON accounts (username_lower)`,
]
/** Client-facing account shape (PascalCase, matches the C# `Account`). */
/** Client-facing account shape (PascalCase, as the client expects). */
export interface Account {
AccountId: number
Username: string
@@ -61,7 +61,7 @@ export function randomUsername(): string {
}
/**
* Build a full account object from an id, applying the C# fallbacks for any
* Build a full account object from an id, applying default fallbacks for any
* column the caller doesn't override. Used both to synthesize accounts that
* aren't in the DB and as the base for a freshly created account.
*/
+4 -4
View File
@@ -12,7 +12,7 @@ import type { App } from './context'
const TOKEN_SCOPE =
'offline_access profile rn rn.accounts rn.accounts.gc rn.api rn.chat rn.clubs rn.commerce rn.match.read rn.match.write rn.notify rn.rooms rn.storage'
/** C# `PlatformType` enum names by value, used for the token's `platform` claim. */
/** Platform-type enum names by value, used for the token's `platform` claim. */
const PLATFORM_TYPES: Record<number, string> = {
[-1]: 'All',
0: 'Steam',
@@ -131,8 +131,8 @@ const app = new Hono<App>()
// OAuth token endpoint — accepts a form-urlencoded body and issues a JWT.
.post('/connect/token', async (c) => {
// The C# reads `grant_type`, `account_id`, `platform_id` and `platform` from
// the form body.
// Reads `grant_type`, `account_id`, `platform_id` and `platform` from the
// form body.
const body = await c.req.parseBody().catch(() => ({}) as Record<string, unknown>)
const grantType = typeof body.grant_type === 'string' ? body.grant_type : ''
const platformId = typeof body.platform_id === 'string' ? body.platform_id : ''
@@ -169,7 +169,7 @@ const app = new Hono<App>()
})
})
// Developer role lookup. Not implemented in the C# source either.
// Developer role lookup. Not implemented yet.
.get('/role/developer/:id', (c) => {
const { id } = c.req.param()
logger.info('developer role lookup', { id })
+4 -5
View File
@@ -1,12 +1,12 @@
/**
* Minimal HS256 JWT generation, mirroring the C# `JwtTokenService.GenerateToken`.
* Minimal HS256 JWT generation.
*
* No real signing-key binding yet — uses a placeholder dev secret. Swap this for
* a secret binding (e.g. `c.env.JWT_SECRET`) before this is used for anything real.
*/
const DEV_SECRET = 'dev-insecure-signing-key-change-me'
/** Token lifetime in seconds (matches `expires_in` in the C# response). */
/** Token lifetime in seconds (mirrored in the `expires_in` response field). */
export const TOKEN_TTL_SECONDS = 3600
function base64url(input: ArrayBuffer | string): string {
@@ -18,7 +18,7 @@ function base64url(input: ArrayBuffer | string): string {
return btoa(binary).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '')
}
/** Scopes the C# `JwtTokenService` stamps onto every token (as a claim array). */
/** Scopes stamped onto every token (as a claim array). */
const TOKEN_SCOPES = [
'profile',
'rn',
@@ -36,7 +36,7 @@ const TOKEN_SCOPES = [
'offline_access',
]
/** Roles the C# grants — the client needs `gameClient` to operate. */
/** Roles granted — the client needs `gameClient` to operate. */
const TOKEN_ROLES = ['gameClient', 'developer', 'moderator']
export async function generateToken(
@@ -47,7 +47,6 @@ export async function generateToken(
): Promise<string> {
const now = Math.floor(Date.now() / 1000)
const header = { alg: 'HS256', typ: 'JWT' }
// Mirror the claim set produced by the C# `JwtTokenService.GenerateToken`.
// The client reads `role`/`scope` (and expects a well-formed iss/aud) to
// authorize itself; a token with only `sub` is rejected before login finishes.
const payload = {
+2 -2
View File
@@ -12,7 +12,7 @@ declare module 'cloudflare:test' {
interface ProvidedEnv extends Env {}
}
const ORIGIN = 'https://auth.rec.djdevin.net'
const ORIGIN = 'https://example.com'
// The Orientation room (RoomId 13) new accounts are placed into on signup.
const ORIENTATION_SCENE = 'c79709d8-a31b-48aa-9eb8-cc31ba9505e8'
@@ -63,7 +63,7 @@ describe('auth worker routes', () => {
const res = await exports.default.fetch(`${ORIGIN}/eac/challenge`)
expect(res.status).toBe(200)
expect(res.headers.get('content-type')).toContain('text/plain')
// Matches the C#'s JSON/eacchallenge.txt content (BOM is stripped on read).
// EAC challenge content (BOM is stripped on read).
expect(await res.text()).toBe('"AA=="')
})