@mcp-z/oauth 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.
Files changed (131) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +71 -0
  3. package/dist/cjs/account-utils.d.cts +107 -0
  4. package/dist/cjs/account-utils.d.ts +107 -0
  5. package/dist/cjs/account-utils.js +481 -0
  6. package/dist/cjs/account-utils.js.map +1 -0
  7. package/dist/cjs/index.d.cts +19 -0
  8. package/dist/cjs/index.d.ts +19 -0
  9. package/dist/cjs/index.js +149 -0
  10. package/dist/cjs/index.js.map +1 -0
  11. package/dist/cjs/jwt-auth.d.cts +53 -0
  12. package/dist/cjs/jwt-auth.d.ts +53 -0
  13. package/dist/cjs/jwt-auth.js +417 -0
  14. package/dist/cjs/jwt-auth.js.map +1 -0
  15. package/dist/cjs/key-utils.d.cts +131 -0
  16. package/dist/cjs/key-utils.d.ts +131 -0
  17. package/dist/cjs/key-utils.js +421 -0
  18. package/dist/cjs/key-utils.js.map +1 -0
  19. package/dist/cjs/lib/account-server/index.d.cts +45 -0
  20. package/dist/cjs/lib/account-server/index.d.ts +45 -0
  21. package/dist/cjs/lib/account-server/index.js +67 -0
  22. package/dist/cjs/lib/account-server/index.js.map +1 -0
  23. package/dist/cjs/lib/account-server/loopback.d.cts +22 -0
  24. package/dist/cjs/lib/account-server/loopback.d.ts +22 -0
  25. package/dist/cjs/lib/account-server/loopback.js +778 -0
  26. package/dist/cjs/lib/account-server/loopback.js.map +1 -0
  27. package/dist/cjs/lib/account-server/me.d.cts +23 -0
  28. package/dist/cjs/lib/account-server/me.d.ts +23 -0
  29. package/dist/cjs/lib/account-server/me.js +412 -0
  30. package/dist/cjs/lib/account-server/me.js.map +1 -0
  31. package/dist/cjs/lib/account-server/shared-utils.d.cts +6 -0
  32. package/dist/cjs/lib/account-server/shared-utils.d.ts +6 -0
  33. package/dist/cjs/lib/account-server/shared-utils.js +235 -0
  34. package/dist/cjs/lib/account-server/shared-utils.js.map +1 -0
  35. package/dist/cjs/lib/account-server/stateless.d.cts +20 -0
  36. package/dist/cjs/lib/account-server/stateless.d.ts +20 -0
  37. package/dist/cjs/lib/account-server/stateless.js +32 -0
  38. package/dist/cjs/lib/account-server/stateless.js.map +1 -0
  39. package/dist/cjs/lib/account-server/types.d.cts +32 -0
  40. package/dist/cjs/lib/account-server/types.d.ts +32 -0
  41. package/dist/cjs/lib/account-server/types.js +7 -0
  42. package/dist/cjs/lib/account-server/types.js.map +1 -0
  43. package/dist/cjs/lib/dcr-types.d.cts +126 -0
  44. package/dist/cjs/lib/dcr-types.d.ts +126 -0
  45. package/dist/cjs/lib/dcr-types.js +12 -0
  46. package/dist/cjs/lib/dcr-types.js.map +1 -0
  47. package/dist/cjs/lib/rfc-metadata-types.d.cts +46 -0
  48. package/dist/cjs/lib/rfc-metadata-types.d.ts +46 -0
  49. package/dist/cjs/lib/rfc-metadata-types.js +8 -0
  50. package/dist/cjs/lib/rfc-metadata-types.js.map +1 -0
  51. package/dist/cjs/package.json +1 -0
  52. package/dist/cjs/pkce.d.cts +36 -0
  53. package/dist/cjs/pkce.d.ts +36 -0
  54. package/dist/cjs/pkce.js +25 -0
  55. package/dist/cjs/pkce.js.map +1 -0
  56. package/dist/cjs/sanitizer.d.cts +37 -0
  57. package/dist/cjs/sanitizer.d.ts +37 -0
  58. package/dist/cjs/sanitizer.js +407 -0
  59. package/dist/cjs/sanitizer.js.map +1 -0
  60. package/dist/cjs/schemas/index.d.cts +36 -0
  61. package/dist/cjs/schemas/index.d.ts +36 -0
  62. package/dist/cjs/schemas/index.js +28 -0
  63. package/dist/cjs/schemas/index.js.map +1 -0
  64. package/dist/cjs/session-auth.d.cts +79 -0
  65. package/dist/cjs/session-auth.d.ts +79 -0
  66. package/dist/cjs/session-auth.js +354 -0
  67. package/dist/cjs/session-auth.js.map +1 -0
  68. package/dist/cjs/templates.d.cts +18 -0
  69. package/dist/cjs/templates.d.ts +18 -0
  70. package/dist/cjs/templates.js +38 -0
  71. package/dist/cjs/templates.js.map +1 -0
  72. package/dist/cjs/types.d.cts +343 -0
  73. package/dist/cjs/types.d.ts +343 -0
  74. package/dist/cjs/types.js +210 -0
  75. package/dist/cjs/types.js.map +1 -0
  76. package/dist/esm/account-utils.d.ts +107 -0
  77. package/dist/esm/account-utils.js +179 -0
  78. package/dist/esm/account-utils.js.map +1 -0
  79. package/dist/esm/index.d.ts +19 -0
  80. package/dist/esm/index.js +23 -0
  81. package/dist/esm/index.js.map +1 -0
  82. package/dist/esm/jwt-auth.d.ts +53 -0
  83. package/dist/esm/jwt-auth.js +164 -0
  84. package/dist/esm/jwt-auth.js.map +1 -0
  85. package/dist/esm/key-utils.d.ts +131 -0
  86. package/dist/esm/key-utils.js +143 -0
  87. package/dist/esm/key-utils.js.map +1 -0
  88. package/dist/esm/lib/account-server/index.d.ts +45 -0
  89. package/dist/esm/lib/account-server/index.js +41 -0
  90. package/dist/esm/lib/account-server/index.js.map +1 -0
  91. package/dist/esm/lib/account-server/loopback.d.ts +22 -0
  92. package/dist/esm/lib/account-server/loopback.js +372 -0
  93. package/dist/esm/lib/account-server/loopback.js.map +1 -0
  94. package/dist/esm/lib/account-server/me.d.ts +23 -0
  95. package/dist/esm/lib/account-server/me.js +170 -0
  96. package/dist/esm/lib/account-server/me.js.map +1 -0
  97. package/dist/esm/lib/account-server/shared-utils.d.ts +6 -0
  98. package/dist/esm/lib/account-server/shared-utils.js +24 -0
  99. package/dist/esm/lib/account-server/shared-utils.js.map +1 -0
  100. package/dist/esm/lib/account-server/stateless.d.ts +20 -0
  101. package/dist/esm/lib/account-server/stateless.js +25 -0
  102. package/dist/esm/lib/account-server/stateless.js.map +1 -0
  103. package/dist/esm/lib/account-server/types.d.ts +32 -0
  104. package/dist/esm/lib/account-server/types.js +6 -0
  105. package/dist/esm/lib/account-server/types.js.map +1 -0
  106. package/dist/esm/lib/dcr-types.d.ts +126 -0
  107. package/dist/esm/lib/dcr-types.js +13 -0
  108. package/dist/esm/lib/dcr-types.js.map +1 -0
  109. package/dist/esm/lib/rfc-metadata-types.d.ts +46 -0
  110. package/dist/esm/lib/rfc-metadata-types.js +7 -0
  111. package/dist/esm/lib/rfc-metadata-types.js.map +1 -0
  112. package/dist/esm/package.json +1 -0
  113. package/dist/esm/pkce.d.ts +36 -0
  114. package/dist/esm/pkce.js +33 -0
  115. package/dist/esm/pkce.js.map +1 -0
  116. package/dist/esm/sanitizer.d.ts +37 -0
  117. package/dist/esm/sanitizer.js +256 -0
  118. package/dist/esm/sanitizer.js.map +1 -0
  119. package/dist/esm/schemas/index.d.ts +36 -0
  120. package/dist/esm/schemas/index.js +19 -0
  121. package/dist/esm/schemas/index.js.map +1 -0
  122. package/dist/esm/session-auth.d.ts +79 -0
  123. package/dist/esm/session-auth.js +141 -0
  124. package/dist/esm/session-auth.js.map +1 -0
  125. package/dist/esm/templates.d.ts +18 -0
  126. package/dist/esm/templates.js +132 -0
  127. package/dist/esm/templates.js.map +1 -0
  128. package/dist/esm/types.d.ts +343 -0
  129. package/dist/esm/types.js +34 -0
  130. package/dist/esm/types.js.map +1 -0
  131. package/package.json +82 -0
@@ -0,0 +1,235 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", {
3
+ value: true
4
+ });
5
+ Object.defineProperty(exports, "findAccountByEmailOrAlias", {
6
+ enumerable: true,
7
+ get: function() {
8
+ return findAccountByEmailOrAlias;
9
+ }
10
+ });
11
+ var _accountutilsts = require("../../account-utils.js");
12
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
13
+ try {
14
+ var info = gen[key](arg);
15
+ var value = info.value;
16
+ } catch (error) {
17
+ reject(error);
18
+ return;
19
+ }
20
+ if (info.done) {
21
+ resolve(value);
22
+ } else {
23
+ Promise.resolve(value).then(_next, _throw);
24
+ }
25
+ }
26
+ function _async_to_generator(fn) {
27
+ return function() {
28
+ var self = this, args = arguments;
29
+ return new Promise(function(resolve, reject) {
30
+ var gen = fn.apply(self, args);
31
+ function _next(value) {
32
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
33
+ }
34
+ function _throw(err) {
35
+ asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
36
+ }
37
+ _next(undefined);
38
+ });
39
+ };
40
+ }
41
+ function _ts_generator(thisArg, body) {
42
+ var f, y, t, _ = {
43
+ label: 0,
44
+ sent: function() {
45
+ if (t[0] & 1) throw t[1];
46
+ return t[1];
47
+ },
48
+ trys: [],
49
+ ops: []
50
+ }, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
51
+ return d(g, "next", {
52
+ value: verb(0)
53
+ }), d(g, "throw", {
54
+ value: verb(1)
55
+ }), d(g, "return", {
56
+ value: verb(2)
57
+ }), typeof Symbol === "function" && d(g, Symbol.iterator, {
58
+ value: function() {
59
+ return this;
60
+ }
61
+ }), g;
62
+ function verb(n) {
63
+ return function(v) {
64
+ return step([
65
+ n,
66
+ v
67
+ ]);
68
+ };
69
+ }
70
+ function step(op) {
71
+ if (f) throw new TypeError("Generator is already executing.");
72
+ while(g && (g = 0, op[0] && (_ = 0)), _)try {
73
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
74
+ if (y = 0, t) op = [
75
+ op[0] & 2,
76
+ t.value
77
+ ];
78
+ switch(op[0]){
79
+ case 0:
80
+ case 1:
81
+ t = op;
82
+ break;
83
+ case 4:
84
+ _.label++;
85
+ return {
86
+ value: op[1],
87
+ done: false
88
+ };
89
+ case 5:
90
+ _.label++;
91
+ y = op[1];
92
+ op = [
93
+ 0
94
+ ];
95
+ continue;
96
+ case 7:
97
+ op = _.ops.pop();
98
+ _.trys.pop();
99
+ continue;
100
+ default:
101
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
102
+ _ = 0;
103
+ continue;
104
+ }
105
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
106
+ _.label = op[1];
107
+ break;
108
+ }
109
+ if (op[0] === 6 && _.label < t[1]) {
110
+ _.label = t[1];
111
+ t = op;
112
+ break;
113
+ }
114
+ if (t && _.label < t[2]) {
115
+ _.label = t[2];
116
+ _.ops.push(op);
117
+ break;
118
+ }
119
+ if (t[2]) _.ops.pop();
120
+ _.trys.pop();
121
+ continue;
122
+ }
123
+ op = body.call(thisArg, _);
124
+ } catch (e) {
125
+ op = [
126
+ 6,
127
+ e
128
+ ];
129
+ y = 0;
130
+ } finally{
131
+ f = t = 0;
132
+ }
133
+ if (op[0] & 5) throw op[1];
134
+ return {
135
+ value: op[0] ? op[1] : void 0,
136
+ done: true
137
+ };
138
+ }
139
+ }
140
+ function findAccountByEmailOrAlias(store, service, emailOrAlias) {
141
+ return _async_to_generator(function() {
142
+ var linkedAccountIds, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, accountId, info, err;
143
+ return _ts_generator(this, function(_state) {
144
+ switch(_state.label){
145
+ case 0:
146
+ return [
147
+ 4,
148
+ (0, _accountutilsts.getLinkedAccounts)(store, {
149
+ service: service
150
+ })
151
+ ];
152
+ case 1:
153
+ linkedAccountIds = _state.sent();
154
+ // Try exact email match first
155
+ if (linkedAccountIds.includes(emailOrAlias)) {
156
+ return [
157
+ 2,
158
+ emailOrAlias
159
+ ];
160
+ }
161
+ _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
162
+ _state.label = 2;
163
+ case 2:
164
+ _state.trys.push([
165
+ 2,
166
+ 7,
167
+ 8,
168
+ 9
169
+ ]);
170
+ _iterator = linkedAccountIds[Symbol.iterator]();
171
+ _state.label = 3;
172
+ case 3:
173
+ if (!!(_iteratorNormalCompletion = (_step = _iterator.next()).done)) return [
174
+ 3,
175
+ 6
176
+ ];
177
+ accountId = _step.value;
178
+ return [
179
+ 4,
180
+ (0, _accountutilsts.getAccountInfo)(store, {
181
+ accountId: accountId,
182
+ service: service
183
+ })
184
+ ];
185
+ case 4:
186
+ info = _state.sent();
187
+ if ((info === null || info === void 0 ? void 0 : info.alias) === emailOrAlias) {
188
+ return [
189
+ 2,
190
+ accountId
191
+ ];
192
+ }
193
+ _state.label = 5;
194
+ case 5:
195
+ _iteratorNormalCompletion = true;
196
+ return [
197
+ 3,
198
+ 3
199
+ ];
200
+ case 6:
201
+ return [
202
+ 3,
203
+ 9
204
+ ];
205
+ case 7:
206
+ err = _state.sent();
207
+ _didIteratorError = true;
208
+ _iteratorError = err;
209
+ return [
210
+ 3,
211
+ 9
212
+ ];
213
+ case 8:
214
+ try {
215
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
216
+ _iterator.return();
217
+ }
218
+ } finally{
219
+ if (_didIteratorError) {
220
+ throw _iteratorError;
221
+ }
222
+ }
223
+ return [
224
+ 7
225
+ ];
226
+ case 9:
227
+ return [
228
+ 2,
229
+ null
230
+ ];
231
+ }
232
+ });
233
+ })();
234
+ }
235
+ /* 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/src/lib/account-server/shared-utils.ts"],"sourcesContent":["import type { Keyv } from 'keyv';\nimport { getAccountInfo, getLinkedAccounts } from '../../account-utils.ts';\n\n/**\n * Find account ID by email or alias lookup.\n * Returns accountId if found, otherwise null.\n */\nexport async function findAccountByEmailOrAlias(store: Keyv, service: string, emailOrAlias: string): Promise<string | null> {\n const linkedAccountIds = await getLinkedAccounts(store, { service });\n\n // Try exact email match first\n if (linkedAccountIds.includes(emailOrAlias)) {\n return emailOrAlias;\n }\n\n // Search by alias\n for (const accountId of linkedAccountIds) {\n const info = await getAccountInfo(store, { accountId, service });\n if (info?.alias === emailOrAlias) {\n return accountId;\n }\n }\n\n return null;\n}\n"],"names":["findAccountByEmailOrAlias","store","service","emailOrAlias","linkedAccountIds","accountId","info","getLinkedAccounts","includes","getAccountInfo","alias"],"mappings":";;;;+BAOsBA;;;eAAAA;;;8BAN4B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAM3C,SAAeA,0BAA0BC,KAAW,EAAEC,OAAe,EAAEC,YAAoB;;YAC1FC,kBAQD,2BAAA,mBAAA,gBAAA,WAAA,OAAMC,WACHC;;;;oBATiB;;wBAAMC,IAAAA,iCAAiB,EAACN,OAAO;4BAAEC,SAAAA;wBAAQ;;;oBAA5DE,mBAAmB;oBAEzB,8BAA8B;oBAC9B,IAAIA,iBAAiBI,QAAQ,CAACL,eAAe;wBAC3C;;4BAAOA;;oBACT;oBAGK,kCAAA,2BAAA;;;;;;;;;oBAAA,YAAmBC;;;2BAAnB,6BAAA,QAAA;;;;oBAAMC,YAAN;oBACU;;wBAAMI,IAAAA,8BAAc,EAACR,OAAO;4BAAEI,WAAAA;4BAAWH,SAAAA;wBAAQ;;;oBAAxDI,OAAO;oBACb,IAAIA,CAAAA,iBAAAA,2BAAAA,KAAMI,KAAK,MAAKP,cAAc;wBAChC;;4BAAOE;;oBACT;;;oBAJG;;;;;;;;;;;;oBAAA;oBAAA;;;;;;;6BAAA,6BAAA;4BAAA;;;4BAAA;kCAAA;;;;;;;oBAOL;;wBAAO;;;;IACT"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Stateless tool set for MCP OAuth mode (DCR).
3
+ *
4
+ * Use this when authentication is managed by the MCP client.
5
+ * Tokens are provided per-request and not stored by the server.
6
+ *
7
+ * Tools:
8
+ * - {service}-account-me: Show current user identity from bearer token
9
+ */
10
+ import type { McpPrompt, McpTool } from '../../types.js';
11
+ import type { AccountStatelessConfig } from './types.js';
12
+ /**
13
+ * Create stateless mode tools.
14
+ * MCP client manages authentication. Server provides user identity from bearer token.
15
+ * Returns 1 tool: account-me.
16
+ */
17
+ export declare function createStateless(config: AccountStatelessConfig): {
18
+ tools: McpTool[];
19
+ prompts: McpPrompt[];
20
+ };
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Stateless tool set for MCP OAuth mode (DCR).
3
+ *
4
+ * Use this when authentication is managed by the MCP client.
5
+ * Tokens are provided per-request and not stored by the server.
6
+ *
7
+ * Tools:
8
+ * - {service}-account-me: Show current user identity from bearer token
9
+ */
10
+ import type { McpPrompt, McpTool } from '../../types.js';
11
+ import type { AccountStatelessConfig } from './types.js';
12
+ /**
13
+ * Create stateless mode tools.
14
+ * MCP client manages authentication. Server provides user identity from bearer token.
15
+ * Returns 1 tool: account-me.
16
+ */
17
+ export declare function createStateless(config: AccountStatelessConfig): {
18
+ tools: McpTool[];
19
+ prompts: McpPrompt[];
20
+ };
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Stateless tool set for MCP OAuth mode (DCR).
3
+ *
4
+ * Use this when authentication is managed by the MCP client.
5
+ * Tokens are provided per-request and not stored by the server.
6
+ *
7
+ * Tools:
8
+ * - {service}-account-me: Show current user identity from bearer token
9
+ */ "use strict";
10
+ Object.defineProperty(exports, "__esModule", {
11
+ value: true
12
+ });
13
+ Object.defineProperty(exports, "createStateless", {
14
+ enumerable: true,
15
+ get: function() {
16
+ return createStateless;
17
+ }
18
+ });
19
+ var _mets = require("./me.js");
20
+ function createStateless(config) {
21
+ var service = config.service;
22
+ // Create account-me tool for stateless mode
23
+ var meTools = (0, _mets.createAccountMe)({
24
+ service: service,
25
+ mode: 'stateless'
26
+ });
27
+ return {
28
+ tools: meTools.tools,
29
+ prompts: []
30
+ };
31
+ }
32
+ /* 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/src/lib/account-server/stateless.ts"],"sourcesContent":["/**\n * Stateless tool set for MCP OAuth mode (DCR).\n *\n * Use this when authentication is managed by the MCP client.\n * Tokens are provided per-request and not stored by the server.\n *\n * Tools:\n * - {service}-account-me: Show current user identity from bearer token\n */\n\nimport type { McpPrompt, McpTool } from '../../types.ts';\nimport { createAccountMe } from './me.ts';\nimport type { AccountStatelessConfig } from './types.ts';\n\n/**\n * Create stateless mode tools.\n * MCP client manages authentication. Server provides user identity from bearer token.\n * Returns 1 tool: account-me.\n */\nexport function createStateless(config: AccountStatelessConfig): { tools: McpTool[]; prompts: McpPrompt[] } {\n const { service } = config;\n\n // Create account-me tool for stateless mode\n const meTools = createAccountMe({ service, mode: 'stateless' });\n\n return { tools: meTools.tools, prompts: [] };\n}\n"],"names":["createStateless","config","service","meTools","createAccountMe","mode","tools","prompts"],"mappings":"AAAA;;;;;;;;CAQC;;;;+BAWeA;;;eAAAA;;;oBARgB;AAQzB,SAASA,gBAAgBC,MAA8B;IAC5D,IAAM,AAAEC,UAAYD,OAAZC;IAER,4CAA4C;IAC5C,IAAMC,UAAUC,IAAAA,qBAAe,EAAC;QAAEF,SAAAA;QAASG,MAAM;IAAY;IAE7D,OAAO;QAAEC,OAAOH,QAAQG,KAAK;QAAEC,SAAS,EAAE;IAAC;AAC7C"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Configuration types for account tool factories.
3
+ */
4
+ import type { Keyv } from 'keyv';
5
+ import type { AuthEmailProvider, Logger } from '../../types.js';
6
+ /**
7
+ * Configuration for loopback OAuth account management.
8
+ * Supports multiple accounts with server-managed tokens (LoopbackOAuthProvider).
9
+ */
10
+ export interface AccountLoopbackConfig {
11
+ service: string;
12
+ store: Keyv;
13
+ logger: Logger;
14
+ auth: AuthEmailProvider;
15
+ }
16
+ /**
17
+ * Configuration for stateless mode.
18
+ * MCP client manages authentication. Server provides read-only status.
19
+ */
20
+ export interface AccountStatelessConfig {
21
+ service: string;
22
+ }
23
+ /**
24
+ * Configuration for account-me tool.
25
+ * Works across all auth modes: loopback, stateless, device code, service account.
26
+ */
27
+ export interface AccountMeConfig {
28
+ service: string;
29
+ store?: Keyv;
30
+ logger?: Logger;
31
+ mode: 'loopback' | 'stateless' | 'device-code' | 'service-account';
32
+ }
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Configuration types for account tool factories.
3
+ */
4
+ import type { Keyv } from 'keyv';
5
+ import type { AuthEmailProvider, Logger } from '../../types.js';
6
+ /**
7
+ * Configuration for loopback OAuth account management.
8
+ * Supports multiple accounts with server-managed tokens (LoopbackOAuthProvider).
9
+ */
10
+ export interface AccountLoopbackConfig {
11
+ service: string;
12
+ store: Keyv;
13
+ logger: Logger;
14
+ auth: AuthEmailProvider;
15
+ }
16
+ /**
17
+ * Configuration for stateless mode.
18
+ * MCP client manages authentication. Server provides read-only status.
19
+ */
20
+ export interface AccountStatelessConfig {
21
+ service: string;
22
+ }
23
+ /**
24
+ * Configuration for account-me tool.
25
+ * Works across all auth modes: loopback, stateless, device code, service account.
26
+ */
27
+ export interface AccountMeConfig {
28
+ service: string;
29
+ store?: Keyv;
30
+ logger?: Logger;
31
+ mode: 'loopback' | 'stateless' | 'device-code' | 'service-account';
32
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Configuration types for account tool factories.
3
+ */ "use strict";
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ /* 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/src/lib/account-server/types.ts"],"sourcesContent":["/**\n * Configuration types for account tool factories.\n */\n\nimport type { Keyv } from 'keyv';\nimport type { AuthEmailProvider, Logger } from '../../types.ts';\n\n/**\n * Configuration for loopback OAuth account management.\n * Supports multiple accounts with server-managed tokens (LoopbackOAuthProvider).\n */\nexport interface AccountLoopbackConfig {\n service: string;\n store: Keyv;\n logger: Logger;\n auth: AuthEmailProvider;\n}\n\n/**\n * Configuration for stateless mode.\n * MCP client manages authentication. Server provides read-only status.\n */\nexport interface AccountStatelessConfig {\n service: string;\n}\n\n/**\n * Configuration for account-me tool.\n * Works across all auth modes: loopback, stateless, device code, service account.\n */\nexport interface AccountMeConfig {\n service: string;\n store?: Keyv;\n logger?: Logger;\n mode: 'loopback' | 'stateless' | 'device-code' | 'service-account';\n}\n"],"names":[],"mappings":"AAAA;;CAEC"}
@@ -0,0 +1,126 @@
1
+ /**
2
+ * Dynamic Client Registration (DCR) types per RFC 7591
3
+ *
4
+ * Defines core types for OAuth 2.0 Dynamic Client Registration Protocol.
5
+ * Used by providers to register clients dynamically with authorization servers.
6
+ *
7
+ * @see https://datatracker.ietf.org/doc/html/rfc7591
8
+ */
9
+ import type { Logger } from '../types.js';
10
+ /**
11
+ * Client metadata for dynamic registration request (RFC 7591 Section 2)
12
+ *
13
+ * All fields are optional per RFC 7591. Authorization server may have
14
+ * required fields or default values based on policy.
15
+ */
16
+ export interface DcrClientMetadata {
17
+ /** Array of redirection URI strings for redirect-based flows */
18
+ redirect_uris?: string[];
19
+ /** Client authentication method for token endpoint */
20
+ token_endpoint_auth_method?: 'none' | 'client_secret_post' | 'client_secret_basic';
21
+ /** OAuth 2.0 grant types the client may use */
22
+ grant_types?: string[];
23
+ /** OAuth 2.0 response types the client may use */
24
+ response_types?: string[];
25
+ /** Human-readable client name */
26
+ client_name?: string;
27
+ /** URL providing information about the client */
28
+ client_uri?: string;
29
+ /** URL referencing a logo for the client */
30
+ logo_uri?: string;
31
+ /** Space-separated list of scope values */
32
+ scope?: string;
33
+ /** Array of contact strings (typically email addresses) */
34
+ contacts?: string[];
35
+ /** URL pointing to terms of service document */
36
+ tos_uri?: string;
37
+ /** URL pointing to privacy policy document */
38
+ policy_uri?: string;
39
+ /** URL referencing the client's JSON Web Key Set */
40
+ jwks_uri?: string;
41
+ /** Client's JSON Web Key Set document value */
42
+ jwks?: object;
43
+ /** Unique identifier for the client software */
44
+ software_id?: string;
45
+ /** Version identifier for the client software */
46
+ software_version?: string;
47
+ /** JWT containing client metadata claims (signed software statement) */
48
+ software_statement?: string;
49
+ }
50
+ /**
51
+ * Client information response from successful registration (RFC 7591 Section 3.2.1)
52
+ *
53
+ * Authorization server returns client credentials and echoes/modifies metadata.
54
+ * client_id is always returned, client_secret is optional for public clients.
55
+ */
56
+ export interface DcrClientInformation {
57
+ /** REQUIRED: OAuth 2.0 client identifier string */
58
+ client_id: string;
59
+ /** OPTIONAL: OAuth 2.0 client secret (omitted for public clients) */
60
+ client_secret?: string;
61
+ /** OPTIONAL: Timestamp of client ID issuance (seconds since Unix epoch) */
62
+ client_id_issued_at?: number;
63
+ /**
64
+ * REQUIRED if client_secret issued: Expiration timestamp (seconds since epoch)
65
+ * Value of 0 indicates the secret does not expire
66
+ */
67
+ client_secret_expires_at?: number;
68
+ redirect_uris?: string[];
69
+ token_endpoint_auth_method?: string;
70
+ grant_types?: string[];
71
+ response_types?: string[];
72
+ client_name?: string;
73
+ client_uri?: string;
74
+ logo_uri?: string;
75
+ scope?: string;
76
+ contacts?: string[];
77
+ tos_uri?: string;
78
+ policy_uri?: string;
79
+ jwks_uri?: string;
80
+ jwks?: object;
81
+ software_id?: string;
82
+ software_version?: string;
83
+ }
84
+ /**
85
+ * Provider tokens for stateless DCR pattern
86
+ *
87
+ * In stateless mode, DCR provider receives provider credentials from context
88
+ * rather than managing token storage. Used for MCP server deployments where
89
+ * client manages all tokens.
90
+ */
91
+ export interface ProviderTokens {
92
+ /** OAuth 2.0 access token for provider API calls */
93
+ accessToken: string;
94
+ /** Optional refresh token for token renewal */
95
+ refreshToken?: string;
96
+ /** Token expiration timestamp (seconds since Unix epoch) */
97
+ expiresAt?: number;
98
+ /** Space-separated list of granted scopes */
99
+ scope?: string;
100
+ }
101
+ /**
102
+ * Configuration for DCR provider initialization
103
+ *
104
+ * Minimal config for creating DCR provider instances. Additional provider-specific
105
+ * config (client IDs, secrets, redirect URIs) handled by concrete implementations.
106
+ */
107
+ export interface DcrConfig {
108
+ /** Authorization server's registration endpoint URL */
109
+ registrationEndpoint: string;
110
+ /** Client metadata to register with authorization server */
111
+ metadata: DcrClientMetadata;
112
+ /** Optional logger for DCR operations */
113
+ logger?: Logger;
114
+ }
115
+ /**
116
+ * DCR error response per RFC 7591 Section 3.2.2
117
+ *
118
+ * Authorization server returns HTTP 400 with error details when
119
+ * registration fails due to invalid metadata or policy violations.
120
+ */
121
+ export interface DcrErrorResponse {
122
+ /** REQUIRED: Single ASCII error code string */
123
+ error: 'invalid_redirect_uri' | 'invalid_client_metadata' | 'invalid_software_statement' | 'unapproved_software_statement' | string;
124
+ /** OPTIONAL: Human-readable ASCII description */
125
+ error_description?: string;
126
+ }
@@ -0,0 +1,126 @@
1
+ /**
2
+ * Dynamic Client Registration (DCR) types per RFC 7591
3
+ *
4
+ * Defines core types for OAuth 2.0 Dynamic Client Registration Protocol.
5
+ * Used by providers to register clients dynamically with authorization servers.
6
+ *
7
+ * @see https://datatracker.ietf.org/doc/html/rfc7591
8
+ */
9
+ import type { Logger } from '../types.js';
10
+ /**
11
+ * Client metadata for dynamic registration request (RFC 7591 Section 2)
12
+ *
13
+ * All fields are optional per RFC 7591. Authorization server may have
14
+ * required fields or default values based on policy.
15
+ */
16
+ export interface DcrClientMetadata {
17
+ /** Array of redirection URI strings for redirect-based flows */
18
+ redirect_uris?: string[];
19
+ /** Client authentication method for token endpoint */
20
+ token_endpoint_auth_method?: 'none' | 'client_secret_post' | 'client_secret_basic';
21
+ /** OAuth 2.0 grant types the client may use */
22
+ grant_types?: string[];
23
+ /** OAuth 2.0 response types the client may use */
24
+ response_types?: string[];
25
+ /** Human-readable client name */
26
+ client_name?: string;
27
+ /** URL providing information about the client */
28
+ client_uri?: string;
29
+ /** URL referencing a logo for the client */
30
+ logo_uri?: string;
31
+ /** Space-separated list of scope values */
32
+ scope?: string;
33
+ /** Array of contact strings (typically email addresses) */
34
+ contacts?: string[];
35
+ /** URL pointing to terms of service document */
36
+ tos_uri?: string;
37
+ /** URL pointing to privacy policy document */
38
+ policy_uri?: string;
39
+ /** URL referencing the client's JSON Web Key Set */
40
+ jwks_uri?: string;
41
+ /** Client's JSON Web Key Set document value */
42
+ jwks?: object;
43
+ /** Unique identifier for the client software */
44
+ software_id?: string;
45
+ /** Version identifier for the client software */
46
+ software_version?: string;
47
+ /** JWT containing client metadata claims (signed software statement) */
48
+ software_statement?: string;
49
+ }
50
+ /**
51
+ * Client information response from successful registration (RFC 7591 Section 3.2.1)
52
+ *
53
+ * Authorization server returns client credentials and echoes/modifies metadata.
54
+ * client_id is always returned, client_secret is optional for public clients.
55
+ */
56
+ export interface DcrClientInformation {
57
+ /** REQUIRED: OAuth 2.0 client identifier string */
58
+ client_id: string;
59
+ /** OPTIONAL: OAuth 2.0 client secret (omitted for public clients) */
60
+ client_secret?: string;
61
+ /** OPTIONAL: Timestamp of client ID issuance (seconds since Unix epoch) */
62
+ client_id_issued_at?: number;
63
+ /**
64
+ * REQUIRED if client_secret issued: Expiration timestamp (seconds since epoch)
65
+ * Value of 0 indicates the secret does not expire
66
+ */
67
+ client_secret_expires_at?: number;
68
+ redirect_uris?: string[];
69
+ token_endpoint_auth_method?: string;
70
+ grant_types?: string[];
71
+ response_types?: string[];
72
+ client_name?: string;
73
+ client_uri?: string;
74
+ logo_uri?: string;
75
+ scope?: string;
76
+ contacts?: string[];
77
+ tos_uri?: string;
78
+ policy_uri?: string;
79
+ jwks_uri?: string;
80
+ jwks?: object;
81
+ software_id?: string;
82
+ software_version?: string;
83
+ }
84
+ /**
85
+ * Provider tokens for stateless DCR pattern
86
+ *
87
+ * In stateless mode, DCR provider receives provider credentials from context
88
+ * rather than managing token storage. Used for MCP server deployments where
89
+ * client manages all tokens.
90
+ */
91
+ export interface ProviderTokens {
92
+ /** OAuth 2.0 access token for provider API calls */
93
+ accessToken: string;
94
+ /** Optional refresh token for token renewal */
95
+ refreshToken?: string;
96
+ /** Token expiration timestamp (seconds since Unix epoch) */
97
+ expiresAt?: number;
98
+ /** Space-separated list of granted scopes */
99
+ scope?: string;
100
+ }
101
+ /**
102
+ * Configuration for DCR provider initialization
103
+ *
104
+ * Minimal config for creating DCR provider instances. Additional provider-specific
105
+ * config (client IDs, secrets, redirect URIs) handled by concrete implementations.
106
+ */
107
+ export interface DcrConfig {
108
+ /** Authorization server's registration endpoint URL */
109
+ registrationEndpoint: string;
110
+ /** Client metadata to register with authorization server */
111
+ metadata: DcrClientMetadata;
112
+ /** Optional logger for DCR operations */
113
+ logger?: Logger;
114
+ }
115
+ /**
116
+ * DCR error response per RFC 7591 Section 3.2.2
117
+ *
118
+ * Authorization server returns HTTP 400 with error details when
119
+ * registration fails due to invalid metadata or policy violations.
120
+ */
121
+ export interface DcrErrorResponse {
122
+ /** REQUIRED: Single ASCII error code string */
123
+ error: 'invalid_redirect_uri' | 'invalid_client_metadata' | 'invalid_software_statement' | 'unapproved_software_statement' | string;
124
+ /** OPTIONAL: Human-readable ASCII description */
125
+ error_description?: string;
126
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Dynamic Client Registration (DCR) types per RFC 7591
3
+ *
4
+ * Defines core types for OAuth 2.0 Dynamic Client Registration Protocol.
5
+ * Used by providers to register clients dynamically with authorization servers.
6
+ *
7
+ * @see https://datatracker.ietf.org/doc/html/rfc7591
8
+ */ "use strict";
9
+ Object.defineProperty(exports, "__esModule", {
10
+ value: true
11
+ });
12
+ /* 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; }