Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
49 changes: 48 additions & 1 deletion .github/workflows/publish-sdks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
next-published: ${{ steps.publish-next.outputs.published }}
aix402-published: ${{ steps.publish-aix402.outputs.published }}
echo-start-published: ${{ steps.publish-echo-start.outputs.published }}
authjs-provider-published: ${{ steps.publish-authjs-provider.outputs.published }}
version: ${{ steps.get-version.outputs.version }}

steps:
Expand Down Expand Up @@ -273,11 +274,55 @@ jobs:
echo "✅ Successfully published $PACKAGE_NAME"
fi

# Auth.js Provider
- name: Build Auth.js Provider
working-directory: ./packages/sdk/auth-js-provider
run: |
echo "🔨 Building Auth.js Provider..."
pnpm run build
echo "✅ Auth.js Provider built"

- name: Test Auth.js Provider
working-directory: ./packages/sdk/auth-js-provider
run: |
echo "🧪 Testing Auth.js Provider..."
pnpm run test
pnpm run type-check
echo "✅ Auth.js Provider tests passed"

- name: Check and publish Auth.js Provider
id: publish-authjs-provider
working-directory: ./packages/sdk/auth-js-provider
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
PACKAGE_NAME=$(node -p "require('./package.json').name")
PACKAGE_VERSION=$(node -p "require('./package.json').version")
FORCE_PUBLISH="${{ github.event.inputs.force_publish }}"

if npm view "$PACKAGE_NAME@$PACKAGE_VERSION" version 2>/dev/null; then
if [ "$FORCE_PUBLISH" = "true" ]; then
echo "⚠️ Version $PACKAGE_VERSION of $PACKAGE_NAME already exists on npm, but force_publish is enabled"
echo "🚀 Publishing $PACKAGE_NAME to npm..."
pnpm publish --access public --no-git-checks
echo "published=true" >> $GITHUB_OUTPUT
echo "✅ Successfully published $PACKAGE_NAME"
else
echo "❌ Version $PACKAGE_VERSION of $PACKAGE_NAME already exists on npm - skipping"
echo "published=false" >> $GITHUB_OUTPUT
fi
else
echo "🚀 Publishing $PACKAGE_NAME to npm..."
pnpm publish --access public --no-git-checks
echo "published=true" >> $GITHUB_OUTPUT
echo "✅ Successfully published $PACKAGE_NAME"
fi

create-tag:
name: Create version tag
runs-on: ubuntu-latest
needs: publish
if: (needs.publish.outputs.typescript-published == 'true' || needs.publish.outputs.react-published == 'true' || needs.publish.outputs.next-published == 'true' || needs.publish.outputs.aix402-published == 'true' || needs.publish.outputs.echo-start-published == 'true') && github.ref == 'refs/heads/production' && !startsWith(github.ref, 'refs/tags/')
if: (needs.publish.outputs.typescript-published == 'true' || needs.publish.outputs.react-published == 'true' || needs.publish.outputs.next-published == 'true' || needs.publish.outputs.aix402-published == 'true' || needs.publish.outputs.echo-start-published == 'true' || needs.publish.outputs.authjs-provider-published == 'true') && github.ref == 'refs/heads/production' && !startsWith(github.ref, 'refs/tags/')

steps:
- name: Checkout code
Expand Down Expand Up @@ -340,6 +385,7 @@ jobs:
- \`@merit-systems/echo-next-sdk\`
- \`@merit-systems/ai-x402\`
- \`echo-start\` (CLI tool)
- \`@merit-systems/echo-authjs-provider\`

### Installation
\`\`\`bash
Expand All @@ -348,6 +394,7 @@ jobs:
npm install @merit-systems/echo-next-sdk
npm install @merit-systems/ai-x402
npm install -g echo-start
npm install @merit-systems/echo-authjs-provider
\`\`\`

This tag was automatically created after successful npm publishing from the production branch.
Expand Down
75 changes: 75 additions & 0 deletions .github/workflows/test-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ on:
- 'packages/sdk/next/**'
- 'packages/sdk/aix402/**'
- 'packages/sdk/echo-start/**'
- 'packages/sdk/auth-js-provider/**'
- '.github/workflows/publish-sdks.yml'
- '.github/workflows/test-publish.yml'
- 'pnpm-lock.yaml'
Expand All @@ -20,6 +21,7 @@ on:
- 'packages/sdk/next/**'
- 'packages/sdk/aix402/**'
- 'packages/sdk/echo-start/**'
- 'packages/sdk/auth-js-provider/**'
- '.github/workflows/publish-sdks.yml'
- '.github/workflows/test-publish.yml'

Expand All @@ -33,11 +35,13 @@ jobs:
next-ready: ${{ steps.test-next.outputs.ready }}
aix402-ready: ${{ steps.test-aix402.outputs.ready }}
echo-start-ready: ${{ steps.test-echo-start.outputs.ready }}
authjs-provider-ready: ${{ steps.test-authjs-provider.outputs.ready }}
typescript-version: ${{ steps.get-versions.outputs.typescript-version }}
react-version: ${{ steps.get-versions.outputs.react-version }}
next-version: ${{ steps.get-versions.outputs.next-version }}
aix402-version: ${{ steps.get-versions.outputs.aix402-version }}
echo-start-version: ${{ steps.get-versions.outputs.echo-start-version }}
authjs-provider-version: ${{ steps.get-versions.outputs.authjs-provider-version }}

env:
# Database Configuration
Expand Down Expand Up @@ -110,16 +114,19 @@ jobs:
NEXT_VERSION=$(node -p "require('./packages/sdk/next/package.json').version")
AIX402_VERSION=$(node -p "require('./packages/sdk/aix402/package.json').version")
ECHO_START_VERSION=$(node -p "require('./packages/sdk/echo-start/package.json').version")
AUTHJS_PROVIDER_VERSION=$(node -p "require('./packages/sdk/auth-js-provider/package.json').version")
echo "typescript-version=$TS_VERSION" >> $GITHUB_OUTPUT
echo "react-version=$REACT_VERSION" >> $GITHUB_OUTPUT
echo "next-version=$NEXT_VERSION" >> $GITHUB_OUTPUT
echo "aix402-version=$AIX402_VERSION" >> $GITHUB_OUTPUT
echo "echo-start-version=$ECHO_START_VERSION" >> $GITHUB_OUTPUT
echo "authjs-provider-version=$AUTHJS_PROVIDER_VERSION" >> $GITHUB_OUTPUT
echo "📦 TypeScript SDK: v$TS_VERSION"
echo "📦 React SDK: v$REACT_VERSION"
echo "📦 Next.js SDK: v$NEXT_VERSION"
echo "📦 AIx402 SDK: v$AIX402_VERSION"
echo "📦 Echo Start CLI: v$ECHO_START_VERSION"
echo "📦 Auth.js Provider: v$AUTHJS_PROVIDER_VERSION"

# TypeScript SDK Tests
- name: Check TypeScript SDK configuration
Expand Down Expand Up @@ -461,3 +468,71 @@ jobs:

echo "ready=true" >> $GITHUB_OUTPUT
echo "✅ Echo Start CLI is ready for publishing"

# Auth.js Provider Tests
- name: Check Auth.js Provider configuration
working-directory: ./packages/sdk/auth-js-provider
run: |
echo "🔍 Checking Auth.js Provider configuration..."
PACKAGE_NAME=$(node -p "require('./package.json').name")
echo "Name: $PACKAGE_NAME"

# Check if package.json has required fields for publishing
if [ "$(node -p "require('./package.json').private || false")" = "true" ]; then
echo "❌ Package is marked as private - cannot publish"
exit 1
fi

if [ -z "$PACKAGE_NAME" ]; then
echo "❌ Package name is missing"
exit 1
fi

echo "✅ Auth.js Provider configuration looks good"

- name: Build and test Auth.js Provider
id: test-authjs-provider
working-directory: ./packages/sdk/auth-js-provider
run: |
echo "🔨 Building Auth.js Provider..."
pnpm run build

echo "🧪 Testing Auth.js Provider..."
pnpm run test
pnpm run type-check

echo "📁 Checking build output..."
if [ ! -d "dist" ]; then
echo "❌ dist directory not found"
exit 1
fi

# Check for main files
MAIN_FILE=$(node -p "require('./package.json').main")
TYPES_FILE=$(node -p "require('./package.json').types")

if [ ! -z "$MAIN_FILE" ] && [ ! -f "$MAIN_FILE" ]; then
echo "❌ Main file not found: $MAIN_FILE"
exit 1
fi

if [ ! -z "$TYPES_FILE" ] && [ ! -f "$TYPES_FILE" ]; then
echo "❌ Types file not found: $TYPES_FILE"
exit 1
fi

echo "📏 Checking dist size..."
du -sh dist || true

echo "🔍 Simulating version check..."
PACKAGE_NAME=$(node -p "require('./package.json').name")
PACKAGE_VERSION=$(node -p "require('./package.json').version")

if npm view "$PACKAGE_NAME@$PACKAGE_VERSION" version 2>/dev/null; then
echo "⚠️ Version $PACKAGE_VERSION already exists on npm"
else
echo "✅ Version $PACKAGE_VERSION does not exist - would be published"
fi

echo "ready=true" >> $GITHUB_OUTPUT
echo "✅ Auth.js Provider is ready for publishing"
41 changes: 41 additions & 0 deletions packages/app/control/docs/getting-started/templates.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -375,4 +375,45 @@ Client-side image generation for React applications with Echo billing and image
</Tab>
</Tabs>
</Step>
</Steps>

## Auth.js (NextAuth)

Next.js application demonstrating Echo as an Auth.js provider for authentication.

[View on GitHub](https://github.com/Merit-Systems/echo/tree/master/templates/authjs)

<Steps>
<Step>
### Create an Echo App
Go to [echo.merit.systems/new](https://echo.merit.systems/new) to get an `app_id`.
</Step>

<Step>
### Create an Auth.js app
Run the following commands to create a new app with Auth.js integration.

<Tabs items={['npm', 'yarn', 'pnpm', 'bun']}>
<Tab value="npm">
```sh lineNumbers
npx echo-start@latest --template authjs --app-id YOUR_ECHO_APP_ID
```
</Tab>
<Tab value="yarn">
```sh lineNumbers
yarn dlx echo-start@latest --template authjs --app-id YOUR_ECHO_APP_ID
```
</Tab>
<Tab value="pnpm">
```sh lineNumbers
pnpx echo-start@latest --template authjs --app-id YOUR_ECHO_APP_ID
```
</Tab>
<Tab value="bun">
```sh lineNumbers
bunx echo-start@latest --template authjs --app-id YOUR_ECHO_APP_ID
```
</Tab>
</Tabs>
</Step>
</Steps>
1 change: 1 addition & 0 deletions packages/app/control/docs/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ We provide a variety of ready-to-use templates to help you get started quickly w
- **Next.js Image Generation** — Image generation app with Echo billing
- **Next.js Video** — Video generation app with Echo integration
- **Next.js API Key** — Server-side API key management template
- **Auth.js (NextAuth)** — Next.js app with Echo as an Auth.js provider
- **React Chat** — Chat interface for React apps
- **React Image** — Image generation for React apps

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SiNextdotjs, SiReact } from '@icons-pack/react-simple-icons';
import { AppWindow, BotMessageSquare, Image } from 'lucide-react';
import { AppWindow, BotMessageSquare, Image, KeyRound } from 'lucide-react';
import type { Route } from 'next';
import Link from 'next/link';
import type { TemplateGroup } from './types';
Expand Down Expand Up @@ -49,6 +49,14 @@ export const TEMPLATES: TemplateGroup = {
Icon: Image,
url: 'https://echo-next-image.vercel.app/',
},
{
id: 'authjs',
title: 'Auth.js (NextAuth)',
description:
'Next.js application with Echo as an Auth.js provider for authentication.',
Icon: KeyRound,
url: 'https://echo-authjs.vercel.app/',
},
Comment thread
sachigoyal marked this conversation as resolved.
Outdated
{
id: 'next',
title: 'Boilerplate',
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk/auth-js-provider/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@merit/echo-authjs-provider",
"version": "1.0.1",
"name": "@merit-systems/echo-authjs-provider",
"version": "0.0.1",
"description": "Auth.js provider for Echo login",
"type": "module",
"main": "./dist/index.js",
Expand Down
5 changes: 4 additions & 1 deletion packages/sdk/auth-js-provider/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function validateAppId(appId: string, context?: string): void {
* const response = await Auth(request, {
* providers: [
* Echo({
* clientId: ECHO_CLIENT_ID,
* appId: ECHO_APP_ID,
* }),
* ],
* })
Expand Down Expand Up @@ -96,6 +96,9 @@ export default function Echo(
image: profile.picture || null,
};
},
client: {
token_endpoint_auth_method: 'none',
},
options: config,
};
}
5 changes: 5 additions & 0 deletions packages/sdk/echo-start/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ const DEFAULT_TEMPLATES = {
description:
'Vite React application with Echo and the Vercel AI SDK for image generation',
},
authjs: {
title: 'Auth.js (NextAuth)',
description:
'Next.js application with Echo as an Auth.js provider for authentication',
},
} as const;

type TemplateName = keyof typeof DEFAULT_TEMPLATES;
Expand Down
16 changes: 16 additions & 0 deletions templates/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,22 @@ npx echo-start@latest --template react-image

---

#### Auth.js (NextAuth) (`authjs`)

Next.js application demonstrating Echo as an Auth.js provider for authentication.

```bash
npx echo-start@latest --template authjs
```

**Features:**

- Auth.js (NextAuth v5) integration
- Echo as authentication provider
- Server-side session management

---

## Template Structure

Each template follows a consistent structure:
Expand Down
5 changes: 5 additions & 0 deletions templates/authjs/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
AUTH_SECRET=

# get from: https://echo.merit.systems
ECHO_APP_ID=
NEXT_PUBLIC_ECHO_APP_ID=
42 changes: 42 additions & 0 deletions templates/authjs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/versions

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# env files (can opt-in for committing if needed)
.env*
!.env.example

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
Loading