@dereekb/firebase-server 14.4.0 → 14.5.1
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/calcom/package.json +11 -10
- package/discord/package.json +14 -10
- package/index.esm.js +1295 -317
- package/mailgun/package.json +9 -9
- package/mcp/index.esm.js +483 -83
- package/mcp/package.json +12 -12
- package/mcp/src/lib/mcp.config.d.ts +73 -3
- package/mcp/src/lib/service/index.d.ts +1 -0
- package/mcp/src/lib/service/mcp.server.factory.d.ts +3 -2
- package/mcp/src/lib/service/mcp.tool-generator.d.ts +9 -0
- package/mcp/src/lib/service/tools/mcp.tool.cli-token.d.ts +62 -0
- package/model/package.json +13 -10
- package/oidc/index.esm.js +3186 -1456
- package/oidc/package.json +11 -11
- package/oidc/src/lib/controller/index.d.ts +3 -0
- package/oidc/src/lib/controller/oidc.cli-token.config.d.ts +323 -0
- package/oidc/src/lib/controller/oidc.cli-token.controller.d.ts +45 -0
- package/oidc/src/lib/controller/oidc.cli-token.service.d.ts +138 -0
- package/oidc/src/lib/controller/oidc.interaction.controller.d.ts +38 -0
- package/oidc/src/lib/middleware/oauth-auth.module.d.ts +8 -0
- package/oidc/src/lib/oidc.config.d.ts +9 -0
- package/oidc/src/lib/oidc.module.d.ts +1 -1
- package/oidc/src/lib/service/index.d.ts +1 -0
- package/oidc/src/lib/service/oidc.config.service.d.ts +8 -3
- package/oidc/src/lib/service/oidc.download-signer.d.ts +17 -0
- package/oidc/src/lib/service/oidc.jwt-signing.service.d.ts +35 -0
- package/package.json +13 -13
- package/src/lib/nest/controller/download/download.api.config.d.ts +203 -0
- package/src/lib/nest/controller/download/download.api.controller.d.ts +25 -0
- package/src/lib/nest/controller/download/download.api.module.d.ts +47 -0
- package/src/lib/nest/controller/download/download.api.service.d.ts +111 -0
- package/src/lib/nest/controller/download/index.d.ts +4 -0
- package/src/lib/nest/controller/index.d.ts +2 -0
- package/src/lib/nest/controller/request.ip.d.ts +60 -0
- package/test/index.esm.js +1 -0
- package/test/package.json +12 -12
- package/test/src/lib/oidc/oidc.test.flow.d.ts +10 -0
- package/twilio/package.json +8 -8
- package/zoho/package.json +14 -10
package/mcp/package.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/firebase-server/mcp",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.5.1",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"peerDependencies": {
|
|
7
|
-
"@dereekb/analytics": "14.
|
|
8
|
-
"@dereekb/date": "14.
|
|
9
|
-
"@dereekb/firebase": "14.
|
|
10
|
-
"@dereekb/firebase-server": "14.
|
|
11
|
-
"@dereekb/firebase-server/oidc": "14.
|
|
12
|
-
"@dereekb/model": "14.
|
|
13
|
-
"@dereekb/nestjs": "14.
|
|
14
|
-
"@dereekb/oauth-resource": "14.
|
|
15
|
-
"@dereekb/rxjs": "14.
|
|
16
|
-
"@dereekb/util": "14.
|
|
17
|
-
"@dereekb/zoho": "14.
|
|
7
|
+
"@dereekb/analytics": "14.5.1",
|
|
8
|
+
"@dereekb/date": "14.5.1",
|
|
9
|
+
"@dereekb/firebase": "14.5.1",
|
|
10
|
+
"@dereekb/firebase-server": "14.5.1",
|
|
11
|
+
"@dereekb/firebase-server/oidc": "14.5.1",
|
|
12
|
+
"@dereekb/model": "14.5.1",
|
|
13
|
+
"@dereekb/nestjs": "14.5.1",
|
|
14
|
+
"@dereekb/oauth-resource": "14.5.1",
|
|
15
|
+
"@dereekb/rxjs": "14.5.1",
|
|
16
|
+
"@dereekb/util": "14.5.1",
|
|
17
|
+
"@dereekb/zoho": "14.5.1",
|
|
18
18
|
"@modelcontextprotocol/node": "2.0.0",
|
|
19
19
|
"@modelcontextprotocol/server": "2.0.0",
|
|
20
20
|
"@nestjs/common": "^12.0.1",
|
|
@@ -132,9 +132,11 @@ export declare abstract class McpModuleConfig {
|
|
|
132
132
|
* injected {@link OidcProviderConfigService.clientRequestableScopesSupported}, so
|
|
133
133
|
* the MCP resource advertises the scopes the issuer grants an arbitrary client
|
|
134
134
|
* without the app restating them. Scopes only an admin-assigned provider profile
|
|
135
|
-
* unlocks are
|
|
136
|
-
*
|
|
137
|
-
*
|
|
135
|
+
* unlocks are excluded from that base list, since an unassigned client can never
|
|
136
|
+
* be granted one. Provide this to narrow the set further — or to add such a gated
|
|
137
|
+
* scope back deliberately, which is safe: the consent URL builder withholds it
|
|
138
|
+
* from any client whose profiles do not unlock it, so that client's flow completes
|
|
139
|
+
* without it rather than failing. When unset, the whole base list is advertised.
|
|
138
140
|
*
|
|
139
141
|
* Advertising these matters because dynamic-registration MCP clients (the Claude
|
|
140
142
|
* Code CLI) read `scopes_supported` to decide which scopes to request on the
|
|
@@ -259,3 +261,71 @@ export type McpModelRolesTargetUidPredicate = (auth: Maybe<FirebaseServerAuthDat
|
|
|
259
261
|
* NestJS injection token for the optional {@link McpModelRolesTargetUidPredicate} provider.
|
|
260
262
|
*/
|
|
261
263
|
export declare const MCP_MODEL_ROLES_TARGET_UID_PREDICATE = "MCP_MODEL_ROLES_TARGET_UID_PREDICATE";
|
|
264
|
+
/**
|
|
265
|
+
* Input handed to an {@link McpCliTokenMinter}.
|
|
266
|
+
*/
|
|
267
|
+
export interface McpCliTokenMintInput {
|
|
268
|
+
/**
|
|
269
|
+
* The calling request's auth data — the identity the minted credential belongs to.
|
|
270
|
+
*/
|
|
271
|
+
readonly auth: Maybe<FirebaseServerAuthData>;
|
|
272
|
+
/**
|
|
273
|
+
* An optional subset of the caller's own scopes to grant. May only narrow.
|
|
274
|
+
*/
|
|
275
|
+
readonly scopes?: Maybe<readonly string[]>;
|
|
276
|
+
/**
|
|
277
|
+
* An optional requested lifetime in seconds, clamped by the minter.
|
|
278
|
+
*/
|
|
279
|
+
readonly ttlSeconds?: Maybe<number>;
|
|
280
|
+
/**
|
|
281
|
+
* When true, ask the minter to also produce a signed, self-authenticating download URL for the
|
|
282
|
+
* CLI binary so a bare machine can fetch it before redeeming the claim code.
|
|
283
|
+
*/
|
|
284
|
+
readonly includeDownloadUrl?: boolean;
|
|
285
|
+
/**
|
|
286
|
+
* The calling MCP session's client address, resolved from the tool call's raw request.
|
|
287
|
+
*
|
|
288
|
+
* Forwarded so a mint through the MCP surface records the same address an HTTP mint does. Without
|
|
289
|
+
* it an app that binds a claim code to its minting address would silently apply that binding on one
|
|
290
|
+
* path and not the other — a gate that looks enabled while doing nothing is worse than none.
|
|
291
|
+
*/
|
|
292
|
+
readonly requestIp?: Maybe<string>;
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* What an {@link McpCliTokenMinter} returns. Carries the one-time claim code and NEVER the refresh
|
|
296
|
+
* token — the tool's output reaches an MCP transcript, and a refresh token must not.
|
|
297
|
+
*/
|
|
298
|
+
export interface McpCliTokenMintResult {
|
|
299
|
+
readonly claimCode: string;
|
|
300
|
+
readonly claimExpiresAt: string;
|
|
301
|
+
readonly expiresAt: string;
|
|
302
|
+
readonly scope: string;
|
|
303
|
+
/**
|
|
304
|
+
* The CLI's binary name, used to render the exact `<cli> auth handoff <code>` command.
|
|
305
|
+
*/
|
|
306
|
+
readonly cliName?: string;
|
|
307
|
+
/**
|
|
308
|
+
* A signed download URL for the CLI binary, when one was requested and the app wired the
|
|
309
|
+
* download path.
|
|
310
|
+
*/
|
|
311
|
+
readonly downloadUrl?: string;
|
|
312
|
+
/**
|
|
313
|
+
* SHA-256 of the artifact behind {@link downloadUrl}, so the caller can verify what it fetched.
|
|
314
|
+
*/
|
|
315
|
+
readonly downloadSha256?: string;
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Signature for the optional app-supplied CLI credential minter behind the `cli-token` MCP tool.
|
|
319
|
+
*
|
|
320
|
+
* Minting needs `OidcService.getProvider()`, which lives in `@dereekb/firebase-server/oidc`. Routing
|
|
321
|
+
* it through an app-supplied injection token — the same shape as
|
|
322
|
+
* {@link McpModelRolesTargetUidPredicate} — keeps `@dereekb/firebase-server/mcp` app-agnostic and
|
|
323
|
+
* free of a dependency on the oidc package.
|
|
324
|
+
*
|
|
325
|
+
* When no minter is provided the `cli-token` tool is not registered at all.
|
|
326
|
+
*/
|
|
327
|
+
export type McpCliTokenMinter = (input: McpCliTokenMintInput) => PromiseOrValue<McpCliTokenMintResult>;
|
|
328
|
+
/**
|
|
329
|
+
* NestJS injection token for the optional {@link McpCliTokenMinter} provider.
|
|
330
|
+
*/
|
|
331
|
+
export declare const MCP_CLI_TOKEN_MINTER = "MCP_CLI_TOKEN_MINTER";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { McpServer } from '@modelcontextprotocol/server';
|
|
2
2
|
import { type Request } from 'express';
|
|
3
3
|
import { ModelApiCallModelDispatchService, ModelApiGetService, FirebaseServerStorageService, type FirebaseServerAuthData } from '@dereekb/firebase-server';
|
|
4
|
-
import { McpModuleConfig, type McpAuthRoleReader, type McpModelRolesTargetUidPredicate } from '../mcp.config';
|
|
4
|
+
import { McpModuleConfig, type McpAuthRoleReader, type McpCliTokenMinter, type McpModelRolesTargetUidPredicate } from '../mcp.config';
|
|
5
5
|
import { type McpAnalyticsService } from './analytics/mcp.analytics.handler';
|
|
6
6
|
/**
|
|
7
7
|
* Optional per-request context passed when invoking the MCP server through a
|
|
@@ -29,6 +29,7 @@ export declare class McpServerFactoryService {
|
|
|
29
29
|
private readonly roleReader?;
|
|
30
30
|
private readonly storageService?;
|
|
31
31
|
private readonly modelRolesTargetUidPredicate?;
|
|
32
|
+
private readonly cliTokenMinter?;
|
|
32
33
|
private readonly _logger;
|
|
33
34
|
private _cachedTools;
|
|
34
35
|
private _cachedStaticTools;
|
|
@@ -43,7 +44,7 @@ export declare class McpServerFactoryService {
|
|
|
43
44
|
private _warnedMissingRoleReader;
|
|
44
45
|
private _resolvedReasonConfig?;
|
|
45
46
|
private readonly _analyticsService;
|
|
46
|
-
constructor(mcpConfig: McpModuleConfig, dispatchService: ModelApiCallModelDispatchService, modelApiGetService?: ModelApiGetService | undefined, roleReader?: McpAuthRoleReader | undefined, analyticsService?: McpAnalyticsService, storageService?: FirebaseServerStorageService | undefined, modelRolesTargetUidPredicate?: McpModelRolesTargetUidPredicate | undefined);
|
|
47
|
+
constructor(mcpConfig: McpModuleConfig, dispatchService: ModelApiCallModelDispatchService, modelApiGetService?: ModelApiGetService | undefined, roleReader?: McpAuthRoleReader | undefined, analyticsService?: McpAnalyticsService, storageService?: FirebaseServerStorageService | undefined, modelRolesTargetUidPredicate?: McpModelRolesTargetUidPredicate | undefined, cliTokenMinter?: McpCliTokenMinter | undefined);
|
|
47
48
|
/**
|
|
48
49
|
* Builds a configured MCP server with tool listing + dispatch handlers wired up.
|
|
49
50
|
*
|
|
@@ -281,6 +281,15 @@ export interface BuildStaticToolDefinitionInput {
|
|
|
281
281
|
* Declarative visibility rule checked per request. Defaults to `{}` (always visible) when omitted.
|
|
282
282
|
*/
|
|
283
283
|
readonly rule?: McpVisibilityRule;
|
|
284
|
+
/**
|
|
285
|
+
* OIDC scope TERMS an OIDC caller must satisfy to see AND to invoke this tool, evaluated by the
|
|
286
|
+
* same `oidcScopeTermsSatisfied` path the generated callModel tools use.
|
|
287
|
+
*
|
|
288
|
+
* Generated tools derive their terms from the dispatch call type; a built-in tool has no model
|
|
289
|
+
* verb to derive from, so a privileged one declares its own here (e.g. the CLI-token mint gates on
|
|
290
|
+
* `token.cli`). Omitted ⇒ no scope requirement, which is right for every read-only built-in.
|
|
291
|
+
*/
|
|
292
|
+
readonly requiredScopeTerms?: readonly OidcScopeTerm[];
|
|
284
293
|
}
|
|
285
294
|
/**
|
|
286
295
|
* Assembles a statically-registered {@link McpToolDefinition} with consistent MCP annotations.
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { type McpCliTokenMinter } from '../../mcp.config';
|
|
2
|
+
import { type McpToolDefinition } from '../mcp.tool-generator';
|
|
3
|
+
/**
|
|
4
|
+
* Reserved tool name for the built-in `cli-token` static tool.
|
|
5
|
+
*/
|
|
6
|
+
export declare const CLI_TOKEN_TOOL_NAME = "cli-token";
|
|
7
|
+
/**
|
|
8
|
+
* Synthetic call type used in the tool's dispatch identity. `create` so the visibility classifier
|
|
9
|
+
* treats the tool as a write — minting a credential is not a read.
|
|
10
|
+
*/
|
|
11
|
+
export declare const CLI_TOKEN_DISPATCH_CALL = "create";
|
|
12
|
+
/**
|
|
13
|
+
* Synthetic model type used in the tool's dispatch identity.
|
|
14
|
+
*/
|
|
15
|
+
export declare const CLI_TOKEN_DISPATCH_MODEL_TYPE = "auth";
|
|
16
|
+
/**
|
|
17
|
+
* Constructor dependencies for {@link createCliTokenTool}.
|
|
18
|
+
*/
|
|
19
|
+
export interface CreateCliTokenToolDeps {
|
|
20
|
+
/**
|
|
21
|
+
* The app-supplied minter. The tool is only ever built when one is wired.
|
|
22
|
+
*/
|
|
23
|
+
readonly minter: McpCliTokenMinter;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Output payload for the `cli-token` tool.
|
|
27
|
+
*
|
|
28
|
+
* Deliberately does NOT carry the refresh token: the claim code is a one-time, short-lived pointer
|
|
29
|
+
* at it, which is what makes the tool's output safe to leave in a transcript.
|
|
30
|
+
*/
|
|
31
|
+
export interface CliTokenToolOutput {
|
|
32
|
+
readonly claimCode: string;
|
|
33
|
+
readonly claimExpiresAt: string;
|
|
34
|
+
readonly expiresAt: string;
|
|
35
|
+
readonly scope: string;
|
|
36
|
+
readonly cliName?: string;
|
|
37
|
+
readonly downloadUrl?: string;
|
|
38
|
+
readonly downloadSha256?: string;
|
|
39
|
+
/**
|
|
40
|
+
* The exact command to run once the CLI is on the machine.
|
|
41
|
+
*/
|
|
42
|
+
readonly handoffCommand: string;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Builds the built-in `cli-token` MCP tool definition — the agent-facing half of the CLI handoff.
|
|
46
|
+
*
|
|
47
|
+
* Mints a short-lived CLI login credential carrying no more privilege than the calling session and
|
|
48
|
+
* returns the one-time claim code that unwraps it, optionally alongside a signed download URL for
|
|
49
|
+
* the CLI binary so a bare machine can go from nothing to logged in without a human.
|
|
50
|
+
*
|
|
51
|
+
* Three independent gates apply before the handler ever runs:
|
|
52
|
+
*
|
|
53
|
+
* - `requiredScopeTerms: [token.cli]` — the tool is invisible to `tools/list` AND uncallable without
|
|
54
|
+
* the scope, through the factory's existing scope filter.
|
|
55
|
+
* - `visibility.requiredRoles: [admin]` — the declarative role gate, which fails closed when the app
|
|
56
|
+
* wires no `McpAuthRoleReader`.
|
|
57
|
+
* - The mint endpoint's own admin predicate, inside the minter.
|
|
58
|
+
*
|
|
59
|
+
* @param deps - The app-supplied minter.
|
|
60
|
+
* @returns A statically-registered {@link McpToolDefinition} to append to the MCP server factory's tool registry.
|
|
61
|
+
*/
|
|
62
|
+
export declare function createCliTokenTool(deps: CreateCliTokenToolDeps): McpToolDefinition;
|
package/model/package.json
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/firebase-server/model",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.5.1",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"peerDependencies": {
|
|
7
|
-
"@
|
|
8
|
-
"@dereekb/
|
|
9
|
-
"@dereekb/
|
|
10
|
-
"@dereekb/firebase
|
|
11
|
-
"@dereekb/
|
|
12
|
-
"@dereekb/
|
|
13
|
-
"@dereekb/
|
|
14
|
-
"@dereekb/
|
|
7
|
+
"@cantoo/pdf-lib": ">=2.6.5 <2.11.0",
|
|
8
|
+
"@dereekb/analytics": "14.5.1",
|
|
9
|
+
"@dereekb/date": "14.5.1",
|
|
10
|
+
"@dereekb/firebase": "14.5.1",
|
|
11
|
+
"@dereekb/firebase-server": "14.5.1",
|
|
12
|
+
"@dereekb/model": "14.5.1",
|
|
13
|
+
"@dereekb/nestjs": "14.5.1",
|
|
14
|
+
"@dereekb/rxjs": "14.5.1",
|
|
15
|
+
"@dereekb/util": "14.5.1",
|
|
15
16
|
"@nestjs/common": "^12.0.1",
|
|
16
17
|
"@nestjs/config": "^12.0.0",
|
|
17
18
|
"archiver": "^8.0.0",
|
|
@@ -19,9 +20,11 @@
|
|
|
19
20
|
"express": "^5.2.1",
|
|
20
21
|
"firebase-functions": "^7.3.2",
|
|
21
22
|
"make-error": "^1.3.6",
|
|
22
|
-
"@cantoo/pdf-lib": ">=2.6.5 <2.11.0",
|
|
23
23
|
"sharp": "0.35.4"
|
|
24
24
|
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"firebase-admin": "^13.10.0"
|
|
27
|
+
},
|
|
25
28
|
"exports": {
|
|
26
29
|
"./package.json": "./package.json",
|
|
27
30
|
".": {
|