@mcp-z/oauth-microsoft 1.0.0
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/LICENSE +21 -0
- package/README.md +98 -0
- package/dist/cjs/index.d.cts +16 -0
- package/dist/cjs/index.d.ts +16 -0
- package/dist/cjs/index.js +112 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/lib/dcr-router.d.cts +44 -0
- package/dist/cjs/lib/dcr-router.d.ts +44 -0
- package/dist/cjs/lib/dcr-router.js +1227 -0
- package/dist/cjs/lib/dcr-router.js.map +1 -0
- package/dist/cjs/lib/dcr-utils.d.cts +160 -0
- package/dist/cjs/lib/dcr-utils.d.ts +160 -0
- package/dist/cjs/lib/dcr-utils.js +860 -0
- package/dist/cjs/lib/dcr-utils.js.map +1 -0
- package/dist/cjs/lib/dcr-verify.d.cts +53 -0
- package/dist/cjs/lib/dcr-verify.d.ts +53 -0
- package/dist/cjs/lib/dcr-verify.js +193 -0
- package/dist/cjs/lib/dcr-verify.js.map +1 -0
- package/dist/cjs/lib/fetch-with-timeout.d.cts +14 -0
- package/dist/cjs/lib/fetch-with-timeout.d.ts +14 -0
- package/dist/cjs/lib/fetch-with-timeout.js +257 -0
- package/dist/cjs/lib/fetch-with-timeout.js.map +1 -0
- package/dist/cjs/lib/token-verifier.d.cts +44 -0
- package/dist/cjs/lib/token-verifier.d.ts +44 -0
- package/dist/cjs/lib/token-verifier.js +253 -0
- package/dist/cjs/lib/token-verifier.js.map +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/providers/dcr.d.cts +110 -0
- package/dist/cjs/providers/dcr.d.ts +110 -0
- package/dist/cjs/providers/dcr.js +600 -0
- package/dist/cjs/providers/dcr.js.map +1 -0
- package/dist/cjs/providers/device-code.d.cts +179 -0
- package/dist/cjs/providers/device-code.d.ts +179 -0
- package/dist/cjs/providers/device-code.js +896 -0
- package/dist/cjs/providers/device-code.js.map +1 -0
- package/dist/cjs/providers/loopback-oauth.d.cts +125 -0
- package/dist/cjs/providers/loopback-oauth.d.ts +125 -0
- package/dist/cjs/providers/loopback-oauth.js +1325 -0
- package/dist/cjs/providers/loopback-oauth.js.map +1 -0
- package/dist/cjs/schemas/index.d.cts +20 -0
- package/dist/cjs/schemas/index.d.ts +20 -0
- package/dist/cjs/schemas/index.js +37 -0
- package/dist/cjs/schemas/index.js.map +1 -0
- package/dist/cjs/setup/config.d.cts +113 -0
- package/dist/cjs/setup/config.d.ts +113 -0
- package/dist/cjs/setup/config.js +246 -0
- package/dist/cjs/setup/config.js.map +1 -0
- package/dist/cjs/types.d.cts +188 -0
- package/dist/cjs/types.d.ts +188 -0
- package/dist/cjs/types.js +18 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/esm/index.d.ts +16 -0
- package/dist/esm/index.js +16 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/lib/dcr-router.d.ts +44 -0
- package/dist/esm/lib/dcr-router.js +556 -0
- package/dist/esm/lib/dcr-router.js.map +1 -0
- package/dist/esm/lib/dcr-utils.d.ts +160 -0
- package/dist/esm/lib/dcr-utils.js +270 -0
- package/dist/esm/lib/dcr-utils.js.map +1 -0
- package/dist/esm/lib/dcr-verify.d.ts +53 -0
- package/dist/esm/lib/dcr-verify.js +53 -0
- package/dist/esm/lib/dcr-verify.js.map +1 -0
- package/dist/esm/lib/fetch-with-timeout.d.ts +14 -0
- package/dist/esm/lib/fetch-with-timeout.js +30 -0
- package/dist/esm/lib/fetch-with-timeout.js.map +1 -0
- package/dist/esm/lib/token-verifier.d.ts +44 -0
- package/dist/esm/lib/token-verifier.js +53 -0
- package/dist/esm/lib/token-verifier.js.map +1 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/providers/dcr.d.ts +110 -0
- package/dist/esm/providers/dcr.js +235 -0
- package/dist/esm/providers/dcr.js.map +1 -0
- package/dist/esm/providers/device-code.d.ts +179 -0
- package/dist/esm/providers/device-code.js +417 -0
- package/dist/esm/providers/device-code.js.map +1 -0
- package/dist/esm/providers/loopback-oauth.d.ts +125 -0
- package/dist/esm/providers/loopback-oauth.js +643 -0
- package/dist/esm/providers/loopback-oauth.js.map +1 -0
- package/dist/esm/schemas/index.d.ts +20 -0
- package/dist/esm/schemas/index.js +18 -0
- package/dist/esm/schemas/index.js.map +1 -0
- package/dist/esm/setup/config.d.ts +113 -0
- package/dist/esm/setup/config.js +268 -0
- package/dist/esm/setup/config.js.map +1 -0
- package/dist/esm/types.d.ts +188 -0
- package/dist/esm/types.js +8 -0
- package/dist/esm/types.js.map +1 -0
- package/package.json +87 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Kevin Malakoff
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# @mcp-z/oauth-microsoft
|
|
2
|
+
|
|
3
|
+
Docs: https://mcp-z.github.io/oauth-microsoft
|
|
4
|
+
OAuth client for Microsoft Graph with multi-account support and PKCE.
|
|
5
|
+
|
|
6
|
+
## Common uses
|
|
7
|
+
|
|
8
|
+
- Outlook OAuth in MCP servers
|
|
9
|
+
- CLI and desktop OAuth flows
|
|
10
|
+
- Device code auth for headless environments
|
|
11
|
+
- DCR (self-hosted) for shared HTTP servers
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install @mcp-z/oauth-microsoft keyv
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Create a Microsoft app
|
|
20
|
+
|
|
21
|
+
1. Go to [Azure Portal](https://portal.azure.com/).
|
|
22
|
+
2. Navigate to Azure Active Directory > App registrations.
|
|
23
|
+
3. Click New registration.
|
|
24
|
+
4. Choose a name and select a supported account type.
|
|
25
|
+
5. Copy the Application (client) ID and Directory (tenant) ID.
|
|
26
|
+
|
|
27
|
+
## OAuth modes
|
|
28
|
+
|
|
29
|
+
### Loopback OAuth (interactive)
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
import { LoopbackOAuthProvider } from '@mcp-z/oauth-microsoft';
|
|
33
|
+
import Keyv from 'keyv';
|
|
34
|
+
import { KeyvFile } from 'keyv-file';
|
|
35
|
+
|
|
36
|
+
const provider = new LoopbackOAuthProvider({
|
|
37
|
+
service: 'outlook',
|
|
38
|
+
clientId: process.env.MS_CLIENT_ID!,
|
|
39
|
+
tenantId: process.env.MS_TENANT_ID || 'common',
|
|
40
|
+
scope: 'https://graph.microsoft.com/Mail.Read offline_access',
|
|
41
|
+
tokenStore: new Keyv({ store: new KeyvFile({ filename: '.tokens/microsoft.json' }) })
|
|
42
|
+
});
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Device code (headless)
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
import { DeviceCodeProvider } from '@mcp-z/oauth-microsoft';
|
|
49
|
+
import Keyv from 'keyv';
|
|
50
|
+
import { KeyvFile } from 'keyv-file';
|
|
51
|
+
|
|
52
|
+
const provider = new DeviceCodeProvider({
|
|
53
|
+
service: 'outlook',
|
|
54
|
+
clientId: process.env.MS_CLIENT_ID!,
|
|
55
|
+
tenantId: process.env.MS_TENANT_ID || 'common',
|
|
56
|
+
scope: 'https://graph.microsoft.com/Mail.Read offline_access',
|
|
57
|
+
tokenStore: new Keyv({ store: new KeyvFile({ filename: '.tokens/microsoft.json' }) })
|
|
58
|
+
});
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### DCR (self-hosted)
|
|
62
|
+
|
|
63
|
+
Use `DcrOAuthProvider` for bearer validation and `createDcrRouter` to host the DCR endpoints.
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
import { DcrOAuthProvider, createDcrRouter } from '@mcp-z/oauth-microsoft';
|
|
67
|
+
|
|
68
|
+
const provider = new DcrOAuthProvider({
|
|
69
|
+
clientId: process.env.MS_CLIENT_ID!,
|
|
70
|
+
clientSecret: process.env.MS_CLIENT_SECRET!,
|
|
71
|
+
scope: 'openid email profile',
|
|
72
|
+
verifyEndpoint: 'https://your-host.com/oauth/verify'
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
const router = createDcrRouter({
|
|
76
|
+
store,
|
|
77
|
+
issuerUrl: 'https://your-host.com',
|
|
78
|
+
baseUrl: 'https://your-host.com',
|
|
79
|
+
scopesSupported: ['openid', 'email', 'profile'],
|
|
80
|
+
clientConfig: {
|
|
81
|
+
clientId: process.env.MS_CLIENT_ID!,
|
|
82
|
+
clientSecret: process.env.MS_CLIENT_SECRET!
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Config helpers
|
|
88
|
+
|
|
89
|
+
Use `parseConfig()` and `parseDcrConfig()` to load CLI + env settings for servers.
|
|
90
|
+
|
|
91
|
+
## Schemas and handler types
|
|
92
|
+
|
|
93
|
+
- `schemas` - Shared Zod schemas used by tools
|
|
94
|
+
- `EnrichedExtra` - Handler extra type with auth context
|
|
95
|
+
|
|
96
|
+
## Requirements
|
|
97
|
+
|
|
98
|
+
- Node.js >= 22
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @mcp-z/oauth-microsoft - Shared Microsoft OAuth implementation
|
|
3
|
+
*
|
|
4
|
+
* Provides OAuth authentication:
|
|
5
|
+
* - Loopback OAuth (RFC 8252) - Server-managed, file-based tokens
|
|
6
|
+
* - Device Code flow (RFC 8628) - For headless/limited-input scenarios
|
|
7
|
+
*/
|
|
8
|
+
export { createDcrRouter, type DcrRouterConfig } from './lib/dcr-router.js';
|
|
9
|
+
export { type VerificationResult, verifyBearerToken } from './lib/dcr-verify.js';
|
|
10
|
+
export { type AuthInfo, DcrTokenVerifier } from './lib/token-verifier.js';
|
|
11
|
+
export { DcrOAuthProvider, type DcrOAuthProviderConfig } from './providers/dcr.js';
|
|
12
|
+
export { type DeviceCodeConfig, DeviceCodeProvider } from './providers/device-code.js';
|
|
13
|
+
export { LoopbackOAuthProvider } from './providers/loopback-oauth.js';
|
|
14
|
+
export * as schemas from './schemas/index.js';
|
|
15
|
+
export { createConfig, parseConfig, parseDcrConfig } from './setup/config.js';
|
|
16
|
+
export * from './types.js';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @mcp-z/oauth-microsoft - Shared Microsoft OAuth implementation
|
|
3
|
+
*
|
|
4
|
+
* Provides OAuth authentication:
|
|
5
|
+
* - Loopback OAuth (RFC 8252) - Server-managed, file-based tokens
|
|
6
|
+
* - Device Code flow (RFC 8628) - For headless/limited-input scenarios
|
|
7
|
+
*/
|
|
8
|
+
export { createDcrRouter, type DcrRouterConfig } from './lib/dcr-router.js';
|
|
9
|
+
export { type VerificationResult, verifyBearerToken } from './lib/dcr-verify.js';
|
|
10
|
+
export { type AuthInfo, DcrTokenVerifier } from './lib/token-verifier.js';
|
|
11
|
+
export { DcrOAuthProvider, type DcrOAuthProviderConfig } from './providers/dcr.js';
|
|
12
|
+
export { type DeviceCodeConfig, DeviceCodeProvider } from './providers/device-code.js';
|
|
13
|
+
export { LoopbackOAuthProvider } from './providers/loopback-oauth.js';
|
|
14
|
+
export * as schemas from './schemas/index.js';
|
|
15
|
+
export { createConfig, parseConfig, parseDcrConfig } from './setup/config.js';
|
|
16
|
+
export * from './types.js';
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @mcp-z/oauth-microsoft - Shared Microsoft OAuth implementation
|
|
3
|
+
*
|
|
4
|
+
* Provides OAuth authentication:
|
|
5
|
+
* - Loopback OAuth (RFC 8252) - Server-managed, file-based tokens
|
|
6
|
+
* - Device Code flow (RFC 8628) - For headless/limited-input scenarios
|
|
7
|
+
*/ "use strict";
|
|
8
|
+
Object.defineProperty(exports, "__esModule", {
|
|
9
|
+
value: true
|
|
10
|
+
});
|
|
11
|
+
function _export(target, all) {
|
|
12
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
_export(exports, {
|
|
18
|
+
get DcrOAuthProvider () {
|
|
19
|
+
return _dcrts.DcrOAuthProvider;
|
|
20
|
+
},
|
|
21
|
+
get DcrTokenVerifier () {
|
|
22
|
+
return _tokenverifierts.DcrTokenVerifier;
|
|
23
|
+
},
|
|
24
|
+
get DeviceCodeProvider () {
|
|
25
|
+
return _devicecodets.DeviceCodeProvider;
|
|
26
|
+
},
|
|
27
|
+
get LoopbackOAuthProvider () {
|
|
28
|
+
return _loopbackoauthts.LoopbackOAuthProvider;
|
|
29
|
+
},
|
|
30
|
+
get createConfig () {
|
|
31
|
+
return _configts.createConfig;
|
|
32
|
+
},
|
|
33
|
+
get createDcrRouter () {
|
|
34
|
+
return _dcrrouterts.createDcrRouter;
|
|
35
|
+
},
|
|
36
|
+
get parseConfig () {
|
|
37
|
+
return _configts.parseConfig;
|
|
38
|
+
},
|
|
39
|
+
get parseDcrConfig () {
|
|
40
|
+
return _configts.parseDcrConfig;
|
|
41
|
+
},
|
|
42
|
+
get schemas () {
|
|
43
|
+
return _indexts;
|
|
44
|
+
},
|
|
45
|
+
get verifyBearerToken () {
|
|
46
|
+
return _dcrverifyts.verifyBearerToken;
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
var _dcrrouterts = require("./lib/dcr-router.js");
|
|
50
|
+
var _dcrverifyts = require("./lib/dcr-verify.js");
|
|
51
|
+
var _tokenverifierts = require("./lib/token-verifier.js");
|
|
52
|
+
var _dcrts = require("./providers/dcr.js");
|
|
53
|
+
var _devicecodets = require("./providers/device-code.js");
|
|
54
|
+
var _loopbackoauthts = require("./providers/loopback-oauth.js");
|
|
55
|
+
var _indexts = /*#__PURE__*/ _interop_require_wildcard(require("./schemas/index.js"));
|
|
56
|
+
var _configts = require("./setup/config.js");
|
|
57
|
+
_export_star(require("./types.js"), exports);
|
|
58
|
+
function _export_star(from, to) {
|
|
59
|
+
Object.keys(from).forEach(function(k) {
|
|
60
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
|
|
61
|
+
Object.defineProperty(to, k, {
|
|
62
|
+
enumerable: true,
|
|
63
|
+
get: function() {
|
|
64
|
+
return from[k];
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
return from;
|
|
70
|
+
}
|
|
71
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
72
|
+
if (typeof WeakMap !== "function") return null;
|
|
73
|
+
var cacheBabelInterop = new WeakMap();
|
|
74
|
+
var cacheNodeInterop = new WeakMap();
|
|
75
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
76
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
77
|
+
})(nodeInterop);
|
|
78
|
+
}
|
|
79
|
+
function _interop_require_wildcard(obj, nodeInterop) {
|
|
80
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
81
|
+
return obj;
|
|
82
|
+
}
|
|
83
|
+
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
84
|
+
return {
|
|
85
|
+
default: obj
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
89
|
+
if (cache && cache.has(obj)) {
|
|
90
|
+
return cache.get(obj);
|
|
91
|
+
}
|
|
92
|
+
var newObj = {
|
|
93
|
+
__proto__: null
|
|
94
|
+
};
|
|
95
|
+
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
96
|
+
for(var key in obj){
|
|
97
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
98
|
+
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
99
|
+
if (desc && (desc.get || desc.set)) {
|
|
100
|
+
Object.defineProperty(newObj, key, desc);
|
|
101
|
+
} else {
|
|
102
|
+
newObj[key] = obj[key];
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
newObj.default = obj;
|
|
107
|
+
if (cache) {
|
|
108
|
+
cache.set(obj, newObj);
|
|
109
|
+
}
|
|
110
|
+
return newObj;
|
|
111
|
+
}
|
|
112
|
+
/* CJS INTEROP */ if (exports.__esModule && exports.default) { try { Object.defineProperty(exports.default, '__esModule', { value: true }); for (var key in exports) { exports.default[key] = exports[key]; } } catch (_) {}; module.exports = exports.default; }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/Projects/ai/mcp-z/oauth/oauth-microsoft/src/index.ts"],"sourcesContent":["/**\n * @mcp-z/oauth-microsoft - Shared Microsoft OAuth implementation\n *\n * Provides OAuth authentication:\n * - Loopback OAuth (RFC 8252) - Server-managed, file-based tokens\n * - Device Code flow (RFC 8628) - For headless/limited-input scenarios\n */\n\nexport { createDcrRouter, type DcrRouterConfig } from './lib/dcr-router.ts';\nexport { type VerificationResult, verifyBearerToken } from './lib/dcr-verify.ts';\nexport { type AuthInfo, DcrTokenVerifier } from './lib/token-verifier.ts';\nexport { DcrOAuthProvider, type DcrOAuthProviderConfig } from './providers/dcr.ts';\nexport { type DeviceCodeConfig, DeviceCodeProvider } from './providers/device-code.ts';\nexport { LoopbackOAuthProvider } from './providers/loopback-oauth.ts';\nexport * as schemas from './schemas/index.ts';\nexport { createConfig, parseConfig, parseDcrConfig } from './setup/config.ts';\nexport * from './types.ts';\n"],"names":["DcrOAuthProvider","DcrTokenVerifier","DeviceCodeProvider","LoopbackOAuthProvider","createConfig","createDcrRouter","parseConfig","parseDcrConfig","schemas","verifyBearerToken"],"mappings":"AAAA;;;;;;CAMC;;;;;;;;;;;QAKQA;eAAAA,uBAAgB;;QADDC;eAAAA,iCAAgB;;QAERC;eAAAA,gCAAkB;;QACzCC;eAAAA,sCAAqB;;QAErBC;eAAAA,sBAAY;;QAPZC;eAAAA,4BAAe;;QAODC;eAAAA,qBAAW;;QAAEC;eAAAA,wBAAc;;QADtCC;;;QALsBC;eAAAA,8BAAiB;;;2BADG;2BACK;+BACX;qBACc;4BACJ;+BACpB;+DACb;wBACiC;qBAC5C"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DCR Router - OAuth 2.0 Authorization Server
|
|
3
|
+
*
|
|
4
|
+
* Implements OAuth 2.0 Dynamic Client Registration Protocol (RFC 7591)
|
|
5
|
+
* and OAuth 2.0 Authorization Server endpoints (RFC 6749, RFC 8414, RFC 9728).
|
|
6
|
+
*
|
|
7
|
+
* Endpoints:
|
|
8
|
+
* - GET /.well-known/oauth-authorization-server (RFC 8414 metadata)
|
|
9
|
+
* - GET /.well-known/oauth-protected-resource (RFC 9728 metadata - root)
|
|
10
|
+
* - GET /.well-known/oauth-protected-resource/mcp (RFC 9728 metadata - sub-path)
|
|
11
|
+
* - POST /oauth/register (RFC 7591 client registration)
|
|
12
|
+
* - GET /oauth/authorize (RFC 6749 authorization endpoint)
|
|
13
|
+
* - POST /oauth/token (RFC 6749 token endpoint)
|
|
14
|
+
* - POST /oauth/revoke (RFC 7009 token revocation)
|
|
15
|
+
* - GET /oauth/verify (token verification for Resource Server)
|
|
16
|
+
*/
|
|
17
|
+
import express from 'express';
|
|
18
|
+
import type { Keyv } from 'keyv';
|
|
19
|
+
import type { OAuthClientConfig } from '../types.js';
|
|
20
|
+
/**
|
|
21
|
+
* Configuration for DCR Router (self-hosted mode only)
|
|
22
|
+
*/
|
|
23
|
+
export interface DcrRouterConfig {
|
|
24
|
+
/** Single Keyv store for all DCR data */
|
|
25
|
+
store: Keyv;
|
|
26
|
+
/** Authorization Server issuer URL */
|
|
27
|
+
issuerUrl: string;
|
|
28
|
+
/** Base URL for OAuth endpoints */
|
|
29
|
+
baseUrl: string;
|
|
30
|
+
/** Supported OAuth scopes */
|
|
31
|
+
scopesSupported: string[];
|
|
32
|
+
/** OAuth client configuration for upstream provider */
|
|
33
|
+
clientConfig: OAuthClientConfig;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Create DCR Router with OAuth 2.0 endpoints (self-hosted mode)
|
|
37
|
+
*
|
|
38
|
+
* For external mode (Auth0/Stitch), don't call this function - no router needed.
|
|
39
|
+
* The server code should check DcrConfig.mode and only call this for 'self-hosted'.
|
|
40
|
+
*
|
|
41
|
+
* @param config - Router configuration
|
|
42
|
+
* @returns Express router with OAuth endpoints
|
|
43
|
+
*/
|
|
44
|
+
export declare function createDcrRouter(config: DcrRouterConfig): express.Router;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DCR Router - OAuth 2.0 Authorization Server
|
|
3
|
+
*
|
|
4
|
+
* Implements OAuth 2.0 Dynamic Client Registration Protocol (RFC 7591)
|
|
5
|
+
* and OAuth 2.0 Authorization Server endpoints (RFC 6749, RFC 8414, RFC 9728).
|
|
6
|
+
*
|
|
7
|
+
* Endpoints:
|
|
8
|
+
* - GET /.well-known/oauth-authorization-server (RFC 8414 metadata)
|
|
9
|
+
* - GET /.well-known/oauth-protected-resource (RFC 9728 metadata - root)
|
|
10
|
+
* - GET /.well-known/oauth-protected-resource/mcp (RFC 9728 metadata - sub-path)
|
|
11
|
+
* - POST /oauth/register (RFC 7591 client registration)
|
|
12
|
+
* - GET /oauth/authorize (RFC 6749 authorization endpoint)
|
|
13
|
+
* - POST /oauth/token (RFC 6749 token endpoint)
|
|
14
|
+
* - POST /oauth/revoke (RFC 7009 token revocation)
|
|
15
|
+
* - GET /oauth/verify (token verification for Resource Server)
|
|
16
|
+
*/
|
|
17
|
+
import express from 'express';
|
|
18
|
+
import type { Keyv } from 'keyv';
|
|
19
|
+
import type { OAuthClientConfig } from '../types.js';
|
|
20
|
+
/**
|
|
21
|
+
* Configuration for DCR Router (self-hosted mode only)
|
|
22
|
+
*/
|
|
23
|
+
export interface DcrRouterConfig {
|
|
24
|
+
/** Single Keyv store for all DCR data */
|
|
25
|
+
store: Keyv;
|
|
26
|
+
/** Authorization Server issuer URL */
|
|
27
|
+
issuerUrl: string;
|
|
28
|
+
/** Base URL for OAuth endpoints */
|
|
29
|
+
baseUrl: string;
|
|
30
|
+
/** Supported OAuth scopes */
|
|
31
|
+
scopesSupported: string[];
|
|
32
|
+
/** OAuth client configuration for upstream provider */
|
|
33
|
+
clientConfig: OAuthClientConfig;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Create DCR Router with OAuth 2.0 endpoints (self-hosted mode)
|
|
37
|
+
*
|
|
38
|
+
* For external mode (Auth0/Stitch), don't call this function - no router needed.
|
|
39
|
+
* The server code should check DcrConfig.mode and only call this for 'self-hosted'.
|
|
40
|
+
*
|
|
41
|
+
* @param config - Router configuration
|
|
42
|
+
* @returns Express router with OAuth endpoints
|
|
43
|
+
*/
|
|
44
|
+
export declare function createDcrRouter(config: DcrRouterConfig): express.Router;
|