diff --git a/bun.lock b/bun.lock index 8a3226f3..0f292ce3 100644 --- a/bun.lock +++ b/bun.lock @@ -362,6 +362,17 @@ "hono": ">=4.0.0", }, }, + "packages/integration": { + "name": "@aura-stack/integration", + "version": "0.0.0", + "dependencies": { + "@aura-stack/auth": "workspace:*", + }, + "devDependencies": { + "@aura-stack/tsconfig": "workspace:*", + "@aura-stack/tsdown-config": "workspace:*", + }, + }, "packages/jose": { "name": "@aura-stack/jose", "version": "0.4.0", @@ -438,6 +449,10 @@ "react-router": ">=7.0.0", }, }, + "packages/shared": { + "name": "shared", + "version": "0.0.0", + }, }, "overrides": { "dompurify": "^3.3.2", @@ -544,6 +559,8 @@ "@aura-stack/hono": ["@aura-stack/hono@workspace:packages/hono"], + "@aura-stack/integration": ["@aura-stack/integration@workspace:packages/integration"], + "@aura-stack/jose": ["@aura-stack/jose@workspace:packages/jose"], "@aura-stack/next": ["@aura-stack/next@workspace:packages/next"], @@ -3254,6 +3271,8 @@ "setprototypeof": ["setprototypeof@1.2.0", "", {}, "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw=="], + "shared": ["shared@workspace:packages/shared"], + "sharp": ["sharp@0.34.5", "", { "dependencies": { "@img/colour": "1.1.0", "detect-libc": "2.1.2", "semver": "7.7.4" }, "optionalDependencies": { "@img/sharp-darwin-arm64": "0.34.5", "@img/sharp-darwin-x64": "0.34.5", "@img/sharp-libvips-darwin-arm64": "1.2.4", "@img/sharp-libvips-darwin-x64": "1.2.4", "@img/sharp-libvips-linux-arm": "1.2.4", "@img/sharp-libvips-linux-arm64": "1.2.4", "@img/sharp-libvips-linux-ppc64": "1.2.4", "@img/sharp-libvips-linux-riscv64": "1.2.4", "@img/sharp-libvips-linux-s390x": "1.2.4", "@img/sharp-libvips-linux-x64": "1.2.4", "@img/sharp-libvips-linuxmusl-arm64": "1.2.4", "@img/sharp-libvips-linuxmusl-x64": "1.2.4", "@img/sharp-linux-arm": "0.34.5", "@img/sharp-linux-arm64": "0.34.5", "@img/sharp-linux-ppc64": "0.34.5", "@img/sharp-linux-riscv64": "0.34.5", "@img/sharp-linux-s390x": "0.34.5", "@img/sharp-linux-x64": "0.34.5", "@img/sharp-linuxmusl-arm64": "0.34.5", "@img/sharp-linuxmusl-x64": "0.34.5", "@img/sharp-wasm32": "0.34.5", "@img/sharp-win32-arm64": "0.34.5", "@img/sharp-win32-ia32": "0.34.5", "@img/sharp-win32-x64": "0.34.5" } }, "sha512-Ou9I5Ft9WNcCbXrU9cMgPBcCK8LiwLqcbywW3t4oDV37n1pzpuNLsYiAV8eODnjbtQlSDwZ2cUEeQz4E54Hltg=="], "shebang-command": ["shebang-command@2.0.0", "", { "dependencies": { "shebang-regex": "3.0.0" } }, "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA=="], diff --git a/package.json b/package.json index 7db23d65..06a6893b 100644 --- a/package.json +++ b/package.json @@ -9,14 +9,15 @@ "dev:core": "turbo run @aura-stack/auth#dev", "dev:docs": "turbo run docs#dev", "build": "turbo run build --filter=./configs/* --filter=./packages/* --filter=./apps/*", - "build:prod": "turbo run build --filter=./configs/* --filter=./packages/* --continue=dependencies-successful", + "build:prod": "turbo run build --filter=./configs/* --filter=./packages/* --filter=!./packages/integration --continue=dependencies-successful", "test": "turbo run test --parallel", "format": "turbo run format format:root --parallel", "format:root": "oxfmt \"!packages\" \"!apps\" \"!configs\"", "format:check": "oxfmt --check", "lint": "oxlint", "lint:fix": "oxlint --fix", - "type-check": "turbo run type-check --parallel" + "type-check": "turbo run type-check --parallel", + "create:integration": "node packages/shared/scripts/integration.js" }, "repository": { "type": "git", diff --git a/packages/integration/CHANGELOG.md b/packages/integration/CHANGELOG.md new file mode 100644 index 00000000..980bf2e3 --- /dev/null +++ b/packages/integration/CHANGELOG.md @@ -0,0 +1,13 @@ +# Changelog - `@aura-stack/integration` + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +--- + +## [Unreleased] + +### Added + +### Changed diff --git a/packages/integration/README.md b/packages/integration/README.md new file mode 100644 index 00000000..eae41ea1 --- /dev/null +++ b/packages/integration/README.md @@ -0,0 +1,35 @@ +
+ +

@aura-stack/integration

+ +**Integration authentication library for the Aura Stack ecosystem** + +[![npm version](https://img.shields.io/npm/v/@aura-stack/integration.svg)](https://www.npmjs.com/package/@aura-stack/integration) +[![JSR version](https://jsr.io/badges/@aura-stack/integration)](https://jsr.io/@aura-stack/integration) +[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) + +[Official Docs](https://aura-stack-auth.vercel.app/docs) · [Core Package Docs](https://aura-stack-auth.vercel.app/docs/packages/core) + +
+ +## Features + +## Installation + +```bash +pnpm add @aura-stack/integration +``` + +## Documentation + +Visit the [**official documentation website**](https://aura-stack-auth.vercel.app). + +## License + +Licensed under the [MIT License](../../LICENSE). © [Aura Stack](https://github.com/aura-stack-ts) + +--- + +

+ Made with ❤️ by Aura Stack team +

diff --git a/packages/integration/deno.json b/packages/integration/deno.json new file mode 100644 index 00000000..ba80ec44 --- /dev/null +++ b/packages/integration/deno.json @@ -0,0 +1,19 @@ +{ + "name": "@aura-stack/integration", + "version": "0.0.0", + "license": "MIT", + "tasks": { + "dev": "deno run --watch src/index.ts" + }, + "imports": { + "@/": "./src/", + "./oauth": "./src/oauth/index.ts", + "./identity": "./src/_core/identity.ts", + "./crypto": "./src/_core/crypto.ts", + "./shared": "./src/_core/shared.ts" + }, + "publish": { + "include": ["src/**/*.ts", "src/**/*.tsx", "README.md", "CHANGELOG.md"] + }, + "exclude": ["dist", "node_modules"] +} diff --git a/packages/integration/package.json b/packages/integration/package.json new file mode 100644 index 00000000..24e7ecf2 --- /dev/null +++ b/packages/integration/package.json @@ -0,0 +1,79 @@ +{ + "name": "@aura-stack/integration", + "version": "0.0.0", + "private": true, + "type": "module", + "description": "Integration for Aura Stack authentication library", + "scripts": { + "dev": "tsdown --watch", + "build": "pnpm sync:modules && tsdown", + "lint": "oxlint", + "lint:fix": "oxlint --fix", + "test": "vitest --run", + "test:watch": "vitest", + "test:coverage": "vitest --run --coverage", + "format": "oxfmt", + "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", + "prepublishOnly": "pnpm clean:cts && pnpm build && pnpm clean:cts", + "sync:modules": "node ../shared/scripts/modules.js" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/aura-stack-ts/auth" + }, + "sideEffects": false, + "files": [ + "dist" + ], + "exports": { + ".": { + "types": "./dist/index.d.ts", + "import": "./dist/index.js", + "require": "./dist/index.cjs" + }, + "./oauth": { + "types": "./dist/oauth/index.d.ts", + "import": "./dist/oauth/index.js", + "require": "./dist/oauth/index.cjs" + }, + "./oauth/*": { + "types": "./dist/oauth/*.d.ts", + "import": "./dist/oauth/*.js", + "require": "./dist/oauth/*.cjs" + }, + "./identity": { + "types": "./dist/_core/identity.d.ts", + "import": "./dist/_core/identity.js", + "require": "./dist/_core/identity.cjs" + }, + "./crypto": { + "types": "./dist/_core/crypto.d.ts", + "import": "./dist/_core/crypto.js", + "require": "./dist/_core/crypto.cjs" + }, + "./shared": { + "types": "./dist/_core/shared.d.ts", + "import": "./dist/_core/shared.js", + "require": "./dist/_core/shared.cjs" + } + }, + "keywords": [], + "author": "Aura Stack | Hernan Alvarado ", + "homepage": "https://aura-stack-auth.vercel.app", + "bugs": { + "url": "https://github.com/aura-stack-ts/auth/issues" + }, + "license": "MIT", + "dependencies": { + "@aura-stack/auth": "workspace:*" + }, + "devDependencies": { + "@aura-stack/tsconfig": "workspace:*", + "@aura-stack/tsdown-config": "workspace:*" + }, + "peerDependencies": {}, + "packageManager": "pnpm@10.15.0" +} diff --git a/packages/integration/src/createAuth.ts b/packages/integration/src/createAuth.ts new file mode 100644 index 00000000..ec270223 --- /dev/null +++ b/packages/integration/src/createAuth.ts @@ -0,0 +1,7 @@ +import { AuthConfig, createAuth as createAuthInstance } from "@aura-stack/auth" +import type { EditableShape, UserShape } from "@aura-stack/auth/identity" + +export const createAuth = >(config: AuthConfig) => { + const auth = createAuthInstance(config) + return auth +} diff --git a/packages/integration/src/index.ts b/packages/integration/src/index.ts new file mode 100644 index 00000000..7405f43d --- /dev/null +++ b/packages/integration/src/index.ts @@ -0,0 +1 @@ +export { createAuth } from "@/createAuth.ts" diff --git a/packages/integration/tsconfig.json b/packages/integration/tsconfig.json new file mode 100644 index 00000000..866c56a9 --- /dev/null +++ b/packages/integration/tsconfig.json @@ -0,0 +1,12 @@ +{ + "extends": "@aura-stack/tsconfig/tsconfig.base.json", + "compilerOptions": { + "noEmit": true, + "allowImportingTsExtensions": true, + "paths": { + "@/*": ["./src/*"] + } + }, + "include": ["src"], + "exclude": ["dist", "node_modules"] +} diff --git a/packages/integration/tsdown.config.ts b/packages/integration/tsdown.config.ts new file mode 100644 index 00000000..58eb3ef6 --- /dev/null +++ b/packages/integration/tsdown.config.ts @@ -0,0 +1,14 @@ +import { defineConfig } from "tsdown" +import { tsdownConfig } from "@aura-stack/tsdown-config" + +export default defineConfig({ + ...tsdownConfig, + entry: [ + "src/index.ts", + "src/oauth/index.ts", + "src/oauth/*.ts", + "src/_core/identity.ts", + "src/_core/crypto.ts", + "src/_core/shared.ts", + ], +}) diff --git a/packages/shared/scripts/integration.js b/packages/shared/scripts/integration.js new file mode 100644 index 00000000..15db5a02 --- /dev/null +++ b/packages/shared/scripts/integration.js @@ -0,0 +1,54 @@ +import { existsSync } from "node:fs" +import { parseArgs } from "node:util" +import { cp } from "node:fs/promises" +import { basename, resolve } from "node:path" + +const args = parseArgs({ + args: process.argv.slice(2), + strict: true, + options: { + name: { + type: "string", + }, + }, +}) + +const { name } = args.values + +if (!name) { + console.error("\x1b[31m[error]: Integration name is required\x1b[0m") + process.exit(1) +} +if (!/^[a-z0-9][a-z0-9-]*$/.test(name)) { + console.error("\x1b[31m[error]: Integration name must be lowercase alphanumeric with dashes\x1b[0m") + process.exit(1) +} + +if (existsSync(resolve(process.cwd(), "packages", name))) { + console.error("\x1b[31m[error]: Integration with the same name already exists\x1b[0m") + process.exit(1) +} + +try { + const outDir = resolve(process.cwd(), "packages", name) + const templateDir = resolve(process.cwd(), "packages", "integration") + + if (!existsSync(templateDir)) { + console.error("\x1b[31m[error]: Integration template folder not found at packages/integration\x1b[0m") + process.exit(1) + } + + console.log(`\x1b[34m[info]: Creating integration "${name}"...\x1b[0m`) + await cp(templateDir, outDir, { + recursive: true, + filter: (src) => { + const name = basename(src) + return name !== "node_modules" && name !== "dist" + }, + }) + + console.log("\x1b[32m[success]: Integration created successfully\x1b[0m") +} catch (error) { + console.error("\x1b[31m[error]: Failed to create integration:\x1b[0m", error) + process.exit(1) +} diff --git a/packages/shared/scripts/modules.js b/packages/shared/scripts/modules.js index a1cc4f7d..8b1a6582 100644 --- a/packages/shared/scripts/modules.js +++ b/packages/shared/scripts/modules.js @@ -1,6 +1,6 @@ -import { glob, mkdir, readFile, writeFile } from "node:fs/promises" -import { join, parse, resolve } from "node:path" import { parseArgs } from "node:util" +import { join, parse, resolve } from "node:path" +import { glob, mkdir, readFile, writeFile } from "node:fs/promises" const coreModules = ["crypto", "identity", "shared"] const jsonExports = [ diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1055bdd5..eb5313ed 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -749,6 +749,19 @@ importers: specifier: catalog:vitest version: 4.1.4(@types/node@24.12.0)(@vitest/coverage-v8@4.1.4)(jsdom@27.4.0(@noble/hashes@1.8.0))(vite@7.3.1(@types/node@24.12.0)(jiti@2.6.1)(lightningcss@1.32.0)(terser@5.46.1)(tsx@4.21.0)(yaml@2.8.2)) + packages/integration: + dependencies: + '@aura-stack/auth': + specifier: workspace:* + version: link:../core + devDependencies: + '@aura-stack/tsconfig': + specifier: workspace:* + version: link:../../configs/tsconfig + '@aura-stack/tsdown-config': + specifier: workspace:* + version: link:../../configs/tsdown-config + packages/jose: dependencies: jose: @@ -846,6 +859,8 @@ importers: specifier: catalog:react-router version: 7.12.0(react-dom@19.2.4(react@19.2.4))(react@19.2.4) + packages/shared: {} + packages: '@acemir/cssom@0.9.31':