From 67f234d44b281b0f6ed1d2652621a1ca603ed855 Mon Sep 17 00:00:00 2001 From: Hernan Alvarado Date: Fri, 5 Jun 2026 13:12:05 -0500 Subject: [PATCH 1/4] fix(react-router): fix non-portable type definitions --- packages/device/package.json | 2 +- packages/elysia/package.json | 4 +- packages/express/package.json | 4 +- packages/hono/package.json | 4 +- packages/integration/package.json | 2 +- packages/rate-limiter/package.json | 2 +- packages/react-router/package.json | 2 +- packages/react-router/src/@types/api.ts | 73 ++++++++++++++++++ packages/react-router/src/@types/core.ts | 3 +- packages/react-router/src/@types/index.ts | 77 +------------------ packages/react-router/src/client.ts | 3 - packages/react-router/src/client.tsx | 11 +++ packages/react-router/src/createAuth.ts | 17 +++- packages/react-router/src/index.ts | 2 +- packages/react-router/src/lib/api.ts | 4 +- .../test/context/provider.test.tsx | 2 +- .../test/context/redirect.test.tsx | 2 +- packages/react-router/tsdown.config.ts | 3 +- packages/react/package.json | 2 +- packages/react/tsdown.config.ts | 4 + 20 files changed, 123 insertions(+), 100 deletions(-) create mode 100644 packages/react-router/src/@types/api.ts delete mode 100644 packages/react-router/src/client.ts create mode 100644 packages/react-router/src/client.tsx diff --git a/packages/device/package.json b/packages/device/package.json index 928305cb..3feb13d5 100644 --- a/packages/device/package.json +++ b/packages/device/package.json @@ -15,7 +15,7 @@ "format": "oxfmt", "format:check": "oxfmt --check", "type-check": "tsc --noEmit", - "clean:cts": "if [ -d dist ]; then find dist -type f -name \"*.cts\" -delete; fi", + "clean:cts": "find dist -type f -name \"*.cts\" -delete", "prepublishOnly": "pnpm clean:cts && pnpm build && pnpm clean:cts" }, "repository": { diff --git a/packages/elysia/package.json b/packages/elysia/package.json index 7496bd46..a5895402 100644 --- a/packages/elysia/package.json +++ b/packages/elysia/package.json @@ -16,7 +16,7 @@ "format:check": "oxfmt --check", "type-check": "tsc --noEmit", "clean": "rm -rf dist src/_core src/oauth", - "clean:cts": "if [ -d dist ]; then find dist -type f -name \"*.cts\" -delete; fi", + "clean:cts": "find dist -type f -name \"*.cts\" -delete", "prepublishOnly": "pnpm sync:modules && pnpm build && pnpm clean:cts", "sync:modules": "node ../shared/scripts/modules.js" }, @@ -90,4 +90,4 @@ "elysia": ">=1.0.0" }, "packageManager": "pnpm@10.15.0" -} \ No newline at end of file +} diff --git a/packages/express/package.json b/packages/express/package.json index 1ef1ba3f..be76cc2b 100644 --- a/packages/express/package.json +++ b/packages/express/package.json @@ -16,7 +16,7 @@ "format:check": "oxfmt --check", "type-check": "tsc --noEmit", "clean": "rm -rf dist src/_core src/oauth", - "clean:cts": "if [ -d dist ]; then find dist -type f -name \"*.cts\" -delete; fi", + "clean:cts": "find dist -type f -name \"*.cts\" -delete", "prepublishOnly": "pnpm sync:modules && pnpm build && pnpm clean:cts", "sync:modules": "node ../shared/scripts/modules.js" }, @@ -88,4 +88,4 @@ "express": ">=4.0.0" }, "packageManager": "pnpm@10.15.0" -} \ No newline at end of file +} diff --git a/packages/hono/package.json b/packages/hono/package.json index 4b6d28da..0ae179eb 100644 --- a/packages/hono/package.json +++ b/packages/hono/package.json @@ -16,7 +16,7 @@ "format:check": "oxfmt --check", "type-check": "tsc --noEmit", "clean": "rm -rf dist src/_core src/oauth", - "clean:cts": "if [ -d dist ]; then find dist -type f -name \"*.cts\" -delete; fi", + "clean:cts": "find dist -type f -name \"*.cts\" -delete", "prepublishOnly": "pnpm sync:modules && pnpm build && pnpm clean:cts", "sync:modules": "node ../shared/scripts/modules.js" }, @@ -86,4 +86,4 @@ "hono": ">=4.0.0" }, "packageManager": "pnpm@10.15.0" -} \ No newline at end of file +} diff --git a/packages/integration/package.json b/packages/integration/package.json index e6485f3f..0574805b 100644 --- a/packages/integration/package.json +++ b/packages/integration/package.json @@ -16,7 +16,7 @@ "format:check": "oxfmt --check", "type-check": "tsc --noEmit", "clean": "rm -rf dist src/_core src/oauth", - "clean:cts": "if [ -d dist ]; then find dist -type f -name \"*.cts\" -delete; fi", + "clean:cts": "find dist -type f -name \"*.cts\" -delete", "prepublishOnly": "pnpm clean:cts && pnpm build && pnpm clean:cts", "sync:modules": "node ../shared/scripts/modules.js" }, diff --git a/packages/rate-limiter/package.json b/packages/rate-limiter/package.json index 9170449b..b7241e86 100644 --- a/packages/rate-limiter/package.json +++ b/packages/rate-limiter/package.json @@ -16,7 +16,7 @@ "format:check": "oxfmt --check", "type-check": "tsc --noEmit", "clean": "rm -rf dist", - "clean:cts": "if [ -d dist ]; then find dist -type f -name \"*.cts\" -delete; fi", + "clean:cts": "find dist -type f -name \"*.cts\" -delete", "prepublishOnly": "pnpm build && pnpm clean:cts" }, "repository": { diff --git a/packages/react-router/package.json b/packages/react-router/package.json index 622f2722..ce058161 100644 --- a/packages/react-router/package.json +++ b/packages/react-router/package.json @@ -16,7 +16,7 @@ "test:watch": "vitest", "test:coverage": "vitest --run --coverage", "clean": "rm -rf dist src/_core src/oauth", - "clean:cts": "if [ -d dist ]; then find dist -type f -name \"*.cts\" -delete; fi", + "clean:cts": "find dist -type f -name \"*.cts\" -delete", "prepublishOnly": "pnpm sync:modules && pnpm build && pnpm clean:cts", "sync:modules": "node ../shared/scripts/modules.js --from react" }, diff --git a/packages/react-router/src/@types/api.ts b/packages/react-router/src/@types/api.ts new file mode 100644 index 00000000..78d1ca4f --- /dev/null +++ b/packages/react-router/src/@types/api.ts @@ -0,0 +1,73 @@ +/** + * React Router (framework) integration types: options include the current `Request`, and result types + * distinguish JSON API results from full `Response` objects when returning from loaders/actions. + */ +import type { + Prettify, + SignInAPIOptions, + SignInAPIReturn, + SignInCredentialsAPIOptions, + SignInCredentialsAPIReturn, + SignOutAPIOptions, + SignOutAPIReturn, + UpdateSessionAPIOptions, + UpdateSessionAPIReturn, + UpdateSessionOptions, + User, +} from "@aura-stack/react/types" + +/** Core `signIn` options plus the incoming `Request` (required in React Router data APIs). */ +export type ReactRouterSignInAPIOptions = Prettify< + SignInAPIOptions & { + request: Request + } +> + +/** + * Credentials sign-in options plus `request` and an optional `redirect` flag matching the server helper behavior. + */ +export type ReactRouterSignInCredentialsAPIOptions = Prettify< + SignInCredentialsAPIOptions & { + request: Request + redirect?: boolean + } +> + +/** Sign-out options plus the incoming `Request` for cookie and CSRF handling. */ +export type ReactRouterSignOutAPIOptions = Prettify & { request: Request }> + +export type ReactRouterSignOutReturn = Options extends { redirect: false } + ? SignOutAPIReturn + : Response + +/** + * Result of the React Router `api.signIn` helper: the JSON API object when `redirect: false`, + * otherwise the `Response` from `toResponse()` (redirect / navigation response). + */ +export type ReactRouterSignInReturn = Options extends { + redirect: false +} + ? SignInAPIReturn + : Response + +/** + * Result of the React Router `api.signInCredentials` helper: same discriminant. + */ +export type ReactRouterSignInCredentialsReturn = Options extends { + redirect: false +} + ? SignInCredentialsAPIReturn + : Response + +export type ReactRouterUpdateSessionAPIOptions = Prettify< + Partial> & { request: Request; session: UpdateSessionOptions["session"] } +> + +export type ReactRouterUpdateSessionReturn< + Options extends ReactRouterUpdateSessionAPIOptions, + DefaultUser extends User = User, +> = Options extends { + redirect: false +} + ? UpdateSessionAPIReturn + : Response diff --git a/packages/react-router/src/@types/core.ts b/packages/react-router/src/@types/core.ts index 6a30620e..d1a5664e 100644 --- a/packages/react-router/src/@types/core.ts +++ b/packages/react-router/src/@types/core.ts @@ -1,2 +1 @@ -/** Re-exports `@aura-stack/react/types` for `@aura-stack/react-router` consumers. */ -export type * from "@aura-stack/react/types" +export * from "@aura-stack/react/types" diff --git a/packages/react-router/src/@types/index.ts b/packages/react-router/src/@types/index.ts index f0783dfd..40a2434c 100644 --- a/packages/react-router/src/@types/index.ts +++ b/packages/react-router/src/@types/index.ts @@ -1,75 +1,2 @@ -/** - * React Router (framework) integration types: options include the current `Request`, and result types - * distinguish JSON API results from full `Response` objects when returning from loaders/actions. - */ -import type { - Prettify, - SignInAPIOptions, - SignInAPIReturn, - SignInCredentialsAPIOptions, - SignInCredentialsAPIReturn, - SignOutAPIOptions, - SignOutAPIReturn, - UpdateSessionAPIOptions, - UpdateSessionAPIReturn, - UpdateSessionOptions, - User, -} from "@/@types/core" - -export type * from "./core" - -/** Core `signIn` options plus the incoming `Request` (required in React Router data APIs). */ -export type ReactRouterSignInAPIOptions = Prettify< - SignInAPIOptions & { - request: Request - } -> - -/** - * Credentials sign-in options plus `request` and an optional `redirect` flag matching the server helper behavior. - */ -export type ReactRouterSignInCredentialsAPIOptions = Prettify< - SignInCredentialsAPIOptions & { - request: Request - redirect?: boolean - } -> - -/** Sign-out options plus the incoming `Request` for cookie and CSRF handling. */ -export type ReactRouterSignOutAPIOptions = Prettify & { request: Request }> - -export type ReactRouterSignOutReturn = Options extends { redirect: false } - ? SignOutAPIReturn - : Response - -/** - * Result of the React Router `api.signIn` helper: the JSON API object when `redirect: false`, - * otherwise the `Response` from `toResponse()` (redirect / navigation response). - */ -export type ReactRouterSignInReturn = Options extends { - redirect: false -} - ? SignInAPIReturn - : Response - -/** - * Result of the React Router `api.signInCredentials` helper: same discriminant as {@link ReactRouterSignInReturn}. - */ -export type ReactRouterSignInCredentialsReturn = Options extends { - redirect: false -} - ? SignInCredentialsAPIReturn - : Response - -export type ReactRouterUpdateSessionAPIOptions = Prettify< - Partial> & { request: Request; session: UpdateSessionOptions["session"] } -> - -export type ReactRouterUpdateSessionReturn< - Options extends ReactRouterUpdateSessionAPIOptions, - DefaultUser extends User = User, -> = Options extends { - redirect: false -} - ? UpdateSessionAPIReturn - : Response +export * from "@/@types/api" +export * from "@/@types/core" diff --git a/packages/react-router/src/client.ts b/packages/react-router/src/client.ts deleted file mode 100644 index 787e295f..00000000 --- a/packages/react-router/src/client.ts +++ /dev/null @@ -1,3 +0,0 @@ -export { createAuthClient, useAuthActions, useSession, useSignIn, useSignInCredentials, useSignOut } from "@aura-stack/react" -export type { AuthClientOptions } from "@aura-stack/react" -export { AuthProvider, type AuthProviderProps } from "@/context" diff --git a/packages/react-router/src/client.tsx b/packages/react-router/src/client.tsx new file mode 100644 index 00000000..1d3c424f --- /dev/null +++ b/packages/react-router/src/client.tsx @@ -0,0 +1,11 @@ +export { + createAuthClient, + useAuthActions, + useSession, + useSignIn, + useSignInCredentials, + useUpdateSession, + useSignOut, + type AuthClientOptions, +} from "@aura-stack/react" +export { AuthProvider, type AuthProviderProps } from "@/context" diff --git a/packages/react-router/src/createAuth.ts b/packages/react-router/src/createAuth.ts index 5b1136ae..693ab35b 100644 --- a/packages/react-router/src/createAuth.ts +++ b/packages/react-router/src/createAuth.ts @@ -1,12 +1,23 @@ import { createAuth as createAuthInstance } from "@aura-stack/react/server" import { api } from "@/lib/api" import type { AuthConfig } from "@aura-stack/react" -import type { Identities, FromShapeToObject } from "@aura-stack/react/identity" +import type { Identities } from "@aura-stack/react/identity" export const createAuth = (config: AuthConfig) => { - const auth = createAuthInstance(config) + const auth = createAuthInstance(config) return { + /** + * The core auth instance. It can be used to advanced use cases, such as creating custom behaviors. + * For most use cases, the `api` property should be sufficient, as it provides a higher-level API for common authentication tasks. + */ core: auth, - api: api>(auth), + /** + * Built-in API functions for server-side operations related to the auth flows. + */ + api: api(auth), + /** + * The handlers object contains the HTTP request handlers. + */ + handlers: auth.handlers, } } diff --git a/packages/react-router/src/index.ts b/packages/react-router/src/index.ts index 81ffe9c6..3808080f 100644 --- a/packages/react-router/src/index.ts +++ b/packages/react-router/src/index.ts @@ -1,2 +1,2 @@ export { createAuth } from "@/createAuth" -export type { User, Session, AuthConfig, AuthInstance } from "@aura-stack/react" +export type { User, Session, AuthConfig, AuthInstance } from "@/@types/core" diff --git a/packages/react-router/src/lib/api.ts b/packages/react-router/src/lib/api.ts index 55f85e50..557c1e8f 100644 --- a/packages/react-router/src/lib/api.ts +++ b/packages/react-router/src/lib/api.ts @@ -7,7 +7,7 @@ import type { ReactRouterSignOutReturn, ReactRouterUpdateSessionReturn, ReactRouterUpdateSessionAPIOptions, -} from "@/@types" +} from "@/@types/index" import type { AuthInstance, Session, User } from "@aura-stack/react" import type { BuiltInOAuthProvider, GetSessionAPIOptions, LiteralUnion } from "@aura-stack/react/types" @@ -30,7 +30,7 @@ export const signIn = ({ api }: AuthInstance( providerId: LiteralUnion, options?: Options - ): Promise> => { + ) => { const signIn = await api.signIn(providerId, options) if (options?.redirect === false) { return signIn as ReactRouterSignInReturn diff --git a/packages/react-router/test/context/provider.test.tsx b/packages/react-router/test/context/provider.test.tsx index 1c3b55c3..f2bfb8c6 100644 --- a/packages/react-router/test/context/provider.test.tsx +++ b/packages/react-router/test/context/provider.test.tsx @@ -1,6 +1,6 @@ import { describe, expect, test, vi, beforeEach } from "vitest" import { render, screen } from "@testing-library/react" -import type { AuthClientInstance, AuthProviderProps } from "@/@types" +import type { AuthClientInstance, AuthProviderProps } from "@/@types/index" /** * vi.hoisted ensures mock references are stable across the hoisting boundary — diff --git a/packages/react-router/test/context/redirect.test.tsx b/packages/react-router/test/context/redirect.test.tsx index 284d44dc..ca31ce71 100644 --- a/packages/react-router/test/context/redirect.test.tsx +++ b/packages/react-router/test/context/redirect.test.tsx @@ -1,7 +1,7 @@ import { describe, expect, test, vi, beforeEach } from "vitest" import { render, screen, fireEvent, act } from "@testing-library/react" import { useSignOut, useSignIn } from "@aura-stack/react" -import type { AuthClientInstance } from "@/@types" +import type { AuthClientInstance } from "@/@types/index" const mockNavigate = vi.hoisted(() => vi.fn()) diff --git a/packages/react-router/tsdown.config.ts b/packages/react-router/tsdown.config.ts index fe987fdb..02970214 100644 --- a/packages/react-router/tsdown.config.ts +++ b/packages/react-router/tsdown.config.ts @@ -3,9 +3,10 @@ import { tsdownConfig } from "@aura-stack/tsdown-config" export default defineConfig({ ...tsdownConfig, + platform: "neutral", entry: [ "src/index.ts", - "src/client.ts", + "src/client.tsx", "src/oauth/index.ts", "src/_core/identity.ts", "src/_core/crypto.ts", diff --git a/packages/react/package.json b/packages/react/package.json index 655fd31a..2954a3be 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -16,7 +16,7 @@ "format:check": "oxfmt --check", "type-check": "tsc --noEmit", "clean": "rm -rf dist src/_core src/oauth", - "clean:cts": "if [ -d dist ]; then find dist -type f -name \"*.cts\" -delete; fi", + "clean:cts": "find dist -type f -name \"*.cts\" -delete", "prepublishOnly": "pnpm sync:modules && pnpm build && pnpm clean:cts", "sync:modules": "node ../shared/scripts/modules.js" }, diff --git a/packages/react/tsdown.config.ts b/packages/react/tsdown.config.ts index 66ab5f5b..39d05b03 100644 --- a/packages/react/tsdown.config.ts +++ b/packages/react/tsdown.config.ts @@ -16,4 +16,8 @@ export default defineConfig({ "src/_core/cookies.ts", "src/@types/index.ts", ], + deps: { + ...tsdownConfig.deps, + neverBundle: ["react", "react-dom"], + }, }) From 3497ff6aa89bd03f2c607e2f30d14fe2ac17caa4 Mon Sep 17 00:00:00 2001 From: Hernan Alvarado Date: Fri, 5 Jun 2026 15:20:16 -0500 Subject: [PATCH 2/4] chore: enable verbatimModuleSyntax and fix portable type exports --- apps/bun/src/lib/auth.ts | 7 ++----- apps/cloudflare/src/auth.ts | 4 ++-- apps/deno/src/auth.ts | 4 ++-- apps/oak/src/auth.ts | 4 ++-- apps/supabase/functions/_shared/auth.ts | 4 ++-- .../src/actions/signIn/authorization-url.ts | 2 +- .../core/src/actions/signIn/authorization.ts | 2 +- packages/core/src/router/context.ts | 2 +- packages/core/src/shared/assert.ts | 4 ++-- packages/core/src/shared/crypto.ts | 2 +- packages/core/src/shared/logger.ts | 2 +- packages/core/src/validator/registry.ts | 2 +- .../test/actions/callback/userinfo.test.ts | 2 +- packages/core/test/identity.test.ts | 4 ++-- packages/core/test/oauth.test.ts | 4 ++-- packages/core/test/types.test-d.ts | 4 ++-- packages/core/tsconfig.json | 5 +++-- packages/express/src/@types/index.ts | 14 ++++++++++++++ packages/express/src/createAuth.ts | 3 ++- packages/jose/src/deriveKey.ts | 4 ++-- packages/jose/src/encrypt.ts | 2 +- packages/jose/tsconfig.json | 3 ++- packages/next/package.json | 2 +- packages/react-router/package.json | 2 +- packages/react-router/src/@types/api.ts | 18 ++++++++++++++++++ packages/react-router/src/@types/index.ts | 15 +++++++++++++++ packages/react-router/src/createAuth.ts | 7 ++++--- packages/react-router/src/index.ts | 2 ++ packages/react-router/src/lib/api.ts | 7 ++++--- packages/react-router/tsconfig.json | 2 +- packages/react-router/tsdown.config.ts | 2 +- packages/react/package.json | 2 +- packages/react/src/context.tsx | 2 +- packages/react/src/hooks.ts | 2 +- packages/react/tsconfig.json | 3 ++- 35 files changed, 101 insertions(+), 49 deletions(-) create mode 100644 packages/express/src/@types/index.ts diff --git a/apps/bun/src/lib/auth.ts b/apps/bun/src/lib/auth.ts index ffa23c57..675e06a1 100644 --- a/apps/bun/src/lib/auth.ts +++ b/apps/bun/src/lib/auth.ts @@ -1,9 +1,6 @@ -import { createAuth, type AuthInstance } from "@aura-stack/auth" +import { createAuth } from "@aura-stack/auth" -/** - * @todo: fix the types for the handlers, jose, and api properties of the AuthInstance - */ -export const { handlers, jose, api }: AuthInstance = createAuth({ +export const { handlers, jose, api } = createAuth({ oauth: ["github"], basePath: "/api/auth", trustedOrigins: ["http://localhost:3000", "https://*.vercel.app"], diff --git a/apps/cloudflare/src/auth.ts b/apps/cloudflare/src/auth.ts index 7720b131..668fd026 100644 --- a/apps/cloudflare/src/auth.ts +++ b/apps/cloudflare/src/auth.ts @@ -1,6 +1,6 @@ -import { type AuthInstance, createAuth } from "@aura-stack/auth" +import { createAuth } from "@aura-stack/auth" -export const { handlers, jose, api }: AuthInstance = createAuth({ +export const { handlers, jose, api } = createAuth({ oauth: ["github"], basePath: "/api/auth", trustedOrigins: ["http://127.0.0.1:8787", "http://localhost:8787"], diff --git a/apps/deno/src/auth.ts b/apps/deno/src/auth.ts index 791e04fd..675e06a1 100644 --- a/apps/deno/src/auth.ts +++ b/apps/deno/src/auth.ts @@ -1,6 +1,6 @@ -import { type AuthInstance, createAuth } from "@aura-stack/auth" +import { createAuth } from "@aura-stack/auth" -export const { handlers, jose, api }: AuthInstance = createAuth({ +export const { handlers, jose, api } = createAuth({ oauth: ["github"], basePath: "/api/auth", trustedOrigins: ["http://localhost:3000", "https://*.vercel.app"], diff --git a/apps/oak/src/auth.ts b/apps/oak/src/auth.ts index 791e04fd..675e06a1 100644 --- a/apps/oak/src/auth.ts +++ b/apps/oak/src/auth.ts @@ -1,6 +1,6 @@ -import { type AuthInstance, createAuth } from "@aura-stack/auth" +import { createAuth } from "@aura-stack/auth" -export const { handlers, jose, api }: AuthInstance = createAuth({ +export const { handlers, jose, api } = createAuth({ oauth: ["github"], basePath: "/api/auth", trustedOrigins: ["http://localhost:3000", "https://*.vercel.app"], diff --git a/apps/supabase/functions/_shared/auth.ts b/apps/supabase/functions/_shared/auth.ts index 3e36f329..574653c7 100644 --- a/apps/supabase/functions/_shared/auth.ts +++ b/apps/supabase/functions/_shared/auth.ts @@ -1,6 +1,6 @@ -import { type AuthInstance, createAuth } from "@aura-stack/auth" +import { createAuth } from "@aura-stack/auth" -export const { handlers, jose, api }: AuthInstance = createAuth({ +export const { handlers, jose, api } = createAuth({ oauth: ["github"], basePath: "/api/auth", trustedOrigins: ["http://localhost:3000", "http://127.0.0.1:3000"], diff --git a/packages/core/src/actions/signIn/authorization-url.ts b/packages/core/src/actions/signIn/authorization-url.ts index 3289d0b4..03f8c583 100644 --- a/packages/core/src/actions/signIn/authorization-url.ts +++ b/packages/core/src/actions/signIn/authorization-url.ts @@ -1,7 +1,7 @@ -import { OAuthProvider } from "@/@types/index.ts" import { AuthInternalError } from "@/shared/errors.ts" import { OAuthAuthorization } from "@/schemas.ts" import { createPKCE, createSecretValue } from "@/shared/crypto.ts" +import type { OAuthProvider } from "@/@types/index.ts" import type { GlobalContext } from "@aura-stack/router" export const setSearchParams = (url: URL, params: Record) => { diff --git a/packages/core/src/actions/signIn/authorization.ts b/packages/core/src/actions/signIn/authorization.ts index 862de7ea..b2d5628d 100644 --- a/packages/core/src/actions/signIn/authorization.ts +++ b/packages/core/src/actions/signIn/authorization.ts @@ -1,9 +1,9 @@ import { getEnv } from "@/shared/env.ts" -import { Identities } from "@/shared/identity.ts" import { AuthInternalError } from "@/shared/errors.ts" import { equals, extractPath, patternToRegex } from "@/shared/utils.ts" import { isRelativeURL, isSameOrigin, isValidURL, isTrustedOrigin } from "@/shared/assert.ts" import type { AuthConfig } from "@/@types/index.ts" +import type { Identities } from "@/shared/identity.ts" import type { GlobalContext } from "@aura-stack/router" /** diff --git a/packages/core/src/router/context.ts b/packages/core/src/router/context.ts index 03b2fe3b..8789353c 100644 --- a/packages/core/src/router/context.ts +++ b/packages/core/src/router/context.ts @@ -1,11 +1,11 @@ import { createJoseInstance } from "@/jose.ts" import { createCookieStore } from "@/cookie.ts" -import { Identities } from "@/shared/identity.ts" import { createProxyLogger } from "@/shared/logger.ts" import { createSessionStrategy } from "@/session/strategy.ts" import { createSchemaRegistry } from "@/validator/registry.ts" import { createBuiltInOAuthProviders } from "@/oauth/index.ts" import { getEnv, getEnvArray, getEnvBoolean } from "@/shared/env.ts" +import type { Identities } from "@/shared/identity.ts" import type { AuthConfig, InternalContext, FromShapeToObject } from "@/@types/index.ts" export const createContext = (config?: AuthConfig) => { diff --git a/packages/core/src/shared/assert.ts b/packages/core/src/shared/assert.ts index 506763a6..6164209f 100644 --- a/packages/core/src/shared/assert.ts +++ b/packages/core/src/shared/assert.ts @@ -1,7 +1,7 @@ import { Type } from "arktype" -import { ZodObject, ZodTypeAny } from "zod" +import type { ZodObject, ZodTypeAny } from "zod" import { Type as TypeboxType } from "typebox" -import { BaseSchema, ObjectSchema } from "valibot" +import type { BaseSchema, ObjectSchema } from "valibot" import { equals, patternToRegex } from "@/shared/utils.ts" import type { AsymmetricKeyPair, diff --git a/packages/core/src/shared/crypto.ts b/packages/core/src/shared/crypto.ts index 036bfe61..d576c466 100644 --- a/packages/core/src/shared/crypto.ts +++ b/packages/core/src/shared/crypto.ts @@ -1,7 +1,7 @@ import { AuthSecurityError } from "@/shared/errors.ts" import { isJWTPayloadWithToken } from "@/shared/assert.ts" import { equals, timingSafeEqual } from "@/shared/utils.ts" -import { exportJWK, generateKeyPair, GenerateKeyPairOptions, importPKCS8, importSPKI } from "@aura-stack/jose/jose" +import { exportJWK, generateKeyPair, importPKCS8, importSPKI, type GenerateKeyPairOptions } from "@aura-stack/jose/jose" import { base64url, encoder, getRandomBytes, getSubtleCrypto } from "@/jose.ts" import type { AsymmetricKeyPairFromEnv, AuthRuntimeConfig, JoseInstance, User } from "@/@types/index.ts" diff --git a/packages/core/src/shared/logger.ts b/packages/core/src/shared/logger.ts index d5067645..e59e38d8 100644 --- a/packages/core/src/shared/logger.ts +++ b/packages/core/src/shared/logger.ts @@ -1,6 +1,6 @@ import { getEnv, getEnvBoolean } from "@/shared/env.ts" +import type { Identities } from "./identity.ts" import type { AuthConfig, InternalLogger, Logger, LogLevel, SyslogOptions } from "@/@types/index.ts" -import { Identities } from "./identity.ts" /** * Log message definitions organized by category. diff --git a/packages/core/src/validator/registry.ts b/packages/core/src/validator/registry.ts index fe9024c5..d95760cc 100644 --- a/packages/core/src/validator/registry.ts +++ b/packages/core/src/validator/registry.ts @@ -3,11 +3,11 @@ import * as valibot from "valibot" import { type } from "arktype" import { formatZodError } from "@/shared/utils.ts" import { IsObject, Type as Typebox } from "typebox" -import { IdentityConfig } from "@/@types/config.ts" import { AuthValidationError } from "@/shared/errors.ts" import { createValidator } from "@/validator/validator.ts" import { UserIdentity, type SchemaTypes } from "@/shared/identity.ts" import { isArkType, isValibotSchema, isZodSchema } from "@/shared/assert.ts" +import type { IdentityConfig } from "@/@types/config.ts" export const deriveSchema = ( schema: Schema, diff --git a/packages/core/test/actions/callback/userinfo.test.ts b/packages/core/test/actions/callback/userinfo.test.ts index 913ad23b..a8c4d8fc 100644 --- a/packages/core/test/actions/callback/userinfo.test.ts +++ b/packages/core/test/actions/callback/userinfo.test.ts @@ -1,8 +1,8 @@ import { describe, test, expect, vi } from "vitest" import { getUserInfo } from "@/actions/callback/userinfo.ts" -import { OAuthProviderConfig, OAuthProviderCredentials } from "@/@types/index.ts" import { oauthCustomService } from "@test/presets.ts" import { AURA_AUTH_VERSION } from "@/shared/utils.ts" +import type { OAuthProviderConfig, OAuthProviderCredentials } from "@/@types/index.ts" describe("getUserInfo", () => { test("get user info", async () => { diff --git a/packages/core/test/identity.test.ts b/packages/core/test/identity.test.ts index eb0bbeb5..639f1e18 100644 --- a/packages/core/test/identity.test.ts +++ b/packages/core/test/identity.test.ts @@ -1,18 +1,18 @@ import { describe, test, expect, expectTypeOf, vi, afterEach } from "vitest" import { createIdentity, - InferUser, UserIdentity, UserIdentityArkType, UserIdentityTypeBox, UserIdentityValibot, + type InferUser, } from "@/shared/identity.ts" import { z } from "zod/v4" import * as valibot from "valibot" import { createAuth } from "@/createAuth.ts" import { createSchemaRegistry, deriveSchema } from "@/validator/registry.ts" import { ArkErrors, type } from "arktype" -import { Static, Type as Typebox } from "typebox" +import { type Static, Type as Typebox } from "typebox" import { Value } from "typebox/value" afterEach(() => { diff --git a/packages/core/test/oauth.test.ts b/packages/core/test/oauth.test.ts index 542259f6..9d720aad 100644 --- a/packages/core/test/oauth.test.ts +++ b/packages/core/test/oauth.test.ts @@ -1,6 +1,6 @@ import { describe, test, expect } from "vitest" -import { createBuiltInOAuthProviders, builtInOAuthProviders, GitHubProfile } from "@/oauth/index.ts" -import { OAuthProviderCredentials, User } from "@/@types/index.ts" +import { createBuiltInOAuthProviders, builtInOAuthProviders, type GitHubProfile } from "@/oauth/index.ts" +import type { OAuthProviderCredentials, User } from "@/@types/index.ts" describe("createBuiltInOAuthProviders", () => { test("create oauth config for github", () => { diff --git a/packages/core/test/types.test-d.ts b/packages/core/test/types.test-d.ts index 342a263a..9767a119 100644 --- a/packages/core/test/types.test-d.ts +++ b/packages/core/test/types.test-d.ts @@ -4,12 +4,12 @@ import { createAuth } from "@/createAuth.ts" import { z, ZodOptional, ZodString } from "zod/v4" import { Type as Typebox } from "typebox" import { - Identities, UserIdentity, UserIdentityArkType, UserIdentityTypeBox, UserIdentityValibot, - UserShapeValibot, + type Identities, + type UserShapeValibot, } from "@/shared/identity.ts" import { github, type GitHubProfile } from "@/oauth/github.ts" import type { diff --git a/packages/core/tsconfig.json b/packages/core/tsconfig.json index d26b2b0e..59ac6493 100644 --- a/packages/core/tsconfig.json +++ b/packages/core/tsconfig.json @@ -5,9 +5,10 @@ "@/*": ["./src/*"], "@test/*": ["./test/*"] }, + "noEmit": true, "skipLibCheck": true, - "allowImportingTsExtensions": true, - "noEmit": true + "verbatimModuleSyntax": true, + "allowImportingTsExtensions": true }, "include": ["src", "test"], "exclude": ["dist", "node_modules"] diff --git a/packages/express/src/@types/index.ts b/packages/express/src/@types/index.ts new file mode 100644 index 00000000..9fd58805 --- /dev/null +++ b/packages/express/src/@types/index.ts @@ -0,0 +1,14 @@ +import { LocalsWithSession } from "@/lib/with-auth.ts" +import { AuthInstance } from "@aura-stack/auth" +import { FromShapeToObject, Identities } from "@aura-stack/auth/identity" +import type { Request, RequestHandler, Response } from "express" + +/** + * The ExpressInstance type represents the shape of the object returned by the `createAuth` + * function in the Express integration of Aura Auth. It was implemented due to errors related + * to unportable types from the `createAuth` function. + */ +export type ExpressInstance = AuthInstance> & { + toHandler: (req: Request, res: Response) => Promise + withAuth: RequestHandler>> +} diff --git a/packages/express/src/createAuth.ts b/packages/express/src/createAuth.ts index 10168cd2..8fdbe0d1 100644 --- a/packages/express/src/createAuth.ts +++ b/packages/express/src/createAuth.ts @@ -2,9 +2,10 @@ import { createAuth as createBasicAuth, type AuthConfig } from "@aura-stack/auth import { withAuth } from "@/lib/with-auth.ts" import { toExpressHandler } from "@/lib/handler.ts" import type { Request, Response } from "express" +import type { ExpressInstance } from "@/@types/index.ts" import type { Identities, FromShapeToObject } from "@aura-stack/auth/identity" -export const createAuth = (config: AuthConfig) => { +export const createAuth = (config: AuthConfig): ExpressInstance => { const auth = createBasicAuth(config) return { ...auth, diff --git a/packages/jose/src/deriveKey.ts b/packages/jose/src/deriveKey.ts index 372078b9..2aecf20d 100644 --- a/packages/jose/src/deriveKey.ts +++ b/packages/jose/src/deriveKey.ts @@ -1,8 +1,8 @@ import { createSecret } from "@/secret.ts" import { KeyDerivationError } from "@/errors.ts" import { encoder, getSubtleCrypto } from "@/crypto.ts" -import { SecretInput } from "./index.ts" -import { isJWKKey } from "./assert.ts" +import { isJWKKey } from "@/assert.ts" +import type { SecretInput } from "@/index.ts" /** * Generate a derived key using HKDF (HMAC-based Extract-and-Expand Key Derivation Function) diff --git a/packages/jose/src/encrypt.ts b/packages/jose/src/encrypt.ts index 71f2e7e8..927cdc16 100644 --- a/packages/jose/src/encrypt.ts +++ b/packages/jose/src/encrypt.ts @@ -2,9 +2,9 @@ import { base64url, EncryptJWT, jwtDecrypt, - JWTPayload, compactDecrypt, CompactEncrypt, + type JWTPayload, type JWEHeaderParameters, type JWTDecryptOptions, type DecryptOptions, diff --git a/packages/jose/tsconfig.json b/packages/jose/tsconfig.json index 87058fa3..88d58598 100644 --- a/packages/jose/tsconfig.json +++ b/packages/jose/tsconfig.json @@ -5,7 +5,8 @@ "@/*": ["./src/*"] }, "allowImportingTsExtensions": true, - "noEmit": true + "noEmit": true, + "verbatimModuleSyntax": true }, "include": ["src", "tsdown.config.ts", "test"], "exclude": ["dist", "node_modules"] diff --git a/packages/next/package.json b/packages/next/package.json index bd6ae88c..fc02b71f 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -119,4 +119,4 @@ "react-dom": ">=19.0.0" }, "packageManager": "pnpm@10.15.0" -} \ No newline at end of file +} diff --git a/packages/react-router/package.json b/packages/react-router/package.json index ce058161..c4a4bdf1 100644 --- a/packages/react-router/package.json +++ b/packages/react-router/package.json @@ -96,4 +96,4 @@ "react-router": ">=7.0.0" }, "packageManager": "pnpm@10.15.0" -} \ No newline at end of file +} diff --git a/packages/react-router/src/@types/api.ts b/packages/react-router/src/@types/api.ts index 78d1ca4f..144d8167 100644 --- a/packages/react-router/src/@types/api.ts +++ b/packages/react-router/src/@types/api.ts @@ -4,6 +4,7 @@ */ import type { Prettify, + GetSessionAPIOptions, SignInAPIOptions, SignInAPIReturn, SignInCredentialsAPIOptions, @@ -14,7 +15,9 @@ import type { UpdateSessionAPIReturn, UpdateSessionOptions, User, + Session, } from "@aura-stack/react/types" +import type { BuiltInOAuthProvider, LiteralUnion } from "@aura-stack/react/types" /** Core `signIn` options plus the incoming `Request` (required in React Router data APIs). */ export type ReactRouterSignInAPIOptions = Prettify< @@ -71,3 +74,18 @@ export type ReactRouterUpdateSessionReturn< } ? UpdateSessionAPIReturn : Response + +export interface ReactRouterAPI { + getSession: (options: GetSessionAPIOptions) => Promise | null> + signIn: ( + providerId: LiteralUnion, + options?: Options + ) => Promise> + signInCredentials: ( + options: Options + ) => Promise> + updateSession: >( + options: Options + ) => Promise> + signOut: (options: Options) => Promise> +} diff --git a/packages/react-router/src/@types/index.ts b/packages/react-router/src/@types/index.ts index 40a2434c..08b399b2 100644 --- a/packages/react-router/src/@types/index.ts +++ b/packages/react-router/src/@types/index.ts @@ -1,2 +1,17 @@ +import type { ReactRouterAPI } from "@/@types/api" +import type { AuthInstance } from "@aura-stack/react" +import type { FromShapeToObject, Identities } from "@aura-stack/react/identity" + export * from "@/@types/api" export * from "@/@types/core" + +/** + * The ReactRouterInstance type represents the shape of the object returned by the `createAuth` + * function in the React Router integration of Aura Auth. It was implemented due to errors related + * to unportable types from the `createAuth.api` object. + */ +export interface ReactRouterInstance { + api: ReactRouterAPI> + core: AuthInstance> + handlers: AuthInstance>["handlers"] +} diff --git a/packages/react-router/src/createAuth.ts b/packages/react-router/src/createAuth.ts index 693ab35b..46d5b940 100644 --- a/packages/react-router/src/createAuth.ts +++ b/packages/react-router/src/createAuth.ts @@ -1,9 +1,10 @@ import { createAuth as createAuthInstance } from "@aura-stack/react/server" import { api } from "@/lib/api" import type { AuthConfig } from "@aura-stack/react" -import type { Identities } from "@aura-stack/react/identity" +import type { ReactRouterInstance } from "@/@types/index" +import type { FromShapeToObject, Identities } from "@aura-stack/react/identity" -export const createAuth = (config: AuthConfig) => { +export const createAuth = (config: AuthConfig): ReactRouterInstance => { const auth = createAuthInstance(config) return { /** @@ -14,7 +15,7 @@ export const createAuth = (config: AuthConfig>(auth), /** * The handlers object contains the HTTP request handlers. */ diff --git a/packages/react-router/src/index.ts b/packages/react-router/src/index.ts index 3808080f..3428e1c1 100644 --- a/packages/react-router/src/index.ts +++ b/packages/react-router/src/index.ts @@ -1,2 +1,4 @@ export { createAuth } from "@/createAuth" export type { User, Session, AuthConfig, AuthInstance } from "@/@types/core" +export type { ReactRouterAPI } from "@/@types/api" +export type { ReactRouterInstance } from "@/@types/index" diff --git a/packages/react-router/src/lib/api.ts b/packages/react-router/src/lib/api.ts index 557c1e8f..2ae57221 100644 --- a/packages/react-router/src/lib/api.ts +++ b/packages/react-router/src/lib/api.ts @@ -1,4 +1,5 @@ import type { + ReactRouterAPI, ReactRouterSignInAPIOptions, ReactRouterSignInCredentialsAPIOptions, ReactRouterSignInCredentialsReturn, @@ -7,7 +8,7 @@ import type { ReactRouterSignOutReturn, ReactRouterUpdateSessionReturn, ReactRouterUpdateSessionAPIOptions, -} from "@/@types/index" +} from "@/@types/api" import type { AuthInstance, Session, User } from "@aura-stack/react" import type { BuiltInOAuthProvider, GetSessionAPIOptions, LiteralUnion } from "@aura-stack/react/types" @@ -30,7 +31,7 @@ export const signIn = ({ api }: AuthInstance( providerId: LiteralUnion, options?: Options - ) => { + ): Promise> => { const signIn = await api.signIn(providerId, options) if (options?.redirect === false) { return signIn as ReactRouterSignInReturn @@ -177,5 +178,5 @@ export const api = (config: AuthInstance(config), - } + } satisfies ReactRouterAPI } diff --git a/packages/react-router/tsconfig.json b/packages/react-router/tsconfig.json index 56baa32e..04313378 100644 --- a/packages/react-router/tsconfig.json +++ b/packages/react-router/tsconfig.json @@ -5,7 +5,7 @@ "@/*": ["./src/*"], "@test/*": ["./test/*"] }, - "verbatimModuleSyntax": false + "verbatimModuleSyntax": true }, "include": ["src", "test"], "exclude": ["dist", "node_modules"] diff --git a/packages/react-router/tsdown.config.ts b/packages/react-router/tsdown.config.ts index 02970214..c5f409f2 100644 --- a/packages/react-router/tsdown.config.ts +++ b/packages/react-router/tsdown.config.ts @@ -3,7 +3,7 @@ import { tsdownConfig } from "@aura-stack/tsdown-config" export default defineConfig({ ...tsdownConfig, - platform: "neutral", + platform: "browser", entry: [ "src/index.ts", "src/client.tsx", diff --git a/packages/react/package.json b/packages/react/package.json index 2954a3be..01698182 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -108,4 +108,4 @@ "@types/react": ">=19.0.0" }, "packageManager": "pnpm@10.15.0" -} \ No newline at end of file +} diff --git a/packages/react/src/context.tsx b/packages/react/src/context.tsx index 28301954..c095ee41 100644 --- a/packages/react/src/context.tsx +++ b/packages/react/src/context.tsx @@ -2,7 +2,7 @@ import { createContext, useCallback, useEffect, useRef, useState } from "react" import type { Session, User } from "@aura-stack/auth" import type { AuthClientInstance, AuthProviderProps, BroadcastMessage, Context } from "@/@types/types.ts" -export { AuthProviderProps } +export type { AuthProviderProps } export const AuthContext = createContext(undefined) diff --git a/packages/react/src/hooks.ts b/packages/react/src/hooks.ts index 78c7d729..e3257b39 100644 --- a/packages/react/src/hooks.ts +++ b/packages/react/src/hooks.ts @@ -1,5 +1,5 @@ "use client" -import { User } from "@aura-stack/auth" +import type { User } from "@aura-stack/auth" import { use, useCallback, useTransition } from "react" import { AuthContext, broadcast } from "@/context.tsx" import type { diff --git a/packages/react/tsconfig.json b/packages/react/tsconfig.json index 683985e3..2f317366 100644 --- a/packages/react/tsconfig.json +++ b/packages/react/tsconfig.json @@ -2,8 +2,9 @@ "extends": "@aura-stack/tsconfig/tsconfig.base.json", "compilerOptions": { "jsx": "react-jsx", - "allowImportingTsExtensions": true, "noEmit": true, + "allowImportingTsExtensions": true, + "verbatimModuleSyntax": true, "paths": { "@/*": ["./src/*"], "@test/*": ["./test/*"] From 8d804b3e5673e8aae6f2aeb0122638a0a774d94c Mon Sep 17 00:00:00 2001 From: Hernan Alvarado Date: Fri, 5 Jun 2026 16:00:27 -0500 Subject: [PATCH 3/4] chore: apply CodeRabbit feedback and update package descriptions --- configs/tsconfig/tsconfig.base.json | 5 +++- packages/core/package.json | 20 +++++++++++-- packages/core/tsconfig.json | 6 +--- packages/device/package.json | 2 +- packages/device/src/providers/index.ts | 4 +-- packages/device/test/providers.test.ts | 2 +- packages/elysia/package.json | 22 +++++++++++--- packages/elysia/tsconfig.json | 4 +-- packages/express/package.json | 27 +++++++++++++++-- packages/express/src/@types/index.ts | 6 ++-- packages/express/tsconfig.json | 4 +-- packages/hono/package.json | 27 +++++++++++++++-- packages/hono/tsconfig.json | 2 -- packages/integration/package.json | 2 +- packages/integration/tsconfig.json | 2 -- packages/jose/package.json | 25 ++++++++++++++-- packages/jose/tsconfig.json | 5 +--- packages/next/package.json | 29 +++++++++++++++++-- packages/next/src/context.tsx | 2 +- .../next/test/pages-router/handler.test.ts | 4 +-- packages/rate-limiter/package.json | 19 ++++++++++-- packages/rate-limiter/tsconfig.json | 4 +-- packages/react-router/package.json | 24 +++++++++++++-- packages/react-router/src/@types/core.ts | 2 +- packages/react-router/src/@types/index.ts | 4 +-- packages/react-router/tsconfig.json | 3 +- packages/react/package.json | 24 +++++++++++++-- packages/react/tsconfig.json | 3 -- 28 files changed, 213 insertions(+), 70 deletions(-) diff --git a/configs/tsconfig/tsconfig.base.json b/configs/tsconfig/tsconfig.base.json index 75febb60..37d2c9b2 100644 --- a/configs/tsconfig/tsconfig.base.json +++ b/configs/tsconfig/tsconfig.base.json @@ -19,7 +19,10 @@ "allowSyntheticDefaultImports": true, "forceConsistentCasingInFileNames": true, "skipLibCheck": true, - "isolatedModules": true + "isolatedModules": true, + "noEmit": true, + "verbatimModuleSyntax": true, + "allowImportingTsExtensions": true }, "include": ["src"], "exclude": ["node_modules"] diff --git a/packages/core/package.json b/packages/core/package.json index 10d6617c..7cb36daa 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -3,7 +3,7 @@ "version": "0.7.0", "private": false, "type": "module", - "description": "Core auth for @aura-stack/auth", + "description": "Open-source authentication and authorization library for modern TypeScript and JavaScript applications. Framework-agnostic, runtime-agnostic and built on web standards.", "scripts": { "dev": "tsdown --watch", "build": "tsdown", @@ -16,7 +16,7 @@ "format:check": "oxfmt --check", "type-check": "tsc --noEmit", "clean": "rm -rf dist", - "clean:cts": "find dist -type f -name \"*.cts\" -delete", + "clean:cts": "[ -d dist ] && find dist -type f -name \"*.cts\" -delete || true", "prepublishOnly": "pnpm build && pnpm clean:cts" }, "repository": { @@ -80,8 +80,22 @@ }, "keywords": [ "auth", + "oauth", + "oauth2", + "security", "session", - "authentication" + "authentication", + "authorization", + "typescript", + "javascript", + "node", + "bun", + "deno", + "edge", + "aura-stack", + "aura-stack-ts", + "aura auth", + "aura-auth" ], "author": "Aura Stack | Hernan Alvarado ", "homepage": "https://aura-stack-auth.vercel.app", diff --git a/packages/core/tsconfig.json b/packages/core/tsconfig.json index 59ac6493..5d037dc3 100644 --- a/packages/core/tsconfig.json +++ b/packages/core/tsconfig.json @@ -4,11 +4,7 @@ "paths": { "@/*": ["./src/*"], "@test/*": ["./test/*"] - }, - "noEmit": true, - "skipLibCheck": true, - "verbatimModuleSyntax": true, - "allowImportingTsExtensions": true + } }, "include": ["src", "test"], "exclude": ["dist", "node_modules"] diff --git a/packages/device/package.json b/packages/device/package.json index 3feb13d5..70bebfca 100644 --- a/packages/device/package.json +++ b/packages/device/package.json @@ -15,7 +15,7 @@ "format": "oxfmt", "format:check": "oxfmt --check", "type-check": "tsc --noEmit", - "clean:cts": "find dist -type f -name \"*.cts\" -delete", + "clean:cts": "[ -d dist ] && find dist -type f -name \"*.cts\" -delete || true", "prepublishOnly": "pnpm clean:cts && pnpm build && pnpm clean:cts" }, "repository": { diff --git a/packages/device/src/providers/index.ts b/packages/device/src/providers/index.ts index b73907f9..31adb441 100644 --- a/packages/device/src/providers/index.ts +++ b/packages/device/src/providers/index.ts @@ -1,9 +1,9 @@ -import { DeviceProviderCredentials } from "@/@types/device.ts" -import { LiteralUnion } from "@/@types/index.ts" import { github } from "@/providers/github.ts" import { DeviceProviderCredentialsSchema } from "@/schemas.ts" import { getEnv } from "@/shared/env.ts" import { pick, safeParse } from "valibot" +import type { LiteralUnion } from "@/@types/index.ts" +import type { DeviceProviderCredentials } from "@/@types/device.ts" export * from "@/providers/github.ts" diff --git a/packages/device/test/providers.test.ts b/packages/device/test/providers.test.ts index 6de9527f..791cf567 100644 --- a/packages/device/test/providers.test.ts +++ b/packages/device/test/providers.test.ts @@ -1,6 +1,6 @@ import { describe, test, expect, vi, afterEach } from "vitest" import { createBuiltInDeviceProviders } from "@/providers/index.ts" -import { DeviceProviderCredentials } from "@/@types/device.ts" +import type { DeviceProviderCredentials } from "@/@types/device.ts" afterEach(() => { vi.unstubAllEnvs() diff --git a/packages/elysia/package.json b/packages/elysia/package.json index a5895402..02a423e5 100644 --- a/packages/elysia/package.json +++ b/packages/elysia/package.json @@ -3,7 +3,7 @@ "version": "0.0.0", "private": false, "type": "module", - "description": "Elysia integration for Aura Stack authentication library", + "description": "Authentication integration for Elysia applications. Provides middleware, route handlers and session verification powered by Aura Auth.", "scripts": { "dev": "tsdown --watch", "build": "pnpm sync:modules && tsdown", @@ -16,7 +16,7 @@ "format:check": "oxfmt --check", "type-check": "tsc --noEmit", "clean": "rm -rf dist src/_core src/oauth", - "clean:cts": "find dist -type f -name \"*.cts\" -delete", + "clean:cts": "[ -d dist ] && find dist -type f -name \"*.cts\" -delete || true", "prepublishOnly": "pnpm sync:modules && pnpm build && pnpm clean:cts", "sync:modules": "node ../shared/scripts/modules.js" }, @@ -67,9 +67,23 @@ }, "keywords": [ "auth", - "elysia", + "oauth", + "oauth2", + "security", + "session", "authentication", - "aura-stack" + "authorization", + "elysia", + "elysiajs", + "bun", + "middleware", + "typescript", + "javascript", + "web-api", + "aura-stack", + "aura-stack-ts", + "aura auth", + "aura-auth" ], "author": "Aura Stack | Hernan Alvarado ", "homepage": "https://aura-stack-auth.vercel.app", diff --git a/packages/elysia/tsconfig.json b/packages/elysia/tsconfig.json index 2ace4c6d..544f018c 100644 --- a/packages/elysia/tsconfig.json +++ b/packages/elysia/tsconfig.json @@ -4,9 +4,7 @@ "paths": { "@/*": ["./src/*"], "@test/*": ["./test/*"] - }, - "allowImportingTsExtensions": true, - "noEmit": true + } }, "include": ["src", "test"], "exclude": ["dist", "node_modules"] diff --git a/packages/express/package.json b/packages/express/package.json index be76cc2b..2d14cfaf 100644 --- a/packages/express/package.json +++ b/packages/express/package.json @@ -3,7 +3,7 @@ "version": "0.0.0", "private": false, "type": "module", - "description": "Express integration for Aura Stack authentication library", + "description": "Authentication integration for Express applications. Provides middleware, route handlers and session verification powered by Aura Auth.", "scripts": { "dev": "tsdown --watch", "build": "pnpm sync:modules && tsdown", @@ -16,7 +16,7 @@ "format:check": "oxfmt --check", "type-check": "tsc --noEmit", "clean": "rm -rf dist src/_core src/oauth", - "clean:cts": "find dist -type f -name \"*.cts\" -delete", + "clean:cts": "[ -d dist ] && find dist -type f -name \"*.cts\" -delete || true", "prepublishOnly": "pnpm sync:modules && pnpm build && pnpm clean:cts", "sync:modules": "node ../shared/scripts/modules.js" }, @@ -65,7 +65,28 @@ "require": "./dist/_core/cookies.cjs" } }, - "keywords": [], + "keywords": [ + "auth", + "oauth", + "oauth2", + "security", + "session", + "authentication", + "authorization", + "express", + "expressjs", + "node", + "bun", + "deno", + "middleware", + "typescript", + "javascript", + "web-api", + "aura-stack", + "aura-stack-ts", + "aura auth", + "aura-auth" + ], "author": "Aura Stack | Hernan Alvarado ", "homepage": "https://aura-stack-auth.vercel.app", "bugs": { diff --git a/packages/express/src/@types/index.ts b/packages/express/src/@types/index.ts index 9fd58805..cc338d64 100644 --- a/packages/express/src/@types/index.ts +++ b/packages/express/src/@types/index.ts @@ -1,7 +1,7 @@ -import { LocalsWithSession } from "@/lib/with-auth.ts" -import { AuthInstance } from "@aura-stack/auth" -import { FromShapeToObject, Identities } from "@aura-stack/auth/identity" import type { Request, RequestHandler, Response } from "express" +import type { AuthInstance } from "@aura-stack/auth" +import type { LocalsWithSession } from "@/lib/with-auth.ts" +import type { FromShapeToObject, Identities } from "@aura-stack/auth/identity" /** * The ExpressInstance type represents the shape of the object returned by the `createAuth` diff --git a/packages/express/tsconfig.json b/packages/express/tsconfig.json index 6e1331cd..5d037dc3 100644 --- a/packages/express/tsconfig.json +++ b/packages/express/tsconfig.json @@ -4,9 +4,7 @@ "paths": { "@/*": ["./src/*"], "@test/*": ["./test/*"] - }, - "allowImportingTsExtensions": true, - "noEmit": true + } }, "include": ["src", "test"], "exclude": ["dist", "node_modules"] diff --git a/packages/hono/package.json b/packages/hono/package.json index 0ae179eb..3fe74e73 100644 --- a/packages/hono/package.json +++ b/packages/hono/package.json @@ -3,7 +3,7 @@ "version": "0.0.0", "private": false, "type": "module", - "description": "Hono integration for Aura Stack authentication library", + "description": "Authentication integration for Hono applications. Provides middleware, route handlers and session verification powered by Aura Auth.", "scripts": { "dev": "tsdown --watch", "build": "pnpm sync:modules && tsdown", @@ -16,7 +16,7 @@ "format:check": "oxfmt --check", "type-check": "tsc --noEmit", "clean": "rm -rf dist src/_core src/oauth", - "clean:cts": "find dist -type f -name \"*.cts\" -delete", + "clean:cts": "[ -d dist ] && find dist -type f -name \"*.cts\" -delete || true", "prepublishOnly": "pnpm sync:modules && pnpm build && pnpm clean:cts", "sync:modules": "node ../shared/scripts/modules.js" }, @@ -65,7 +65,28 @@ "require": "./dist/_core/cookies.cjs" } }, - "keywords": [], + "keywords": [ + "auth", + "oauth", + "oauth2", + "security", + "session", + "authentication", + "authorization", + "hono", + "honojs", + "bun", + "edge-runtime", + "cloudflare-workers", + "middleware", + "typescript", + "javascript", + "web-api", + "aura-stack", + "aura-stack-ts", + "aura auth", + "aura-auth" + ], "author": "Aura Stack | Hernan Alvarado ", "homepage": "https://aura-stack-auth.vercel.app", "bugs": { diff --git a/packages/hono/tsconfig.json b/packages/hono/tsconfig.json index be21e6fe..139bbd94 100644 --- a/packages/hono/tsconfig.json +++ b/packages/hono/tsconfig.json @@ -5,8 +5,6 @@ "@/*": ["./src/*"], "@test/*": ["./test/*"] }, - "allowImportingTsExtensions": true, - "noEmit": true, "jsx": "react-jsx", "jsxImportSource": "hono/jsx" }, diff --git a/packages/integration/package.json b/packages/integration/package.json index 0574805b..1f5587a3 100644 --- a/packages/integration/package.json +++ b/packages/integration/package.json @@ -16,7 +16,7 @@ "format:check": "oxfmt --check", "type-check": "tsc --noEmit", "clean": "rm -rf dist src/_core src/oauth", - "clean:cts": "find dist -type f -name \"*.cts\" -delete", + "clean:cts": "[ -d dist ] && find dist -type f -name \"*.cts\" -delete || true", "prepublishOnly": "pnpm clean:cts && pnpm build && pnpm clean:cts", "sync:modules": "node ../shared/scripts/modules.js" }, diff --git a/packages/integration/tsconfig.json b/packages/integration/tsconfig.json index 866c56a9..2aca6a65 100644 --- a/packages/integration/tsconfig.json +++ b/packages/integration/tsconfig.json @@ -1,8 +1,6 @@ { "extends": "@aura-stack/tsconfig/tsconfig.base.json", "compilerOptions": { - "noEmit": true, - "allowImportingTsExtensions": true, "paths": { "@/*": ["./src/*"] } diff --git a/packages/jose/package.json b/packages/jose/package.json index 69b7e9e7..2e6aeff2 100644 --- a/packages/jose/package.json +++ b/packages/jose/package.json @@ -3,7 +3,7 @@ "version": "0.6.0", "private": false, "type": "module", - "description": "JOSE utilities for @aura-stack/auth", + "description": "JOSE, JWT, JWS, JWE and JWK utilities for TypeScript and JavaScript applications built on Web Cryptography APIs.", "scripts": { "dev": "tsdown --watch", "build": "tsdown", @@ -16,7 +16,7 @@ "format:check": "oxfmt --check", "type-check": "tsc --noEmit", "clean": "rm -rf dist", - "clean:cts": "find dist -type f -name \"*.cts\" -delete", + "clean:cts": "[ -d dist ] && find dist -type f -name \"*.cts\" -delete || true", "prepublishOnly": "pnpm build && pnpm clean:cts" }, "repository": { @@ -65,7 +65,26 @@ "keywords": [ "auth", "session", - "authentication" + "authentication", + "jose", + "jwt", + "jws", + "jwe", + "jwk", + "crypto", + "cryptography", + "webcrypto", + "security", + "token", + "typescript", + "javascript", + "authentication", + "authorization", + "web-api", + "aura-stack", + "aura-stack-ts", + "aura auth", + "aura-auth" ], "author": "Aura Stack | Hernan Alvarado ", "homepage": "https://aura-stack-auth.vercel.app", diff --git a/packages/jose/tsconfig.json b/packages/jose/tsconfig.json index 88d58598..afdcd159 100644 --- a/packages/jose/tsconfig.json +++ b/packages/jose/tsconfig.json @@ -3,10 +3,7 @@ "compilerOptions": { "paths": { "@/*": ["./src/*"] - }, - "allowImportingTsExtensions": true, - "noEmit": true, - "verbatimModuleSyntax": true + } }, "include": ["src", "tsdown.config.ts", "test"], "exclude": ["dist", "node_modules"] diff --git a/packages/next/package.json b/packages/next/package.json index fc02b71f..c536a824 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -3,7 +3,7 @@ "version": "0.0.0", "private": false, "type": "module", - "description": "Next.js integration for Aura Stack authentication library", + "description": "Authentication integration for Next.js applications. Supports App Router, Server Components, Route Handlers and client-side authentication powered by Aura Auth.", "scripts": { "dev": "tsdown --watch", "build": "pnpm sync:modules && tsdown", @@ -16,7 +16,7 @@ "test:coverage": "vitest --run --coverage", "type-check": "tsc --noEmit", "clean": "rm -rf dist src/_core src/oauth", - "clean:cts": "find dist -type f -name \"*.cts\" -delete", + "clean:cts": "[ -d dist ] && find dist -type f -name \"*.cts\" -delete || true", "prepublishOnly": "pnpm sync:modules && pnpm build && pnpm clean:cts", "sync:modules": "node ../shared/scripts/modules.js --from react" }, @@ -91,7 +91,30 @@ }, "./types": "./dist/@types/index.d.ts" }, - "keywords": [], + "keywords": [ + "auth", + "oauth", + "oauth2", + "security", + "session", + "authentication", + "authorization", + "nextjs", + "next.js", + "server components", + "client components", + "server actions", + "server-side rendering", + "client-side rendering", + "react", + "typescript", + "javascript", + "web-api", + "aura-stack", + "aura-stack-ts", + "aura auth", + "aura-auth" + ], "author": "Aura Stack | Hernan Alvarado ", "homepage": "https://aura-stack-auth.vercel.app", "bugs": { diff --git a/packages/next/src/context.tsx b/packages/next/src/context.tsx index 333e6f1f..1c01566b 100644 --- a/packages/next/src/context.tsx +++ b/packages/next/src/context.tsx @@ -1,8 +1,8 @@ "use client" -import { User } from "@aura-stack/react" import { AuthProvider as Provider, type AuthProviderProps } from "@aura-stack/react/context" import { useRouter } from "next/navigation" +import type { User } from "@aura-stack/react" /** * Wrapper component that provides authentication context for Next.js App Router applications. diff --git a/packages/next/test/pages-router/handler.test.ts b/packages/next/test/pages-router/handler.test.ts index 95544adc..d21e4c42 100644 --- a/packages/next/test/pages-router/handler.test.ts +++ b/packages/next/test/pages-router/handler.test.ts @@ -1,9 +1,9 @@ import { describe, test, expect } from "vitest" -import { createMocks, createResponse, RequestOptions, ResponseOptions } from "node-mocks-http" +import { createMocks, createResponse, type RequestOptions, type ResponseOptions } from "node-mocks-http" import { auth } from "@test/pages-router/preset" -import { NextApiRequest, NextApiResponse } from "next" import { createCSRF } from "@aura-stack/react/crypto" import { setResponseHeaders } from "@/pages/handler" +import type { NextApiRequest, NextApiResponse } from "next" const createHandler = async (reqOptions?: RequestOptions, resOptions?: ResponseOptions) => { if (reqOptions?.body) { diff --git a/packages/rate-limiter/package.json b/packages/rate-limiter/package.json index b7241e86..51c55c28 100644 --- a/packages/rate-limiter/package.json +++ b/packages/rate-limiter/package.json @@ -3,7 +3,7 @@ "version": "0.0.0", "private": false, "type": "module", - "description": "Rate limiter for @aura-stack/auth", + "description": "Rate limiting utilities for TypeScript and JavaScript applications with support for authentication flows powered by Aura Auth.", "scripts": { "dev": "tsdown --watch", "build": "tsdown", @@ -16,7 +16,7 @@ "format:check": "oxfmt --check", "type-check": "tsc --noEmit", "clean": "rm -rf dist", - "clean:cts": "find dist -type f -name \"*.cts\" -delete", + "clean:cts": "[ -d dist ] && find dist -type f -name \"*.cts\" -delete || true", "prepublishOnly": "pnpm build && pnpm clean:cts" }, "repository": { @@ -29,7 +29,20 @@ "files": [ "dist" ], - "keywords": [], + "keywords": [ + "rate-limiter", + "rate-limit", + "throttling", + "api", + "security", + "authentication", + "ddos", + "abuse-protection", + "typescript", + "javascript", + "nodejs", + "edge-runtime" + ], "exports": { ".": { "types": "./dist/index.d.ts", diff --git a/packages/rate-limiter/tsconfig.json b/packages/rate-limiter/tsconfig.json index 32f55470..afdcd159 100644 --- a/packages/rate-limiter/tsconfig.json +++ b/packages/rate-limiter/tsconfig.json @@ -3,9 +3,7 @@ "compilerOptions": { "paths": { "@/*": ["./src/*"] - }, - "noEmit": true, - "allowImportingTsExtensions": true + } }, "include": ["src", "tsdown.config.ts", "test"], "exclude": ["dist", "node_modules"] diff --git a/packages/react-router/package.json b/packages/react-router/package.json index c4a4bdf1..89d8dce6 100644 --- a/packages/react-router/package.json +++ b/packages/react-router/package.json @@ -3,7 +3,7 @@ "version": "0.0.0", "private": false, "type": "module", - "description": "React Router integration for Aura Stack authentication library", + "description": "Authentication integration for React Router applications with server-side rendering, route protection, session management and OAuth flows powered by Aura Auth.", "scripts": { "dev": "tsdown --watch", "build": "pnpm sync:modules && tsdown", @@ -16,7 +16,7 @@ "test:watch": "vitest", "test:coverage": "vitest --run --coverage", "clean": "rm -rf dist src/_core src/oauth", - "clean:cts": "find dist -type f -name \"*.cts\" -delete", + "clean:cts": "[ -d dist ] && find dist -type f -name \"*.cts\" -delete || true", "prepublishOnly": "pnpm sync:modules && pnpm build && pnpm clean:cts", "sync:modules": "node ../shared/scripts/modules.js --from react" }, @@ -71,7 +71,25 @@ }, "./types": "./dist/@types/index.d.ts" }, - "keywords": [], + "keywords": [ + "react-router", + "react", + "authentication", + "auth", + "oauth", + "jwt", + "session", + "ssr", + "routing", + "authorization", + "typescript", + "web", + "web-api", + "aura-stack", + "aura-stack-ts", + "aura auth", + "aura-auth" + ], "author": "Aura Stack | Hernan Alvarado ", "homepage": "https://aura-stack-auth.vercel.app", "bugs": { diff --git a/packages/react-router/src/@types/core.ts b/packages/react-router/src/@types/core.ts index d1a5664e..b3e3e144 100644 --- a/packages/react-router/src/@types/core.ts +++ b/packages/react-router/src/@types/core.ts @@ -1 +1 @@ -export * from "@aura-stack/react/types" +export type * from "@aura-stack/react/types" diff --git a/packages/react-router/src/@types/index.ts b/packages/react-router/src/@types/index.ts index 08b399b2..b6ec001e 100644 --- a/packages/react-router/src/@types/index.ts +++ b/packages/react-router/src/@types/index.ts @@ -2,8 +2,8 @@ import type { ReactRouterAPI } from "@/@types/api" import type { AuthInstance } from "@aura-stack/react" import type { FromShapeToObject, Identities } from "@aura-stack/react/identity" -export * from "@/@types/api" -export * from "@/@types/core" +export type * from "@/@types/api" +export type * from "@/@types/core" /** * The ReactRouterInstance type represents the shape of the object returned by the `createAuth` diff --git a/packages/react-router/tsconfig.json b/packages/react-router/tsconfig.json index 04313378..14658a2d 100644 --- a/packages/react-router/tsconfig.json +++ b/packages/react-router/tsconfig.json @@ -4,8 +4,7 @@ "paths": { "@/*": ["./src/*"], "@test/*": ["./test/*"] - }, - "verbatimModuleSyntax": true + } }, "include": ["src", "test"], "exclude": ["dist", "node_modules"] diff --git a/packages/react/package.json b/packages/react/package.json index 01698182..2d1fa23a 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -3,7 +3,7 @@ "version": "0.0.0", "private": false, "type": "module", - "description": "React integration for Aura Stack authentication library", + "description": "React authentication utilities including providers, hooks and OAuth flows for client-side and hybrid applications powered by Aura Auth.", "scripts": { "dev": "tsdown --watch", "build": "pnpm sync:modules && tsdown", @@ -16,7 +16,7 @@ "format:check": "oxfmt --check", "type-check": "tsc --noEmit", "clean": "rm -rf dist src/_core src/oauth", - "clean:cts": "find dist -type f -name \"*.cts\" -delete", + "clean:cts": "[ -d dist ] && find dist -type f -name \"*.cts\" -delete || true", "prepublishOnly": "pnpm sync:modules && pnpm build && pnpm clean:cts", "sync:modules": "node ../shared/scripts/modules.js" }, @@ -83,7 +83,25 @@ }, "./types": "./dist/@types/index.d.ts" }, - "keywords": [], + "keywords": [ + "react", + "authentication", + "auth", + "oauth", + "jwt", + "session", + "context", + "hooks", + "typescript", + "javascript", + "authorization", + "frontend", + "web-api", + "aura-stack", + "aura-stack-ts", + "aura auth", + "aura-auth" + ], "author": "Aura Stack | Hernan Alvarado ", "homepage": "https://aura-stack-auth.vercel.app", "bugs": { diff --git a/packages/react/tsconfig.json b/packages/react/tsconfig.json index 2f317366..98a9e28b 100644 --- a/packages/react/tsconfig.json +++ b/packages/react/tsconfig.json @@ -2,9 +2,6 @@ "extends": "@aura-stack/tsconfig/tsconfig.base.json", "compilerOptions": { "jsx": "react-jsx", - "noEmit": true, - "allowImportingTsExtensions": true, - "verbatimModuleSyntax": true, "paths": { "@/*": ["./src/*"], "@test/*": ["./test/*"] From 835beb0bf055e0f0e2a0310bad52571bf34316ae Mon Sep 17 00:00:00 2001 From: Hernan Alvarado Date: Fri, 5 Jun 2026 16:03:01 -0500 Subject: [PATCH 4/4] chore: fix type import --- packages/integration/src/createAuth.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integration/src/createAuth.ts b/packages/integration/src/createAuth.ts index c8948120..2311110e 100644 --- a/packages/integration/src/createAuth.ts +++ b/packages/integration/src/createAuth.ts @@ -1,4 +1,4 @@ -import { AuthConfig, createAuth as createAuthInstance } from "@aura-stack/auth" +import { type AuthConfig, createAuth as createAuthInstance } from "@aura-stack/auth" import type { Identities } from "@aura-stack/auth/identity" export const createAuth = (config: AuthConfig) => {