@meshagent/meshagent 0.35.6 → 0.35.8

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 (47) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/browser/containers-client.d.ts +79 -2
  3. package/dist/browser/containers-client.js +341 -19
  4. package/dist/browser/database-client.d.ts +95 -24
  5. package/dist/browser/database-client.js +150 -49
  6. package/dist/browser/messaging-client.d.ts +33 -52
  7. package/dist/browser/messaging-client.js +180 -184
  8. package/dist/browser/participant.d.ts +5 -3
  9. package/dist/browser/participant.js +9 -1
  10. package/dist/browser/room-client.js +2 -0
  11. package/dist/browser/room-event.d.ts +6 -2
  12. package/dist/browser/room-event.js +4 -2
  13. package/dist/browser/secrets-client.d.ts +86 -16
  14. package/dist/browser/secrets-client.js +243 -44
  15. package/dist/browser/storage-client.d.ts +17 -4
  16. package/dist/browser/storage-client.js +104 -16
  17. package/dist/esm/containers-client.d.ts +79 -2
  18. package/dist/esm/containers-client.js +341 -19
  19. package/dist/esm/database-client.d.ts +95 -24
  20. package/dist/esm/database-client.js +150 -49
  21. package/dist/esm/messaging-client.d.ts +33 -52
  22. package/dist/esm/messaging-client.js +179 -180
  23. package/dist/esm/participant.d.ts +5 -3
  24. package/dist/esm/participant.js +9 -1
  25. package/dist/esm/room-client.js +2 -0
  26. package/dist/esm/room-event.d.ts +6 -2
  27. package/dist/esm/room-event.js +4 -2
  28. package/dist/esm/secrets-client.d.ts +86 -16
  29. package/dist/esm/secrets-client.js +243 -44
  30. package/dist/esm/storage-client.d.ts +17 -4
  31. package/dist/esm/storage-client.js +103 -16
  32. package/dist/node/containers-client.d.ts +79 -2
  33. package/dist/node/containers-client.js +341 -19
  34. package/dist/node/database-client.d.ts +95 -24
  35. package/dist/node/database-client.js +150 -49
  36. package/dist/node/messaging-client.d.ts +33 -52
  37. package/dist/node/messaging-client.js +180 -184
  38. package/dist/node/participant.d.ts +5 -3
  39. package/dist/node/participant.js +9 -1
  40. package/dist/node/room-client.js +2 -0
  41. package/dist/node/room-event.d.ts +6 -2
  42. package/dist/node/room-event.js +4 -2
  43. package/dist/node/secrets-client.d.ts +86 -16
  44. package/dist/node/secrets-client.js +243 -44
  45. package/dist/node/storage-client.d.ts +17 -4
  46. package/dist/node/storage-client.js +104 -16
  47. package/package.json +1 -1
@@ -1,11 +1,9 @@
1
- import { v4 as uuidV4 } from "uuid";
2
1
  import { EventEmitter } from "./event-emitter";
2
+ import { Completer } from "./completer";
3
3
  import { RemoteParticipant } from "./participant";
4
4
  import { RoomMessage, RoomMessageEvent } from "./room-event";
5
5
  import { RoomServerException } from "./room-server-client";
6
6
  import { splitMessageHeader, splitMessagePayload } from "./utils";
7
- import { StreamController } from "./stream-controller";
8
- import { Completer } from "./completer";
9
7
  const globalScope = globalThis;
10
8
  function bytesToBase64(bytes) {
11
9
  if (globalScope.Buffer) {
@@ -20,20 +18,18 @@ function bytesToBase64(bytes) {
20
18
  }
21
19
  return globalScope.btoa(binary);
22
20
  }
23
- export class MessageStreamChunk {
24
- constructor({ header, data }) {
25
- this.header = header;
26
- this.data = data;
27
- }
28
- }
29
21
  export class MessagingClient extends EventEmitter {
30
22
  constructor({ room }) {
31
23
  super();
32
- this._streamWriters = {};
33
- this._streamReaders = {};
24
+ this._messageHandler = this._handleMessageSend.bind(this);
34
25
  this._participants = {};
26
+ this._messageQueue = [];
27
+ this._messageQueued = null;
28
+ this._sendTask = null;
29
+ this._messageQueueClosed = false;
30
+ this._enabled = false;
35
31
  this.client = room;
36
- this.client.protocol.addHandler("messaging.send", this._handleMessageSend.bind(this));
32
+ this.client.protocol.addHandler("messaging.send", this._messageHandler);
37
33
  }
38
34
  _messageInput(params) {
39
35
  const input = {
@@ -48,6 +44,16 @@ export class MessagingClient extends EventEmitter {
48
44
  }
49
45
  return input;
50
46
  }
47
+ _syntheticMessageEvent(params) {
48
+ return new RoomMessageEvent({
49
+ message: new RoomMessage({
50
+ fromParticipantId: params.fromParticipantId,
51
+ type: params.type,
52
+ message: params.message,
53
+ local: true,
54
+ }),
55
+ });
56
+ }
51
57
  _removeParticipant(participantId) {
52
58
  const participant = this._participants[participantId];
53
59
  if (participant === undefined) {
@@ -55,15 +61,24 @@ export class MessagingClient extends EventEmitter {
55
61
  }
56
62
  participant._setOnline(false);
57
63
  delete this._participants[participantId];
58
- for (const [streamId, reader] of Object.entries(this._streamReaders)) {
59
- if (reader._to.id !== participant.id) {
60
- continue;
61
- }
62
- reader._controller.close();
63
- delete this._streamReaders[streamId];
64
- }
65
64
  return participant;
66
65
  }
66
+ _markParticipantOffline(participant) {
67
+ if (!(participant instanceof RemoteParticipant)) {
68
+ return;
69
+ }
70
+ participant._setOnline(false);
71
+ const current = this._participants[participant.id];
72
+ if (current === undefined) {
73
+ return;
74
+ }
75
+ this._removeParticipant(participant.id);
76
+ this.emit("participant_removed", this._syntheticMessageEvent({
77
+ fromParticipantId: participant.id,
78
+ type: "participant.disabled",
79
+ message: { id: participant.id },
80
+ }));
81
+ }
67
82
  _resolveMessageRecipient(to) {
68
83
  if (!(to instanceof RemoteParticipant)) {
69
84
  return to;
@@ -73,46 +88,131 @@ export class MessagingClient extends EventEmitter {
73
88
  }
74
89
  return this._participants[to.id] ?? null;
75
90
  }
76
- _participantNotFound(ignoreOffline) {
77
- if (ignoreOffline) {
78
- return null;
91
+ _queueMessage(message) {
92
+ if (this._sendTask === null) {
93
+ throw new RoomServerException("Cannot send messages because messaging has not been started");
94
+ }
95
+ this._messageQueue.push(message);
96
+ const waiter = this._messageQueued;
97
+ if (waiter !== null) {
98
+ this._messageQueued = null;
99
+ waiter.complete();
100
+ }
101
+ }
102
+ _rejectQueuedMessages(error) {
103
+ while (this._messageQueue.length > 0) {
104
+ const message = this._messageQueue.shift();
105
+ message?.completer?.completeError(error);
106
+ }
107
+ }
108
+ _isParticipantNotFound(error) {
109
+ return error instanceof RoomServerException && error.message === "the participant was not found";
110
+ }
111
+ async _nextQueuedMessage() {
112
+ while (this._messageQueue.length === 0) {
113
+ if (this._messageQueueClosed) {
114
+ return null;
115
+ }
116
+ if (this._messageQueued === null) {
117
+ this._messageQueued = new Completer();
118
+ }
119
+ await this._messageQueued.fut;
120
+ }
121
+ return this._messageQueue.shift() ?? null;
122
+ }
123
+ async _sendMessages() {
124
+ while (true) {
125
+ const queued = await this._nextQueuedMessage();
126
+ if (queued === null) {
127
+ return;
128
+ }
129
+ const resolvedTo = this._resolveMessageRecipient(queued.to);
130
+ if (resolvedTo === null) {
131
+ const error = new RoomServerException("the participant was not found");
132
+ if (queued.dropIfOffline) {
133
+ queued.completer?.complete();
134
+ }
135
+ else {
136
+ queued.completer?.completeError(error);
137
+ }
138
+ continue;
139
+ }
140
+ try {
141
+ await this.client.invoke({
142
+ toolkit: "messaging",
143
+ tool: "send",
144
+ input: this._messageInput({
145
+ toParticipantId: resolvedTo.id,
146
+ type: queued.type,
147
+ message: queued.message,
148
+ attachment: queued.attachment,
149
+ }),
150
+ });
151
+ queued.completer?.complete();
152
+ }
153
+ catch (error) {
154
+ if (this._isParticipantNotFound(error)) {
155
+ this._markParticipantOffline(queued.to);
156
+ if (queued.dropIfOffline) {
157
+ queued.completer?.complete();
158
+ continue;
159
+ }
160
+ }
161
+ queued.completer?.completeError(error);
162
+ }
79
163
  }
80
- throw new RoomServerException("the participant was not found");
81
164
  }
82
- async createStream({ to, header }) {
83
- const streamId = uuidV4();
165
+ async start() {
166
+ if (this._sendTask !== null) {
167
+ return;
168
+ }
169
+ this._messageQueueClosed = false;
170
+ this._sendTask = this._sendMessages();
171
+ }
172
+ async stop() {
173
+ if (this._sendTask === null) {
174
+ this._enabled = false;
175
+ return;
176
+ }
177
+ this._messageQueueClosed = true;
178
+ const waiter = this._messageQueued;
179
+ if (waiter !== null) {
180
+ this._messageQueued = null;
181
+ waiter.complete();
182
+ }
183
+ const sendTask = this._sendTask;
184
+ this._sendTask = null;
185
+ await sendTask;
186
+ this._enabled = false;
187
+ }
188
+ async sendMessage({ to, type, message, attachment, ignoreOffline = false }) {
84
189
  const completer = new Completer();
85
- this._streamWriters[streamId] = completer;
86
- await this.sendMessage({
190
+ this._queueMessage({
87
191
  to,
88
- type: "stream.open",
89
- message: { stream_id: streamId, header },
192
+ type,
193
+ message,
194
+ attachment,
195
+ dropIfOffline: ignoreOffline,
196
+ completer,
90
197
  });
91
- return completer.fut;
198
+ await completer.fut;
92
199
  }
93
- async sendMessage({ to, type, message, attachment, ignoreOffline = false }) {
94
- const resolvedTo = this._resolveMessageRecipient(to) ?? this._participantNotFound(ignoreOffline);
95
- if (resolvedTo === null) {
96
- return;
97
- }
98
- await this.client.invoke({
99
- toolkit: "messaging",
100
- tool: "send",
101
- input: this._messageInput({
102
- toParticipantId: resolvedTo.id,
103
- type,
104
- message,
105
- attachment,
106
- }),
200
+ sendMessageNowait({ to, type, message, attachment }) {
201
+ this._queueMessage({
202
+ to,
203
+ type,
204
+ message,
205
+ attachment,
206
+ dropIfOffline: true,
107
207
  });
108
208
  }
109
- async enable(onStreamAccept) {
209
+ async enable() {
110
210
  await this.client.invoke({
111
211
  toolkit: "messaging",
112
212
  tool: "enable",
113
213
  input: {},
114
214
  });
115
- this._onStreamAcceptCallback = onStreamAccept;
215
+ this._enabled = true;
116
216
  }
117
217
  async disable() {
118
218
  await this.client.invoke({
@@ -120,6 +220,7 @@ export class MessagingClient extends EventEmitter {
120
220
  tool: "disable",
121
221
  input: {},
122
222
  });
223
+ this._enabled = false;
123
224
  }
124
225
  async broadcastMessage({ type, message, attachment }) {
125
226
  await this.client.invoke({
@@ -131,6 +232,23 @@ export class MessagingClient extends EventEmitter {
131
232
  get remoteParticipants() {
132
233
  return Object.values(this._participants);
133
234
  }
235
+ get isEnabled() {
236
+ return this._enabled;
237
+ }
238
+ getParticipants() {
239
+ return this.remoteParticipants;
240
+ }
241
+ getParticipant(id) {
242
+ return this._participants[id] ?? null;
243
+ }
244
+ getParticipantByName(name) {
245
+ for (const participant of this.remoteParticipants) {
246
+ if (participant.getAttribute("name") === name) {
247
+ return participant;
248
+ }
249
+ }
250
+ return null;
251
+ }
134
252
  async _handleMessageSend(protocol, messageId, type, bytes) {
135
253
  const headerStr = splitMessageHeader(bytes || new Uint8Array());
136
254
  const payload = splitMessagePayload(bytes || new Uint8Array());
@@ -154,21 +272,6 @@ export class MessagingClient extends EventEmitter {
154
272
  case "participant.disabled":
155
273
  this._onParticipantDisabled(message);
156
274
  break;
157
- case "stream.open":
158
- this._onStreamOpen(message);
159
- break;
160
- case "stream.accept":
161
- this._onStreamAccept(message);
162
- break;
163
- case "stream.reject":
164
- this._onStreamReject(message);
165
- break;
166
- case "stream.chunk":
167
- this._onStreamChunk(message);
168
- break;
169
- case "stream.close":
170
- this._onStreamClose(message);
171
- break;
172
275
  }
173
276
  const messageEvent = new RoomMessageEvent({ message });
174
277
  this.client.emit(messageEvent);
@@ -177,20 +280,17 @@ export class MessagingClient extends EventEmitter {
177
280
  _onParticipantEnabled(message) {
178
281
  const data = message.message;
179
282
  const p = new RemoteParticipant(this.client, data["id"], data["role"], true);
180
- for (const [k, v] of Object.entries(data["attributes"] || {})) {
181
- p._attributes[k] = v;
182
- }
283
+ p._setAttributes(data["attributes"] ?? {});
183
284
  this._participants[data["id"]] = p;
184
285
  this.emit("participant_added", { message });
185
286
  }
186
287
  _onParticipantAttributes(message) {
187
288
  const part = this._participants[message.fromParticipantId];
188
- if (!part)
289
+ if (!part) {
189
290
  return;
190
- const attrObj = message.message["attributes"];
191
- for (const [k, v] of Object.entries(attrObj)) {
192
- part._attributes[k] = v;
193
291
  }
292
+ const attrObj = message.message["attributes"];
293
+ part._setAttributes(attrObj);
194
294
  this.emit("participant_attributes_updated", { message });
195
295
  }
196
296
  _onParticipantDisabled(message) {
@@ -203,124 +303,23 @@ export class MessagingClient extends EventEmitter {
203
303
  const participants = message.message["participants"];
204
304
  for (const data of participants) {
205
305
  const rp = new RemoteParticipant(this.client, data["id"], data["role"], true);
206
- for (const [k, v] of Object.entries(data["attributes"] || {})) {
207
- rp._attributes[k] = v;
208
- }
306
+ rp._setAttributes(data["attributes"] ?? {});
209
307
  this._participants[data["id"]] = rp;
210
308
  }
309
+ this._enabled = true;
211
310
  this.emit("messaging_enabled", { message });
212
311
  }
213
- _onStreamOpen(message) {
214
- const from = [...this.remoteParticipants]
215
- .find((x) => x.id === message.fromParticipantId);
216
- if (!from)
217
- return;
218
- const streamId = message.message["stream_id"];
219
- const controller = new StreamController();
220
- const reader = new MessageStreamReader({
221
- streamId,
222
- to: from,
223
- client: this,
224
- controller,
225
- });
226
- try {
227
- if (!this._onStreamAcceptCallback) {
228
- throw new Error("streams are not allowed by this client");
229
- }
230
- this._onStreamAcceptCallback(reader);
231
- void this.sendMessage({
232
- to: from,
233
- type: "stream.accept",
234
- message: { stream_id: streamId },
235
- ignoreOffline: true,
236
- }).catch((error) => {
237
- console.warn("unable to send stream response", error);
238
- });
239
- }
240
- catch (e) {
241
- void this.sendMessage({
242
- to: from,
243
- type: "stream.reject",
244
- message: { stream_id: streamId, error: String(e) },
245
- ignoreOffline: true,
246
- }).catch((error) => {
247
- console.warn("unable to send stream response", error);
248
- });
249
- }
250
- this._streamReaders[streamId] = reader;
251
- this.emit("stream_opened", { message });
252
- }
253
- _onStreamAccept(message) {
254
- const streamId = message.message["stream_id"];
255
- const writerCompleter = this._streamWriters[streamId];
256
- if (!writerCompleter)
257
- return;
258
- const from = [...this.remoteParticipants].find((x) => x.id === message.fromParticipantId);
259
- if (!from)
260
- return;
261
- writerCompleter.complete(new MessageStreamWriter({
262
- streamId,
263
- to: from,
264
- client: this,
265
- }));
266
- }
267
- _onStreamReject(message) {
268
- const streamId = message.message["stream_id"];
269
- const writerCompleter = this._streamWriters[streamId];
270
- if (!writerCompleter)
271
- return;
272
- writerCompleter.completeError(new Error("The stream was rejected by the remote client"));
273
- }
274
- _onStreamChunk(message) {
275
- const streamId = message.message["stream_id"];
276
- const reader = this._streamReaders[streamId];
277
- if (!reader)
278
- return;
279
- reader._controller.add(new MessageStreamChunk({
280
- header: message.message,
281
- data: message.attachment,
282
- }));
283
- }
284
- _onStreamClose(message) {
285
- const streamId = message.message["stream_id"];
286
- const reader = this._streamReaders[streamId];
287
- if (!reader)
288
- return;
289
- reader._controller.close();
290
- delete this._streamReaders[streamId];
291
- }
292
312
  dispose() {
313
+ const error = new RoomServerException("messaging client disposed");
314
+ this._messageQueueClosed = true;
315
+ this._enabled = false;
316
+ this._rejectQueuedMessages(error);
317
+ const waiter = this._messageQueued;
318
+ if (waiter !== null) {
319
+ this._messageQueued = null;
320
+ waiter.complete();
321
+ }
293
322
  super.dispose();
294
323
  this.client.protocol.removeHandler("messaging.send");
295
324
  }
296
325
  }
297
- export class MessageStreamWriter {
298
- constructor({ streamId, to, client }) {
299
- this._streamId = streamId;
300
- this._to = to;
301
- this._client = client;
302
- }
303
- async write(chunk) {
304
- await this._client.sendMessage({
305
- to: this._to,
306
- type: "stream.chunk",
307
- message: { stream_id: this._streamId, header: chunk.header },
308
- attachment: chunk.data,
309
- });
310
- }
311
- async close() {
312
- await this._client.sendMessage({
313
- to: this._to,
314
- type: "stream.close",
315
- message: { stream_id: this._streamId },
316
- });
317
- }
318
- }
319
- export class MessageStreamReader {
320
- constructor({ streamId, to, client, controller }) {
321
- this._streamId = streamId;
322
- this._to = to;
323
- this._client = client;
324
- this._controller = controller;
325
- }
326
- }
@@ -2,11 +2,13 @@ import { RoomClient } from "./room-client";
2
2
  export declare abstract class Participant {
3
3
  readonly id: string;
4
4
  protected readonly client: RoomClient;
5
- protected _attributes: Record<string, any>;
5
+ protected _attributes: Record<string, unknown>;
6
6
  protected _connections: string[];
7
7
  constructor(client: RoomClient, id: string);
8
8
  get connections(): ReadonlyArray<string>;
9
- getAttribute(name: string): any;
9
+ getAttribute(name: string): unknown;
10
+ _setAttribute(name: string, value: unknown): void;
11
+ _setAttributes(attributes: Record<string, unknown>): void;
10
12
  }
11
13
  export declare class RemoteParticipant extends Participant {
12
14
  readonly role: string;
@@ -16,5 +18,5 @@ export declare class RemoteParticipant extends Participant {
16
18
  }
17
19
  export declare class LocalParticipant extends Participant {
18
20
  constructor(client: RoomClient, id: string);
19
- setAttribute(name: string, value: any): Promise<void>;
21
+ setAttribute(name: string, value: unknown): Promise<void>;
20
22
  }
@@ -12,6 +12,14 @@ export class Participant {
12
12
  getAttribute(name) {
13
13
  return this._attributes[name];
14
14
  }
15
+ _setAttribute(name, value) {
16
+ this._attributes[name] = value;
17
+ }
18
+ _setAttributes(attributes) {
19
+ for (const [name, value] of Object.entries(attributes)) {
20
+ this._setAttribute(name, value);
21
+ }
22
+ }
15
23
  }
16
24
  export class RemoteParticipant extends Participant {
17
25
  constructor(client, id, role, online) {
@@ -28,7 +36,7 @@ export class LocalParticipant extends Participant {
28
36
  super(client, id);
29
37
  }
30
38
  async setAttribute(name, value) {
31
- this._attributes[name] = value;
39
+ this._setAttribute(name, value);
32
40
  try {
33
41
  const payload = packMessage({ [name]: value });
34
42
  await this.client.protocol.send("set_attributes", payload);
@@ -46,6 +46,7 @@ export class RoomClient {
46
46
  return this._ready.fut;
47
47
  }
48
48
  async start({ onDone, onError } = {}) {
49
+ await this.messaging.start();
49
50
  this.sync.start({ onDone, onError });
50
51
  await this.ready;
51
52
  }
@@ -55,6 +56,7 @@ export class RoomClient {
55
56
  pr?.reject(new Error("Disposed"));
56
57
  this._pendingRequests.delete(prKey);
57
58
  }
59
+ this.messaging.dispose();
58
60
  this.sync.dispose();
59
61
  for (const stream of this._toolCallStreams.values()) {
60
62
  stream.close();
@@ -34,16 +34,20 @@ export declare class FileCreatedEvent extends RoomEvent {
34
34
  }
35
35
  export declare class FileDeletedEvent extends RoomEvent {
36
36
  path: string;
37
- constructor({ path }: {
37
+ participantId: string;
38
+ constructor({ path, participantId }: {
38
39
  path: string;
40
+ participantId: string;
39
41
  });
40
42
  get name(): string;
41
43
  get description(): string;
42
44
  }
43
45
  export declare class FileUpdatedEvent extends RoomEvent {
44
46
  path: string;
45
- constructor({ path }: {
47
+ participantId: string;
48
+ constructor({ path, participantId }: {
46
49
  path: string;
50
+ participantId: string;
47
51
  });
48
52
  get name(): string;
49
53
  get description(): string;
@@ -34,9 +34,10 @@ export class FileCreatedEvent extends RoomEvent {
34
34
  }
35
35
  }
36
36
  export class FileDeletedEvent extends RoomEvent {
37
- constructor({ path }) {
37
+ constructor({ path, participantId }) {
38
38
  super();
39
39
  this.path = path;
40
+ this.participantId = participantId;
40
41
  }
41
42
  get name() {
42
43
  return "file deleted";
@@ -46,9 +47,10 @@ export class FileDeletedEvent extends RoomEvent {
46
47
  }
47
48
  }
48
49
  export class FileUpdatedEvent extends RoomEvent {
49
- constructor({ path }) {
50
+ constructor({ path, participantId }) {
50
51
  super();
51
52
  this.path = path;
53
+ this.participantId = participantId;
52
54
  }
53
55
  get name() {
54
56
  return "file updated";
@@ -1,37 +1,107 @@
1
- import { RoomClient } from "./room-client";
1
+ import type { ConnectorRef, OAuthClientConfig } from "./meshagent-client";
2
2
  import { FileContent } from "./response";
3
+ import { RoomClient } from "./room-client";
3
4
  export interface SecretInfo {
4
5
  id: string;
5
6
  name: string;
6
- type?: string;
7
+ type: string;
7
8
  delegatedTo?: string | null;
8
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;
9
26
  export declare class SecretsClient {
10
- private client;
11
- constructor({ room }: {
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, }: {
12
33
  room: RoomClient;
34
+ oauthTokenRequestHandler?: OAuthTokenRequestHandler;
35
+ secretRequestHandler?: SecretRequestHandler;
13
36
  });
14
37
  private unexpectedResponse;
15
- setSecret({ secretId, data, mimeType, name, delegatedTo, forIdentity, }: {
16
- secretId: string;
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;
17
55
  data: Uint8Array;
18
- mimeType?: string;
19
- name?: string;
20
- delegatedTo?: string;
21
- forIdentity?: string;
22
56
  }): Promise<void>;
23
- getSecret({ secretId, delegatedTo, }: {
24
- secretId: string;
25
- delegatedTo?: string;
26
- }): Promise<FileContent | null>;
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>;
27
75
  listSecrets(): Promise<SecretInfo[]>;
28
76
  deleteSecret({ secretId, delegatedTo, }: {
29
77
  secretId: string;
30
- delegatedTo?: string;
78
+ delegatedTo?: string | null;
31
79
  }): Promise<void>;
32
80
  deleteRequestedSecret({ url, type, delegatedTo, }: {
33
81
  url: string;
34
82
  type: string;
35
- delegatedTo?: string;
83
+ delegatedTo?: string | null;
36
84
  }): Promise<void>;
85
+ requestSecret({ fromParticipantId, url, type, timeout, delegateTo, }: {
86
+ fromParticipantId: string;
87
+ url: string;
88
+ type: string;
89
+ timeout?: number;
90
+ delegateTo?: string | null;
91
+ }): Promise<Uint8Array>;
92
+ setSecret({ secretId, type, mimeType, name, delegatedTo, forIdentity, data, }: {
93
+ secretId?: string | null;
94
+ type?: string | null;
95
+ mimeType?: string | null;
96
+ name?: string | null;
97
+ delegatedTo?: string | null;
98
+ forIdentity?: string | null;
99
+ data: Uint8Array;
100
+ }): Promise<void>;
101
+ getSecret({ secretId, type, name, delegatedTo, }: {
102
+ secretId?: string | null;
103
+ type?: string | null;
104
+ name?: string | null;
105
+ delegatedTo?: string | null;
106
+ }): Promise<FileContent | null>;
37
107
  }