@layer-ai/core 0.1.5 → 0.1.7
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/middleware/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAK1D,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,OAAO,CAAC;QAChB,UAAU,OAAO;YACf,MAAM,CAAC,EAAE,MAAM,CAAC;YAChB,UAAU,CAAC,EAAE,MAAM,CAAC;SACrB;KACF;CACF;AAED;;;;;GAKG;AACH,wBAAsB,YAAY,CAChC,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,QAAQ,EACb,IAAI,EAAE,YAAY,GACjB,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/middleware/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAK1D,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,OAAO,CAAC;QAChB,UAAU,OAAO;YACf,MAAM,CAAC,EAAE,MAAM,CAAC;YAChB,UAAU,CAAC,EAAE,MAAM,CAAC;SACrB;KACF;CACF;AAED;;;;;GAKG;AACH,wBAAsB,YAAY,CAChC,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,QAAQ,EACb,IAAI,EAAE,YAAY,GACjB,OAAO,CAAC,IAAI,CAAC,CAkFf;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAC1B,GAAG,EAAE,OAAO,EACZ,GAAG,EAAE,QAAQ,EACb,IAAI,EAAE,YAAY,GACjB,IAAI,CAWN"}
|
package/dist/middleware/auth.js
CHANGED
|
@@ -37,13 +37,10 @@ export async function authenticate(req, res, next) {
|
|
|
37
37
|
.createHash('sha256')
|
|
38
38
|
.update(token)
|
|
39
39
|
.digest('hex');
|
|
40
|
-
//
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
res.status(401).json({ error: 'unauthorized', message: 'Invalid API key' });
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
40
|
+
// All tokens start with 'layer_', so we need to check both API keys and session keys
|
|
41
|
+
// First try API keys
|
|
42
|
+
const apiKeyRecord = await db.getApiKeyByHash(tokenHash);
|
|
43
|
+
if (apiKeyRecord) {
|
|
47
44
|
if (!apiKeyRecord.isActive) {
|
|
48
45
|
res.status(401).json({
|
|
49
46
|
error: 'unauthorized',
|
|
@@ -61,14 +58,16 @@ export async function authenticate(req, res, next) {
|
|
|
61
58
|
next();
|
|
62
59
|
return;
|
|
63
60
|
}
|
|
64
|
-
//
|
|
61
|
+
// Not an API key, try session key
|
|
65
62
|
const sessionKey = await db.getSessionKeyByHash(tokenHash);
|
|
66
|
-
if (
|
|
67
|
-
|
|
63
|
+
if (sessionKey) {
|
|
64
|
+
req.userId = sessionKey.userId;
|
|
65
|
+
next();
|
|
68
66
|
return;
|
|
69
67
|
}
|
|
70
|
-
|
|
71
|
-
|
|
68
|
+
// Neither API key nor session key
|
|
69
|
+
res.status(401).json({ error: 'unauthorized', message: 'Invalid token' });
|
|
70
|
+
return;
|
|
72
71
|
}
|
|
73
72
|
catch (error) {
|
|
74
73
|
console.error('Authentication error:', error);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/routes/auth.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,SAAS,CAAC;AAKpD,QAAA,MAAM,MAAM,EAAE,UAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/routes/auth.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,SAAS,CAAC;AAKpD,QAAA,MAAM,MAAM,EAAE,UAAqB,CAAC;AA4FpC,eAAe,MAAM,CAAC"}
|
package/dist/routes/auth.js
CHANGED
|
@@ -79,11 +79,4 @@ router.post('/token', async (req, res) => {
|
|
|
79
79
|
res.status(500).json({ error: 'internal_error', message: 'Failed to create api key' });
|
|
80
80
|
}
|
|
81
81
|
});
|
|
82
|
-
// GET /auth/session
|
|
83
|
-
// This endpoint is used by NextAuth to check session status
|
|
84
|
-
router.get('/session', async (req, res) => {
|
|
85
|
-
// For now, return null session (not authenticated via this endpoint)
|
|
86
|
-
// NextAuth will handle sessions via its own mechanism
|
|
87
|
-
res.json({ user: null });
|
|
88
|
-
});
|
|
89
82
|
export default router;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anthropic.d.ts","sourceRoot":"","sources":["../../../src/services/providers/anthropic.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAkB,MAAM,eAAe,CAAC;AAe7D,MAAM,WAAW,yBAAyB;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,yBAAyB,GAAG,OAAO,CAAC,gBAAgB,CAAC,
|
|
1
|
+
{"version":3,"file":"anthropic.d.ts","sourceRoot":"","sources":["../../../src/services/providers/anthropic.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAkB,MAAM,eAAe,CAAC;AAe7D,MAAM,WAAW,yBAAyB;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,yBAAyB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAkDnG"}
|
|
@@ -26,13 +26,15 @@ export async function createCompletion(params) {
|
|
|
26
26
|
content: msg.content,
|
|
27
27
|
}));
|
|
28
28
|
// Call anthropic api
|
|
29
|
+
// Note: Anthropic doesn't allow both temperature and top_p
|
|
30
|
+
// If both are set, prioritize temperature
|
|
29
31
|
const response = await getAnthropicClient().messages.create({
|
|
30
32
|
model: params.model,
|
|
31
33
|
max_tokens: params.maxTokens || 1024,
|
|
32
34
|
messages: anthropicMessages,
|
|
33
35
|
...(systemPrompt && { system: systemPrompt }),
|
|
34
36
|
...(params.temperature != null && { temperature: params.temperature }),
|
|
35
|
-
...(params.topP != null && { top_p: params.topP }),
|
|
37
|
+
...(params.topP != null && params.temperature == null && { top_p: params.topP }),
|
|
36
38
|
});
|
|
37
39
|
// Extract response content
|
|
38
40
|
const content = response.content[0].type === 'text'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@layer-ai/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "Core API routes and services for Layer AI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@anthropic-ai/sdk": "^0.39.0",
|
|
35
35
|
"@google/genai": "^1.30.0",
|
|
36
|
-
"@layer-ai/sdk": "
|
|
36
|
+
"@layer-ai/sdk": "workspace:*",
|
|
37
37
|
"bcryptjs": "^2.4.3",
|
|
38
38
|
"express": "^4.18.2",
|
|
39
39
|
"ioredis": "^5.3.2",
|