@exposify/firebase 0.0.1 → 0.0.2
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.
- package/README.md +5 -1
- package/dist/index.cjs +10 -4
- package/dist/index.js +11 -4
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -70,7 +70,11 @@ broker as the authorization server, and the client sends the user through
|
|
|
70
70
|
sign-in. Tool calls then reach Firestore with the `Authorization` the broker
|
|
71
71
|
resolves for that user, never the broker token itself, so your rules still
|
|
72
72
|
decide. Requests without a connection are refused rather
|
|
73
|
-
than run anonymously; pass `authRequired: false` to allow them.
|
|
73
|
+
than run anonymously; pass `authRequired: false` to allow them. The
|
|
74
|
+
exception: when the project has no sign-in method yet (add the Firebase
|
|
75
|
+
preset in the dashboard), agents use the function signed out, as the
|
|
76
|
+
anonymous user, with no sign-in asked. The startup log says which it is
|
|
77
|
+
(`[agentready] How agents sign in: ...`).
|
|
74
78
|
|
|
75
79
|
`auth: hostedBroker()` does the same explicitly. If the function is
|
|
76
80
|
reached through a URL other than the one it sees (a custom domain or a
|
package/dist/index.cjs
CHANGED
|
@@ -807,13 +807,19 @@ function createFirebaseMcpHandler(options = {}) {
|
|
|
807
807
|
if (!auth) return core;
|
|
808
808
|
const brokerGate = authRequired ? (0, import_core2.createBrokerGate)(auth) : null;
|
|
809
809
|
return async (req) => {
|
|
810
|
+
let open = false;
|
|
810
811
|
if (brokerGate) {
|
|
811
812
|
const own = (0, import_core2.publicRequestUrl)(req.url, req.headers);
|
|
812
813
|
const isPrm = own.endsWith(import_core2.PRM_PATH);
|
|
813
814
|
const resource = brokerGate.resourceFor(functionPublicUrl(isPrm ? own.slice(0, -import_core2.PRM_PATH.length) : own, functionName));
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
815
|
+
open = await (0, import_core2.reportAppLogin)(auth, resource, null, { stacks: ["firebase-admin"], why: "Firebase Auth sign-in for agents is the Firebase preset in the dashboard's sign-in methods.", log: logReady }) === "open";
|
|
816
|
+
if (open) {
|
|
817
|
+
if (isPrm) return new Response("not found", { status: 404 });
|
|
818
|
+
} else {
|
|
819
|
+
if (isPrm) return brokerGate.metadataResponse(req.method, resource);
|
|
820
|
+
const result = await brokerGate.check(req.headers, resource, `${resource}${import_core2.PRM_PATH}`);
|
|
821
|
+
if (!result.ok) return result.response;
|
|
822
|
+
}
|
|
817
823
|
}
|
|
818
824
|
let resolved;
|
|
819
825
|
try {
|
|
@@ -822,7 +828,7 @@ function createFirebaseMcpHandler(options = {}) {
|
|
|
822
828
|
console.error(`${LOG_PREFIX} auth resolver failed`, err);
|
|
823
829
|
return Response.json({ error: "internal MCP server error" }, { status: 503 });
|
|
824
830
|
}
|
|
825
|
-
if (authRequired && !resolved.get("authorization")) {
|
|
831
|
+
if (authRequired && !open && !resolved.get("authorization")) {
|
|
826
832
|
return Response.json({ error: "unauthorized" }, { status: 401, headers: { "www-authenticate": "Bearer" } });
|
|
827
833
|
}
|
|
828
834
|
resolvedAuth.set(req, resolved);
|
package/dist/index.js
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
KnowledgeBase,
|
|
11
11
|
PRM_PATH,
|
|
12
12
|
publicRequestUrl,
|
|
13
|
+
reportAppLogin,
|
|
13
14
|
startupLogEnabled
|
|
14
15
|
} from "@exposify/core";
|
|
15
16
|
import { loadDocsFromFs } from "@exposify/core/node";
|
|
@@ -786,13 +787,19 @@ function createFirebaseMcpHandler(options = {}) {
|
|
|
786
787
|
if (!auth) return core;
|
|
787
788
|
const brokerGate = authRequired ? createBrokerGate(auth) : null;
|
|
788
789
|
return async (req) => {
|
|
790
|
+
let open = false;
|
|
789
791
|
if (brokerGate) {
|
|
790
792
|
const own = publicRequestUrl(req.url, req.headers);
|
|
791
793
|
const isPrm = own.endsWith(PRM_PATH);
|
|
792
794
|
const resource = brokerGate.resourceFor(functionPublicUrl(isPrm ? own.slice(0, -PRM_PATH.length) : own, functionName));
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
795
|
+
open = await reportAppLogin(auth, resource, null, { stacks: ["firebase-admin"], why: "Firebase Auth sign-in for agents is the Firebase preset in the dashboard's sign-in methods.", log: logReady }) === "open";
|
|
796
|
+
if (open) {
|
|
797
|
+
if (isPrm) return new Response("not found", { status: 404 });
|
|
798
|
+
} else {
|
|
799
|
+
if (isPrm) return brokerGate.metadataResponse(req.method, resource);
|
|
800
|
+
const result = await brokerGate.check(req.headers, resource, `${resource}${PRM_PATH}`);
|
|
801
|
+
if (!result.ok) return result.response;
|
|
802
|
+
}
|
|
796
803
|
}
|
|
797
804
|
let resolved;
|
|
798
805
|
try {
|
|
@@ -801,7 +808,7 @@ function createFirebaseMcpHandler(options = {}) {
|
|
|
801
808
|
console.error(`${LOG_PREFIX} auth resolver failed`, err);
|
|
802
809
|
return Response.json({ error: "internal MCP server error" }, { status: 503 });
|
|
803
810
|
}
|
|
804
|
-
if (authRequired && !resolved.get("authorization")) {
|
|
811
|
+
if (authRequired && !open && !resolved.get("authorization")) {
|
|
805
812
|
return Response.json({ error: "unauthorized" }, { status: 401, headers: { "www-authenticate": "Bearer" } });
|
|
806
813
|
}
|
|
807
814
|
resolvedAuth.set(req, resolved);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exposify/firebase",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=20.19"
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"prepack": "yarn build"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@exposify/core": "0.3.
|
|
32
|
+
"@exposify/core": "0.3.14",
|
|
33
33
|
"@modelcontextprotocol/sdk": "^1.12.0",
|
|
34
34
|
"zod": "^3.24.0"
|
|
35
35
|
},
|