@meshagent/meshagent 0.44.13 → 0.45.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.
Files changed (56) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/browser/index.d.ts +1 -1
  3. package/dist/browser/index.js +1 -1
  4. package/dist/browser/meshagent-client.d.ts +390 -372
  5. package/dist/browser/meshagent-client.js +841 -1040
  6. package/dist/browser/oauth-scopes.d.ts +1 -1
  7. package/dist/browser/oauth-scopes.js +64 -14
  8. package/dist/browser/participant-token.d.ts +68 -20
  9. package/dist/browser/participant-token.js +232 -61
  10. package/dist/browser/room-client.d.ts +4 -8
  11. package/dist/browser/room-client.js +4 -10
  12. package/dist/browser/services-client.d.ts +11 -0
  13. package/dist/browser/services-client.js +17 -0
  14. package/dist/browser/sqlite-client.d.ts +326 -0
  15. package/dist/browser/sqlite-client.js +630 -0
  16. package/dist/browser/toolkit-config.d.ts +7 -1
  17. package/dist/browser/toolkit-config.js +41 -22
  18. package/dist/esm/index.d.ts +1 -1
  19. package/dist/esm/index.js +1 -1
  20. package/dist/esm/meshagent-client.d.ts +390 -372
  21. package/dist/esm/meshagent-client.js +841 -1038
  22. package/dist/esm/oauth-scopes.d.ts +1 -1
  23. package/dist/esm/oauth-scopes.js +64 -14
  24. package/dist/esm/participant-token.d.ts +68 -20
  25. package/dist/esm/participant-token.js +228 -59
  26. package/dist/esm/room-client.d.ts +4 -8
  27. package/dist/esm/room-client.js +4 -10
  28. package/dist/esm/services-client.d.ts +11 -0
  29. package/dist/esm/services-client.js +17 -0
  30. package/dist/esm/sqlite-client.d.ts +326 -0
  31. package/dist/esm/sqlite-client.js +625 -0
  32. package/dist/esm/toolkit-config.d.ts +7 -1
  33. package/dist/esm/toolkit-config.js +41 -22
  34. package/dist/node/index.d.ts +1 -1
  35. package/dist/node/index.js +1 -1
  36. package/dist/node/meshagent-client.d.ts +390 -372
  37. package/dist/node/meshagent-client.js +841 -1040
  38. package/dist/node/oauth-scopes.d.ts +1 -1
  39. package/dist/node/oauth-scopes.js +64 -14
  40. package/dist/node/participant-token.d.ts +68 -20
  41. package/dist/node/participant-token.js +232 -61
  42. package/dist/node/room-client.d.ts +4 -8
  43. package/dist/node/room-client.js +4 -10
  44. package/dist/node/services-client.d.ts +11 -0
  45. package/dist/node/services-client.js +17 -0
  46. package/dist/node/sqlite-client.d.ts +326 -0
  47. package/dist/node/sqlite-client.js +630 -0
  48. package/dist/node/toolkit-config.d.ts +7 -1
  49. package/dist/node/toolkit-config.js +41 -22
  50. package/package.json +1 -1
  51. package/dist/browser/secrets-client.d.ts +0 -112
  52. package/dist/browser/secrets-client.js +0 -300
  53. package/dist/esm/secrets-client.d.ts +0 -112
  54. package/dist/esm/secrets-client.js +0 -296
  55. package/dist/node/secrets-client.d.ts +0 -112
  56. package/dist/node/secrets-client.js +0 -300
@@ -180,30 +180,19 @@ class Connector {
180
180
  if (connector == null && this.oauth == null) {
181
181
  return true;
182
182
  }
183
- const token = await room.secrets.getOfflineOAuthToken({
184
- connector,
185
- oauth: this.oauth,
186
- delegatedTo: agentName,
187
- });
188
- return token != null;
183
+ void room;
184
+ void agentName;
185
+ throw new Error("OAuth MCP connections require proxy-backed user secrets");
189
186
  }
190
187
  async authenticate(client, agent, redirectUri) {
191
188
  const connector = this.buildConnectorRef();
192
189
  if (connector == null && this.oauth == null) {
193
190
  return null;
194
191
  }
195
- const localParticipant = client.localParticipant;
196
- if (localParticipant == null) {
197
- throw new Error("Connector.authenticate requires a local participant");
198
- }
199
- const agentName = agent.getAttribute("name");
200
- return await client.secrets.requestOAuthToken({
201
- fromParticipantId: localParticipant.id,
202
- connector,
203
- oauth: this.oauth,
204
- redirectUri,
205
- delegateTo: agentName == null ? null : String(agentName),
206
- });
192
+ void client;
193
+ void agent;
194
+ void redirectUri;
195
+ throw new Error("OAuth MCP connections require proxy-backed user secrets");
207
196
  }
208
197
  }
209
198
  exports.Connector = Connector;
@@ -259,7 +248,25 @@ function roomServiceMcpServerUrl({ service, port, endpoint, }) {
259
248
  const fragment = baseUrl.hash;
260
249
  return `${baseUrl.protocol}//${userInfo}${bracketIpv6Host(baseUrl.hostname)}:${portValue}${joinedPath}${query}${fragment}`;
261
250
  }
262
- function mcpConnectorsFromRoomServices({ services, agentName, }) {
251
+ function proxyMcpServerUrl({ serverUrl, useProxySecret, proxyConfig, }) {
252
+ const secretId = useProxySecret?.trim();
253
+ if (serverUrl == null || secretId == null || secretId.length === 0 || proxyConfig == null) {
254
+ return serverUrl;
255
+ }
256
+ const apiUrl = proxyConfig.apiUrl.trim().replace(/\/+$/, "");
257
+ if (apiUrl.length === 0 || proxyConfig.apiKey.trim().length === 0) {
258
+ throw new Error("meshagent_proxy_config requires apiUrl and apiKey");
259
+ }
260
+ const url = new URL(`${apiUrl}/proxy-request`);
261
+ url.searchParams.set("url", serverUrl);
262
+ url.searchParams.set("secret-id", secretId);
263
+ const user = proxyConfig.user?.trim();
264
+ if (user != null && user.length > 0) {
265
+ url.searchParams.set("user", user);
266
+ }
267
+ return url.toString();
268
+ }
269
+ function mcpConnectorsFromRoomServices({ services, agentName, meshagentProxyConfig, }) {
263
270
  const connectors = [];
264
271
  for (const service of services) {
265
272
  const filter = service.metadata.annotations?.["meshagent.agent.filter"];
@@ -276,12 +283,24 @@ function mcpConnectorsFromRoomServices({ services, agentName, }) {
276
283
  name: mcp.label,
277
284
  server: new MCPServer({
278
285
  serverLabel: mcp.label,
279
- serverUrl: roomServiceMcpServerUrl({ service, port, endpoint }),
280
- headers: headersFromEndpointSpec(mcp.headers),
286
+ serverUrl: proxyMcpServerUrl({
287
+ serverUrl: roomServiceMcpServerUrl({ service, port, endpoint }),
288
+ useProxySecret: mcp.use_proxy_secret,
289
+ proxyConfig: meshagentProxyConfig,
290
+ }),
291
+ headers: mcp.use_proxy_secret != null && meshagentProxyConfig != null
292
+ ? [
293
+ ...(headersFromEndpointSpec(mcp.headers) ?? []),
294
+ new MCPHeader({
295
+ name: "Authorization",
296
+ value: `Bearer ${meshagentProxyConfig.apiKey}`,
297
+ }),
298
+ ]
299
+ : headersFromEndpointSpec(mcp.headers),
281
300
  requireApproval: mcp.require_approval,
282
301
  openaiConnectorId: mcp.openai_connector_id,
283
302
  }),
284
- oauth: mcp.oauth,
303
+ oauth: mcp.use_proxy_secret != null ? undefined : mcp.oauth,
285
304
  }));
286
305
  }
287
306
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meshagent/meshagent",
3
- "version": "0.44.13",
3
+ "version": "0.45.1",
4
4
  "description": "Meshagent Client",
5
5
  "homepage": "https://github.com/meshagent/meshagent-ts",
6
6
  "scripts": {
@@ -1,112 +0,0 @@
1
- import type { ConnectorRef, OAuthClientConfig } from "./meshagent-client.js";
2
- import { FileContent } from "./response.js";
3
- import { RoomClient } from "./room-client.js";
4
- export interface SecretInfo {
5
- id: string;
6
- name: string;
7
- type: string;
8
- delegatedTo?: string | null;
9
- }
10
- export interface OAuthTokenRequest {
11
- requestId: string;
12
- authorizationEndpoint: string;
13
- tokenEndpoint: string;
14
- challenge?: string | null;
15
- scopes?: string[] | null;
16
- clientId?: string | null;
17
- }
18
- export type OAuthTokenRequestHandler = (request: OAuthTokenRequest) => Promise<void> | void;
19
- export interface SecretRequest {
20
- requestId: string;
21
- url: string;
22
- type: string;
23
- delegateTo?: string | null;
24
- }
25
- export type SecretRequestHandler = (request: SecretRequest) => Promise<void> | void;
26
- export declare class SecretsClient {
27
- private readonly client;
28
- private readonly oauthTokenRequestHandler?;
29
- private readonly secretRequestHandler?;
30
- private readonly _oauthRequestHandler;
31
- private readonly _secretRequestHandler;
32
- constructor({ room, oauthTokenRequestHandler, secretRequestHandler, }: {
33
- room: RoomClient;
34
- oauthTokenRequestHandler?: OAuthTokenRequestHandler;
35
- secretRequestHandler?: SecretRequestHandler;
36
- });
37
- private unexpectedResponse;
38
- private invoke;
39
- private serializeConnectorRef;
40
- private serializeOAuthConfig;
41
- private parseAccessToken;
42
- private parseSecretInfo;
43
- private _handleClientOAuthTokenRequest;
44
- private _handleClientSecretRequest;
45
- provideOAuthAuthorization({ requestId, code, }: {
46
- requestId: string;
47
- code: string;
48
- }): Promise<void>;
49
- rejectOAuthAuthorization({ requestId, error, }: {
50
- requestId: string;
51
- error: string;
52
- }): Promise<void>;
53
- provideSecret({ requestId, data, }: {
54
- requestId: string;
55
- data: Uint8Array;
56
- }): Promise<void>;
57
- rejectSecret({ requestId, error, }: {
58
- requestId: string;
59
- error: string;
60
- }): Promise<void>;
61
- getOfflineOAuthToken({ connector, oauth, delegatedTo, delegatedBy, }: {
62
- connector?: ConnectorRef | null;
63
- oauth?: OAuthClientConfig | null;
64
- delegatedTo?: string | null;
65
- delegatedBy?: string | null;
66
- }): Promise<string | null>;
67
- requestOAuthToken({ connector, oauth, timeout, fromParticipantId, redirectUri, delegateTo, }: {
68
- connector?: ConnectorRef | null;
69
- oauth?: OAuthClientConfig | null;
70
- timeout?: number;
71
- fromParticipantId: string;
72
- redirectUri: string | URL;
73
- delegateTo?: string | null;
74
- }): Promise<string | null>;
75
- listSecrets(): Promise<SecretInfo[]>;
76
- exists({ secretId, delegatedTo, forIdentity, }: {
77
- secretId: string;
78
- delegatedTo?: string | null;
79
- forIdentity?: string | null;
80
- }): Promise<boolean>;
81
- deleteSecret({ secretId, delegatedTo, }: {
82
- secretId: string;
83
- delegatedTo?: string | null;
84
- }): Promise<void>;
85
- deleteRequestedSecret({ url, type, delegatedTo, }: {
86
- url: string;
87
- type: string;
88
- delegatedTo?: string | null;
89
- }): Promise<void>;
90
- requestSecret({ fromParticipantId, url, type, timeout, delegateTo, }: {
91
- fromParticipantId: string;
92
- url: string;
93
- type: string;
94
- timeout?: number;
95
- delegateTo?: string | null;
96
- }): Promise<Uint8Array>;
97
- setSecret({ secretId, type, mimeType, name, delegatedTo, forIdentity, data, }: {
98
- secretId?: string | null;
99
- type?: string | null;
100
- mimeType?: string | null;
101
- name?: string | null;
102
- delegatedTo?: string | null;
103
- forIdentity?: string | null;
104
- data: Uint8Array;
105
- }): Promise<void>;
106
- getSecret({ secretId, type, name, delegatedTo, }: {
107
- secretId?: string | null;
108
- type?: string | null;
109
- name?: string | null;
110
- delegatedTo?: string | null;
111
- }): Promise<FileContent | null>;
112
- }
@@ -1,300 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SecretsClient = void 0;
4
- const response_js_1 = require("./response.js");
5
- const room_server_client_js_1 = require("./room-server-client.js");
6
- const utils_js_1 = require("./utils.js");
7
- function isRecord(value) {
8
- return typeof value === "object" && value !== null && !Array.isArray(value);
9
- }
10
- class SecretsClient {
11
- constructor({ room, oauthTokenRequestHandler, secretRequestHandler, }) {
12
- this._oauthRequestHandler = this._handleClientOAuthTokenRequest.bind(this);
13
- this._secretRequestHandler = this._handleClientSecretRequest.bind(this);
14
- this.client = room;
15
- this.oauthTokenRequestHandler = oauthTokenRequestHandler;
16
- this.secretRequestHandler = secretRequestHandler;
17
- this.client.protocol.addHandler("secrets.request_oauth_token", this._oauthRequestHandler);
18
- this.client.protocol.addHandler("secrets.request_secret", this._secretRequestHandler);
19
- }
20
- unexpectedResponse(operation) {
21
- return new room_server_client_js_1.RoomServerException(`unexpected return type from secrets.${operation}`);
22
- }
23
- async invoke(operation, input) {
24
- return await this.client.invokeContent({
25
- toolkit: "secrets",
26
- tool: operation,
27
- input,
28
- });
29
- }
30
- serializeConnectorRef(connector) {
31
- if (connector == null) {
32
- return null;
33
- }
34
- return {
35
- openai_connector_id: connector.openaiConnectorId ?? null,
36
- server_url: connector.serverUrl ?? null,
37
- client_secret_id: connector.clientSecretId ?? null,
38
- };
39
- }
40
- serializeOAuthConfig(oauth) {
41
- if (oauth == null) {
42
- return null;
43
- }
44
- return {
45
- client_id: oauth.client_id,
46
- client_secret: oauth.client_secret ?? null,
47
- authorization_endpoint: oauth.authorization_endpoint,
48
- token_endpoint: oauth.token_endpoint,
49
- no_pkce: oauth.no_pkce ?? null,
50
- scopes: oauth.scopes ?? null,
51
- };
52
- }
53
- parseAccessToken(operation, response) {
54
- if (!(response instanceof response_js_1.JsonContent)) {
55
- throw this.unexpectedResponse(operation);
56
- }
57
- const token = response.json["access_token"];
58
- if (typeof token !== "string" || token.length === 0) {
59
- return null;
60
- }
61
- return token;
62
- }
63
- parseSecretInfo(value) {
64
- if (!isRecord(value) || typeof value["id"] !== "string" || typeof value["name"] !== "string" || typeof value["type"] !== "string") {
65
- throw this.unexpectedResponse("list_secrets");
66
- }
67
- const delegatedTo = value["delegated_to"];
68
- if (delegatedTo !== undefined && delegatedTo !== null && typeof delegatedTo !== "string") {
69
- throw this.unexpectedResponse("list_secrets");
70
- }
71
- return {
72
- id: value["id"],
73
- name: value["name"],
74
- type: value["type"],
75
- delegatedTo: delegatedTo,
76
- };
77
- }
78
- async _handleClientOAuthTokenRequest(protocol, messageId, type, bytes) {
79
- if (!this.client.isActiveProtocol(protocol)) {
80
- return;
81
- }
82
- void messageId;
83
- void type;
84
- if (bytes == null) {
85
- throw new room_server_client_js_1.RoomServerException("invalid secrets.request_oauth_token payload");
86
- }
87
- if (this.oauthTokenRequestHandler == null) {
88
- throw new room_server_client_js_1.RoomServerException("No oauth token handler registered");
89
- }
90
- const [request] = (0, utils_js_1.unpackMessage)(bytes);
91
- const requestId = request["request_id"];
92
- const challenge = request["challenge"];
93
- const requestPayload = request["request"];
94
- if (typeof requestId !== "string" || !isRecord(requestPayload)) {
95
- throw new room_server_client_js_1.RoomServerException("invalid secrets.request_oauth_token payload");
96
- }
97
- const oauth = requestPayload["oauth"];
98
- if (!isRecord(oauth) || typeof oauth["authorization_endpoint"] !== "string" || typeof oauth["token_endpoint"] !== "string") {
99
- throw new room_server_client_js_1.RoomServerException("invalid secrets.request_oauth_token payload");
100
- }
101
- const scopes = oauth["scopes"];
102
- if (scopes !== undefined && scopes !== null && (!Array.isArray(scopes) || scopes.some((scope) => typeof scope !== "string"))) {
103
- throw new room_server_client_js_1.RoomServerException("invalid secrets.request_oauth_token payload");
104
- }
105
- Promise.resolve(this.oauthTokenRequestHandler({
106
- requestId,
107
- authorizationEndpoint: oauth["authorization_endpoint"],
108
- tokenEndpoint: oauth["token_endpoint"],
109
- challenge: typeof challenge === "string" ? challenge : null,
110
- scopes: scopes ?? null,
111
- clientId: typeof oauth["client_id"] === "string" ? oauth["client_id"] : null,
112
- })).catch((error) => {
113
- console.warn("OAuth token request handler threw", error);
114
- });
115
- }
116
- async _handleClientSecretRequest(protocol, messageId, type, bytes) {
117
- if (!this.client.isActiveProtocol(protocol)) {
118
- return;
119
- }
120
- void messageId;
121
- void type;
122
- if (bytes == null) {
123
- throw new room_server_client_js_1.RoomServerException("invalid secrets.request_secret payload");
124
- }
125
- if (this.secretRequestHandler == null) {
126
- throw new room_server_client_js_1.RoomServerException("No secret handler registered");
127
- }
128
- const [request] = (0, utils_js_1.unpackMessage)(bytes);
129
- const requestId = request["request_id"];
130
- const requestPayload = request["request"];
131
- if (typeof requestId !== "string" || !isRecord(requestPayload) || typeof requestPayload["url"] !== "string" || typeof requestPayload["type"] !== "string") {
132
- throw new room_server_client_js_1.RoomServerException("invalid secrets.request_secret payload");
133
- }
134
- Promise.resolve(this.secretRequestHandler({
135
- requestId,
136
- url: requestPayload["url"],
137
- type: requestPayload["type"],
138
- delegateTo: typeof requestPayload["delegate_to"] === "string" ? requestPayload["delegate_to"] : null,
139
- })).catch((error) => {
140
- console.warn("Secret request handler threw", error);
141
- });
142
- }
143
- async provideOAuthAuthorization({ requestId, code, }) {
144
- const response = await this.invoke("provide_oauth_authorization", {
145
- request_id: requestId,
146
- code,
147
- error: null,
148
- });
149
- if (response instanceof response_js_1.EmptyContent || response instanceof response_js_1.JsonContent) {
150
- return;
151
- }
152
- throw this.unexpectedResponse("provide_oauth_authorization");
153
- }
154
- async rejectOAuthAuthorization({ requestId, error, }) {
155
- const response = await this.invoke("provide_oauth_authorization", {
156
- request_id: requestId,
157
- code: null,
158
- error,
159
- });
160
- if (response instanceof response_js_1.EmptyContent || response instanceof response_js_1.JsonContent) {
161
- return;
162
- }
163
- throw this.unexpectedResponse("provide_oauth_authorization");
164
- }
165
- async provideSecret({ requestId, data, }) {
166
- const response = await this.invoke("provide_secret", new response_js_1.BinaryContent({
167
- data,
168
- headers: {
169
- request_id: requestId,
170
- error: null,
171
- },
172
- }));
173
- if (response instanceof response_js_1.EmptyContent || response instanceof response_js_1.JsonContent) {
174
- return;
175
- }
176
- throw this.unexpectedResponse("provide_secret");
177
- }
178
- async rejectSecret({ requestId, error, }) {
179
- const response = await this.invoke("provide_secret", new response_js_1.BinaryContent({
180
- data: new Uint8Array(0),
181
- headers: {
182
- request_id: requestId,
183
- error,
184
- },
185
- }));
186
- if (response instanceof response_js_1.EmptyContent || response instanceof response_js_1.JsonContent) {
187
- return;
188
- }
189
- throw this.unexpectedResponse("provide_secret");
190
- }
191
- async getOfflineOAuthToken({ connector, oauth, delegatedTo, delegatedBy, }) {
192
- const response = await this.invoke("get_offline_oauth_token", {
193
- connector: this.serializeConnectorRef(connector),
194
- oauth: this.serializeOAuthConfig(oauth),
195
- delegated_to: delegatedTo ?? null,
196
- delegated_by: delegatedBy ?? null,
197
- });
198
- return this.parseAccessToken("get_offline_oauth_token", response);
199
- }
200
- async requestOAuthToken({ connector, oauth, timeout = 60 * 5, fromParticipantId, redirectUri, delegateTo, }) {
201
- const response = await this.invoke("request_oauth_token", {
202
- connector: this.serializeConnectorRef(connector),
203
- oauth: this.serializeOAuthConfig(oauth),
204
- redirect_uri: typeof redirectUri === "string" ? redirectUri : redirectUri.toString(),
205
- timeout,
206
- participant_id: fromParticipantId,
207
- delegate_to: delegateTo ?? null,
208
- });
209
- return this.parseAccessToken("request_oauth_token", response);
210
- }
211
- async listSecrets() {
212
- const response = await this.invoke("list_secrets", {});
213
- if (!(response instanceof response_js_1.JsonContent)) {
214
- throw this.unexpectedResponse("list_secrets");
215
- }
216
- const secrets = response.json["secrets"];
217
- if (!Array.isArray(secrets)) {
218
- throw this.unexpectedResponse("list_secrets");
219
- }
220
- return secrets.map((item) => this.parseSecretInfo(item));
221
- }
222
- async exists({ secretId, delegatedTo, forIdentity, }) {
223
- const response = await this.invoke("exists", {
224
- secret_id: secretId,
225
- delegated_to: delegatedTo ?? null,
226
- for_identity: forIdentity ?? null,
227
- });
228
- if (!(response instanceof response_js_1.JsonContent) || typeof response.json["exists"] !== "boolean") {
229
- throw this.unexpectedResponse("exists");
230
- }
231
- return response.json["exists"];
232
- }
233
- async deleteSecret({ secretId, delegatedTo, }) {
234
- const response = await this.invoke("delete_secret", {
235
- id: secretId,
236
- delegated_to: delegatedTo ?? null,
237
- });
238
- if (response instanceof response_js_1.EmptyContent || response instanceof response_js_1.JsonContent) {
239
- return;
240
- }
241
- throw this.unexpectedResponse("delete_secret");
242
- }
243
- async deleteRequestedSecret({ url, type, delegatedTo, }) {
244
- const response = await this.invoke("delete_requested_secret", {
245
- url,
246
- type,
247
- delegated_to: delegatedTo ?? null,
248
- });
249
- if (response instanceof response_js_1.EmptyContent || response instanceof response_js_1.JsonContent) {
250
- return;
251
- }
252
- throw this.unexpectedResponse("delete_requested_secret");
253
- }
254
- async requestSecret({ fromParticipantId, url, type, timeout = 60 * 5, delegateTo, }) {
255
- const response = await this.invoke("request_secret", {
256
- url,
257
- type,
258
- participant_id: fromParticipantId,
259
- timeout,
260
- delegate_to: delegateTo ?? null,
261
- });
262
- if (response instanceof response_js_1.FileContent) {
263
- return response.data;
264
- }
265
- throw this.unexpectedResponse("request_secret");
266
- }
267
- async setSecret({ secretId, type, mimeType, name, delegatedTo, forIdentity, data, }) {
268
- const response = await this.invoke("set_secret", new response_js_1.BinaryContent({
269
- data,
270
- headers: {
271
- secret_id: secretId ?? null,
272
- type: type ?? mimeType ?? null,
273
- name: name ?? null,
274
- delegated_to: delegatedTo ?? null,
275
- for_identity: forIdentity ?? null,
276
- has_data: true,
277
- },
278
- }));
279
- if (response instanceof response_js_1.EmptyContent || response instanceof response_js_1.JsonContent) {
280
- return;
281
- }
282
- throw this.unexpectedResponse("set_secret");
283
- }
284
- async getSecret({ secretId, type, name, delegatedTo, }) {
285
- const response = await this.invoke("get_secret", {
286
- secret_id: secretId ?? null,
287
- type: type ?? null,
288
- name: name ?? null,
289
- delegated_to: delegatedTo ?? null,
290
- });
291
- if (response instanceof response_js_1.EmptyContent) {
292
- return null;
293
- }
294
- if (response instanceof response_js_1.FileContent) {
295
- return response;
296
- }
297
- throw this.unexpectedResponse("get_secret");
298
- }
299
- }
300
- exports.SecretsClient = SecretsClient;
@@ -1,112 +0,0 @@
1
- import type { ConnectorRef, OAuthClientConfig } from "./meshagent-client.js";
2
- import { FileContent } from "./response.js";
3
- import { RoomClient } from "./room-client.js";
4
- export interface SecretInfo {
5
- id: string;
6
- name: string;
7
- type: string;
8
- delegatedTo?: string | null;
9
- }
10
- export interface OAuthTokenRequest {
11
- requestId: string;
12
- authorizationEndpoint: string;
13
- tokenEndpoint: string;
14
- challenge?: string | null;
15
- scopes?: string[] | null;
16
- clientId?: string | null;
17
- }
18
- export type OAuthTokenRequestHandler = (request: OAuthTokenRequest) => Promise<void> | void;
19
- export interface SecretRequest {
20
- requestId: string;
21
- url: string;
22
- type: string;
23
- delegateTo?: string | null;
24
- }
25
- export type SecretRequestHandler = (request: SecretRequest) => Promise<void> | void;
26
- export declare class SecretsClient {
27
- private readonly client;
28
- private readonly oauthTokenRequestHandler?;
29
- private readonly secretRequestHandler?;
30
- private readonly _oauthRequestHandler;
31
- private readonly _secretRequestHandler;
32
- constructor({ room, oauthTokenRequestHandler, secretRequestHandler, }: {
33
- room: RoomClient;
34
- oauthTokenRequestHandler?: OAuthTokenRequestHandler;
35
- secretRequestHandler?: SecretRequestHandler;
36
- });
37
- private unexpectedResponse;
38
- private invoke;
39
- private serializeConnectorRef;
40
- private serializeOAuthConfig;
41
- private parseAccessToken;
42
- private parseSecretInfo;
43
- private _handleClientOAuthTokenRequest;
44
- private _handleClientSecretRequest;
45
- provideOAuthAuthorization({ requestId, code, }: {
46
- requestId: string;
47
- code: string;
48
- }): Promise<void>;
49
- rejectOAuthAuthorization({ requestId, error, }: {
50
- requestId: string;
51
- error: string;
52
- }): Promise<void>;
53
- provideSecret({ requestId, data, }: {
54
- requestId: string;
55
- data: Uint8Array;
56
- }): Promise<void>;
57
- rejectSecret({ requestId, error, }: {
58
- requestId: string;
59
- error: string;
60
- }): Promise<void>;
61
- getOfflineOAuthToken({ connector, oauth, delegatedTo, delegatedBy, }: {
62
- connector?: ConnectorRef | null;
63
- oauth?: OAuthClientConfig | null;
64
- delegatedTo?: string | null;
65
- delegatedBy?: string | null;
66
- }): Promise<string | null>;
67
- requestOAuthToken({ connector, oauth, timeout, fromParticipantId, redirectUri, delegateTo, }: {
68
- connector?: ConnectorRef | null;
69
- oauth?: OAuthClientConfig | null;
70
- timeout?: number;
71
- fromParticipantId: string;
72
- redirectUri: string | URL;
73
- delegateTo?: string | null;
74
- }): Promise<string | null>;
75
- listSecrets(): Promise<SecretInfo[]>;
76
- exists({ secretId, delegatedTo, forIdentity, }: {
77
- secretId: string;
78
- delegatedTo?: string | null;
79
- forIdentity?: string | null;
80
- }): Promise<boolean>;
81
- deleteSecret({ secretId, delegatedTo, }: {
82
- secretId: string;
83
- delegatedTo?: string | null;
84
- }): Promise<void>;
85
- deleteRequestedSecret({ url, type, delegatedTo, }: {
86
- url: string;
87
- type: string;
88
- delegatedTo?: string | null;
89
- }): Promise<void>;
90
- requestSecret({ fromParticipantId, url, type, timeout, delegateTo, }: {
91
- fromParticipantId: string;
92
- url: string;
93
- type: string;
94
- timeout?: number;
95
- delegateTo?: string | null;
96
- }): Promise<Uint8Array>;
97
- setSecret({ secretId, type, mimeType, name, delegatedTo, forIdentity, data, }: {
98
- secretId?: string | null;
99
- type?: string | null;
100
- mimeType?: string | null;
101
- name?: string | null;
102
- delegatedTo?: string | null;
103
- forIdentity?: string | null;
104
- data: Uint8Array;
105
- }): Promise<void>;
106
- getSecret({ secretId, type, name, delegatedTo, }: {
107
- secretId?: string | null;
108
- type?: string | null;
109
- name?: string | null;
110
- delegatedTo?: string | null;
111
- }): Promise<FileContent | null>;
112
- }