@frontmcp/plugin-approval 1.8.0 → 1.8.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/README.md +3 -2
- package/approval.identity.d.ts +24 -0
- package/approval.identity.d.ts.map +1 -0
- package/approval.plugin.d.ts +2 -8
- package/approval.plugin.d.ts.map +1 -1
- package/esm/index.mjs +388 -371
- package/esm/package.json +4 -4
- package/hooks/approval-check.hook.d.ts +3 -2
- package/hooks/approval-check.hook.d.ts.map +1 -1
- package/index.js +377 -365
- package/package.json +4 -4
- package/stores/approval-storage.store.d.ts +7 -3
- package/stores/approval-storage.store.d.ts.map +1 -1
- package/types/approval.types.d.ts +7 -0
- package/types/approval.types.d.ts.map +1 -1
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@ Tool authorization workflow with PKCE webhook security for FrontMCP.
|
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
|
-
- **Tool Approval Checking**: Automatic approval check before tool execution via hook
|
|
7
|
+
- **Tool Approval Checking**: Automatic approval check before tool execution via hook, registered by `ApprovalPlugin.init()` (no need to list `ApprovalCheckPlugin`)
|
|
8
8
|
- **Multiple Approval Scopes**: SESSION, USER, TIME_LIMITED, TOOL_SPECIFIC, CONTEXT_SPECIFIC
|
|
9
9
|
- **PKCE Webhook Security**: RFC 7636 compliant PKCE for secure external approval systems
|
|
10
10
|
- **Recheck Mode**: Poll external API for approval status
|
|
@@ -47,13 +47,14 @@ const plugin = ApprovalPlugin.init({
|
|
|
47
47
|
### Using in Tools
|
|
48
48
|
|
|
49
49
|
```typescript
|
|
50
|
+
import { ApprovalScope } from '@frontmcp/plugin-approval';
|
|
50
51
|
import { Tool, ToolContext } from '@frontmcp/sdk';
|
|
51
52
|
|
|
52
53
|
@Tool({
|
|
53
54
|
name: 'dangerous_operation',
|
|
54
55
|
approval: {
|
|
55
56
|
required: true,
|
|
56
|
-
defaultScope:
|
|
57
|
+
defaultScope: ApprovalScope.SESSION,
|
|
57
58
|
category: 'write',
|
|
58
59
|
riskLevel: 'high',
|
|
59
60
|
approvalMessage: 'Allow dangerous operation?',
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Who a call's approvals belong to.
|
|
3
|
+
*
|
|
4
|
+
* @module @frontmcp/plugin-approval
|
|
5
|
+
*/
|
|
6
|
+
import { type FrontMcpContext } from '@frontmcp/sdk';
|
|
7
|
+
export interface ApprovalIdentity {
|
|
8
|
+
/** Key for session-scoped approvals. */
|
|
9
|
+
sessionId: string;
|
|
10
|
+
/** Key for user-scoped approvals, when the call has an authenticated principal. */
|
|
11
|
+
userId: string | undefined;
|
|
12
|
+
}
|
|
13
|
+
type ApprovalCallerContext = Pick<FrontMcpContext, 'sessionId' | 'authInfo'>;
|
|
14
|
+
/**
|
|
15
|
+
* The session and user that a call's approvals are read from and granted to.
|
|
16
|
+
*
|
|
17
|
+
* The stateless transport gives every request the same session id, so keying session
|
|
18
|
+
* approvals on it let one caller's approval admit every other stateless caller. A stateless
|
|
19
|
+
* call is keyed by its authenticated principal instead, and a call with neither a session nor
|
|
20
|
+
* a principal gets a key of its own that no other call can match.
|
|
21
|
+
*/
|
|
22
|
+
export declare function resolveApprovalIdentity(ctx: ApprovalCallerContext | undefined): ApprovalIdentity;
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=approval.identity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"approval.identity.d.ts","sourceRoot":"","sources":["../src/approval.identity.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAwB,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC;AAG3E,MAAM,WAAW,gBAAgB;IAC/B,wCAAwC;IACxC,SAAS,EAAE,MAAM,CAAC;IAClB,mFAAmF;IACnF,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;CAC5B;AAED,KAAK,qBAAqB,GAAG,IAAI,CAAC,eAAe,EAAE,WAAW,GAAG,UAAU,CAAC,CAAC;AAM7E;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,qBAAqB,GAAG,SAAS,GAAG,gBAAgB,CAWhG"}
|
package/approval.plugin.d.ts
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @module @frontmcp/plugin-approval
|
|
5
5
|
*/
|
|
6
|
-
import { DynamicPlugin, ProviderType } from '@frontmcp/sdk';
|
|
7
|
-
import type {
|
|
6
|
+
import { DynamicPlugin, type ProviderType } from '@frontmcp/sdk';
|
|
7
|
+
import type { NamespacedStorage, RootStorage, StorageConfig } from '@frontmcp/utils';
|
|
8
8
|
import type { ApprovalMode } from './types';
|
|
9
9
|
/**
|
|
10
10
|
* Configuration options for ApprovalPlugin.
|
|
@@ -117,12 +117,6 @@ export default class ApprovalPlugin extends DynamicPlugin<ApprovalPluginOptions>
|
|
|
117
117
|
* Dynamic providers based on plugin options.
|
|
118
118
|
*/
|
|
119
119
|
static dynamicProviders: (options: ApprovalPluginOptions) => ProviderType[];
|
|
120
|
-
/**
|
|
121
|
-
* Get plugin metadata including nested plugins.
|
|
122
|
-
*/
|
|
123
|
-
static getPluginMetadata(_options: ApprovalPluginOptions): {
|
|
124
|
-
plugins?: unknown[];
|
|
125
|
-
};
|
|
126
120
|
}
|
|
127
121
|
export { ApprovalPlugin };
|
|
128
122
|
//# sourceMappingURL=approval.plugin.d.ts.map
|
package/approval.plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"approval.plugin.d.ts","sourceRoot":"","sources":["../src/approval.plugin.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"approval.plugin.d.ts","sourceRoot":"","sources":["../src/approval.plugin.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,aAAa,EAKb,KAAK,YAAY,EAClB,MAAM,eAAe,CAAC;A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