@autonoma-ai/server-express 0.1.11 → 0.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +8 -7
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -15,16 +15,17 @@ pnpm add @autonoma-ai/sdk @autonoma-ai/sdk-prisma @autonoma-ai/server-express
15
15
  ```typescript
16
16
  import express from 'express'
17
17
  import { createExpressHandler } from '@autonoma-ai/server-express'
18
- import { prismaAdapter } from '@autonoma-ai/sdk-prisma'
18
+ import { prismaExecutor } from '@autonoma-ai/sdk-prisma'
19
19
  import { prisma } from './db'
20
20
 
21
21
  const app = express()
22
22
 
23
23
  app.post('/api/autonoma', createExpressHandler({
24
- adapter: prismaAdapter(prisma, { scopeField: 'organizationId' }),
24
+ executor: prismaExecutor(prisma),
25
+ scopeField: 'organizationId',
25
26
  sharedSecret: process.env.AUTONOMA_SHARED_SECRET!,
26
27
  signingSecret: process.env.AUTONOMA_SIGNING_SECRET!,
27
- auth: async (user) => {
28
+ auth: async (user, context) => {
28
29
  const session = await createSession(user.id as string)
29
30
  return { headers: { Authorization: `Bearer ${session.token}` } }
30
31
  },
@@ -49,11 +50,11 @@ app.post('/api/autonoma', async (req, reply) => {
49
50
 
50
51
  ## Auth callback
51
52
 
52
- The `auth` callback receives the first `User` record created during setup (or `null` if no User model exists) and must return credentials for the test runner to authenticate:
53
+ The `auth` callback receives the first `User` record created during setup (or `null` if no User model exists) and a context object with `scopeValue` and `refs`. It must return credentials for the test runner to authenticate:
53
54
 
54
55
  ```typescript
55
56
  // Session cookie
56
- auth: async (user) => {
57
+ auth: async (user, context) => {
57
58
  const session = await createSession(user.id as string)
58
59
  return {
59
60
  cookies: [{ name: 'session', value: session.token, httpOnly: true, sameSite: 'lax', path: '/' }],
@@ -61,13 +62,13 @@ auth: async (user) => {
61
62
  }
62
63
 
63
64
  // Bearer token
64
- auth: async (user) => {
65
+ auth: async (user, context) => {
65
66
  const token = jwt.sign({ sub: user.id }, SECRET)
66
67
  return { headers: { Authorization: `Bearer ${token}` } }
67
68
  }
68
69
 
69
70
  // Username + password (for login-page flows)
70
- auth: async (user) => {
71
+ auth: async (user, context) => {
71
72
  return { credentials: { email: user.email as string, password: 'TestP@ssw0rd123!' } }
72
73
  }
73
74
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autonoma-ai/server-express",
3
- "version": "0.1.11",
3
+ "version": "0.1.13",
4
4
  "description": "Express/Fastify server adapter for Autonoma SDK",
5
5
  "type": "module",
6
6
  "exports": {
@@ -16,7 +16,7 @@
16
16
  "access": "public"
17
17
  },
18
18
  "dependencies": {
19
- "@autonoma-ai/sdk": "0.1.11"
19
+ "@autonoma-ai/sdk": "0.1.13"
20
20
  },
21
21
  "devDependencies": {
22
22
  "@types/node": "^22.0.0",