@meshagent/meshagent 0.34.0 → 0.35.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.
@@ -226,6 +226,29 @@ export interface KeysSecret extends BaseSecret {
226
226
  data: Record<string, string>;
227
227
  }
228
228
  export type SecretLike = PullSecret | KeysSecret;
229
+ export interface ManagedSecretInfo {
230
+ id: string;
231
+ type: string;
232
+ name: string;
233
+ delegatedTo?: string | null;
234
+ }
235
+ export interface ManagedSecret extends ManagedSecretInfo {
236
+ dataBase64: string;
237
+ data: Uint8Array;
238
+ }
239
+ export interface ConnectorRef {
240
+ openaiConnectorId?: string | null;
241
+ serverUrl?: string | null;
242
+ clientSecretId?: string | null;
243
+ }
244
+ export interface ExternalOAuthClientRegistration {
245
+ id: string;
246
+ delegatedTo: string;
247
+ connector?: ConnectorRef | null;
248
+ oauth?: OAuthClientConfig | null;
249
+ clientId: string;
250
+ clientSecret?: string | null;
251
+ }
229
252
  export declare class Meshagent {
230
253
  private readonly baseUrl;
231
254
  private readonly token?;
@@ -245,7 +268,13 @@ export declare class Meshagent {
245
268
  private parseBalance;
246
269
  private parseTransaction;
247
270
  private parseSecret;
271
+ private parseManagedSecretInfo;
272
+ private parseManagedSecret;
273
+ private parseSecretPayload;
248
274
  private toSecretPayload;
275
+ private parseConnectorRef;
276
+ private serializeConnectorRef;
277
+ private parseExternalOAuthClientRegistration;
249
278
  private parseOAuthClient;
250
279
  private parseRoomConnectionInfo;
251
280
  private encodePathComponent;
@@ -359,10 +388,121 @@ export declare class Meshagent {
359
388
  getService(projectId: string, serviceId: string): Promise<ServiceSpec>;
360
389
  listServices(projectId: string): Promise<ServiceSpec[]>;
361
390
  deleteService(projectId: string, serviceId: string): Promise<void>;
391
+ createProjectSecret(params: {
392
+ projectId: string;
393
+ name: string;
394
+ type: string;
395
+ data: Uint8Array | ArrayBuffer | Buffer;
396
+ }): Promise<string>;
397
+ updateProjectSecret(params: {
398
+ projectId: string;
399
+ secretId: string;
400
+ name: string;
401
+ type: string;
402
+ data: Uint8Array | ArrayBuffer | Buffer;
403
+ }): Promise<void>;
404
+ getProjectSecret(projectId: string, secretId: string): Promise<ManagedSecret>;
405
+ listProjectSecrets(projectId: string): Promise<ManagedSecretInfo[]>;
406
+ deleteProjectSecret(projectId: string, secretId: string): Promise<void>;
407
+ createRoomSecret(params: {
408
+ projectId: string;
409
+ roomName: string;
410
+ data: Uint8Array | ArrayBuffer | Buffer;
411
+ secretId?: string;
412
+ name?: string;
413
+ type?: string;
414
+ delegatedTo?: string;
415
+ forIdentity?: string;
416
+ }): Promise<string>;
417
+ updateRoomSecret(params: {
418
+ projectId: string;
419
+ roomName: string;
420
+ secretId: string;
421
+ data: Uint8Array | ArrayBuffer | Buffer;
422
+ name?: string;
423
+ type?: string;
424
+ delegatedTo?: string;
425
+ forIdentity?: string;
426
+ }): Promise<void>;
427
+ getRoomSecret(params: {
428
+ projectId: string;
429
+ roomName: string;
430
+ secretId: string;
431
+ delegatedTo?: string;
432
+ forIdentity?: string;
433
+ }): Promise<ManagedSecret>;
434
+ listRoomSecrets(params: {
435
+ projectId: string;
436
+ roomName: string;
437
+ forIdentity?: string;
438
+ }): Promise<ManagedSecretInfo[]>;
439
+ deleteRoomSecret(params: {
440
+ projectId: string;
441
+ roomName: string;
442
+ secretId: string;
443
+ delegatedTo?: string;
444
+ forIdentity?: string;
445
+ }): Promise<void>;
362
446
  createSecret(projectId: string, secret: SecretLike): Promise<void>;
363
447
  updateSecret(projectId: string, secret: SecretLike): Promise<void>;
364
448
  deleteSecret(projectId: string, secretId: string): Promise<void>;
365
449
  listSecrets(projectId: string): Promise<SecretLike[]>;
450
+ createProjectExternalOAuthRegistration(params: {
451
+ projectId: string;
452
+ oauth: OAuthClientConfig;
453
+ clientId: string;
454
+ clientSecret?: string | null;
455
+ delegatedTo?: string | null;
456
+ connector?: ConnectorRef | null;
457
+ }): Promise<string>;
458
+ updateProjectExternalOAuthRegistration(params: {
459
+ projectId: string;
460
+ registrationId: string;
461
+ oauth: OAuthClientConfig;
462
+ clientId: string;
463
+ clientSecret?: string | null;
464
+ delegatedTo?: string | null;
465
+ connector?: ConnectorRef | null;
466
+ }): Promise<void>;
467
+ listProjectExternalOAuthRegistrations(params: {
468
+ projectId: string;
469
+ delegatedTo?: string | null;
470
+ }): Promise<ExternalOAuthClientRegistration[]>;
471
+ deleteProjectExternalOAuthRegistration(params: {
472
+ projectId: string;
473
+ registrationId: string;
474
+ delegatedTo?: string | null;
475
+ }): Promise<void>;
476
+ createRoomExternalOAuthRegistration(params: {
477
+ projectId: string;
478
+ roomName: string;
479
+ oauth: OAuthClientConfig;
480
+ clientId: string;
481
+ clientSecret?: string | null;
482
+ delegatedTo?: string | null;
483
+ connector?: ConnectorRef | null;
484
+ }): Promise<string>;
485
+ updateRoomExternalOAuthRegistration(params: {
486
+ projectId: string;
487
+ roomName: string;
488
+ registrationId: string;
489
+ oauth: OAuthClientConfig;
490
+ clientId: string;
491
+ clientSecret?: string | null;
492
+ delegatedTo?: string | null;
493
+ connector?: ConnectorRef | null;
494
+ }): Promise<void>;
495
+ listRoomExternalOAuthRegistrations(params: {
496
+ projectId: string;
497
+ roomName: string;
498
+ delegatedTo?: string | null;
499
+ }): Promise<ExternalOAuthClientRegistration[]>;
500
+ deleteRoomExternalOAuthRegistration(params: {
501
+ projectId: string;
502
+ roomName: string;
503
+ registrationId: string;
504
+ delegatedTo?: string | null;
505
+ }): Promise<void>;
366
506
  createRoom(params: {
367
507
  projectId: string;
368
508
  name: string;
@@ -4,6 +4,7 @@ exports.Meshagent = void 0;
4
4
  const helpers_1 = require("./helpers");
5
5
  const requirement_1 = require("./requirement");
6
6
  const participant_token_1 = require("./participant-token");
7
+ const utils_1 = require("./utils");
7
8
  function pruneUndefinedValues(value) {
8
9
  if (Array.isArray(value)) {
9
10
  const prunedItems = value
@@ -44,6 +45,40 @@ function serializeServiceSpec(service) {
44
45
  agents,
45
46
  });
46
47
  }
48
+ const globalScope = globalThis;
49
+ function bytesToBase64(bytes) {
50
+ if (globalScope.Buffer) {
51
+ return globalScope.Buffer.from(bytes).toString("base64");
52
+ }
53
+ if (!globalScope.btoa) {
54
+ throw new Error("base64 encoding is not available in this runtime");
55
+ }
56
+ let binary = "";
57
+ for (const byte of bytes) {
58
+ binary += String.fromCharCode(byte);
59
+ }
60
+ return globalScope.btoa(binary);
61
+ }
62
+ function base64ToBytes(base64) {
63
+ if (globalScope.Buffer) {
64
+ return Uint8Array.from(globalScope.Buffer.from(base64, "base64"));
65
+ }
66
+ if (!globalScope.atob) {
67
+ throw new Error("base64 decoding is not available in this runtime");
68
+ }
69
+ const binary = globalScope.atob(base64);
70
+ const bytes = new Uint8Array(binary.length);
71
+ for (let index = 0; index < binary.length; index += 1) {
72
+ bytes[index] = binary.charCodeAt(index);
73
+ }
74
+ return bytes;
75
+ }
76
+ function normalizeBinary(data) {
77
+ if (data instanceof Uint8Array) {
78
+ return data;
79
+ }
80
+ return new Uint8Array(data);
81
+ }
47
82
  class Meshagent {
48
83
  constructor({ baseUrl, token } = {}) {
49
84
  const resolvedBaseUrl = (0, helpers_1.meshagentBaseUrl)(baseUrl).replace(/\/+$/, "");
@@ -327,6 +362,75 @@ class Meshagent {
327
362
  }
328
363
  throw new requirement_1.RoomException(`Unknown secret type: ${type}`);
329
364
  }
365
+ parseManagedSecretInfo(data) {
366
+ if (!data || typeof data !== "object") {
367
+ throw new requirement_1.RoomException("Invalid managed secret payload");
368
+ }
369
+ const { id, type, name, delegated_to: delegatedToRaw, delegatedTo } = data;
370
+ if (typeof id !== "string" || typeof type !== "string" || typeof name !== "string") {
371
+ throw new requirement_1.RoomException("Invalid managed secret payload: missing id, type, or name");
372
+ }
373
+ const delegatedToValue = typeof delegatedTo === "string"
374
+ ? delegatedTo
375
+ : typeof delegatedToRaw === "string"
376
+ ? delegatedToRaw
377
+ : null;
378
+ return {
379
+ id,
380
+ type,
381
+ name,
382
+ delegatedTo: delegatedToValue,
383
+ };
384
+ }
385
+ parseManagedSecret(data) {
386
+ const secret = this.parseManagedSecretInfo(data);
387
+ const dataBase64 = data.data_base64 ?? data.dataBase64;
388
+ if (typeof dataBase64 !== "string") {
389
+ throw new requirement_1.RoomException("Invalid managed secret payload: missing data_base64");
390
+ }
391
+ return {
392
+ ...secret,
393
+ dataBase64,
394
+ data: base64ToBytes(dataBase64),
395
+ };
396
+ }
397
+ parseSecretPayload(secret, rawData) {
398
+ let payload;
399
+ try {
400
+ payload = JSON.parse(utils_1.decoder.decode(rawData));
401
+ }
402
+ catch {
403
+ throw new requirement_1.RoomException(`Invalid secret payload for ${secret.id}`);
404
+ }
405
+ if (!payload || typeof payload !== "object" || Array.isArray(payload)) {
406
+ throw new requirement_1.RoomException(`Invalid secret payload for ${secret.id}`);
407
+ }
408
+ if (secret.type === "docker") {
409
+ const { server, username, password, email } = payload;
410
+ if (typeof server !== "string" || typeof username !== "string" || typeof password !== "string") {
411
+ throw new requirement_1.RoomException(`Invalid secret payload for ${secret.id}`);
412
+ }
413
+ return {
414
+ id: secret.id,
415
+ name: secret.name,
416
+ type: "docker",
417
+ server,
418
+ username,
419
+ password,
420
+ email: typeof email === "string" ? email : "none@example.com",
421
+ };
422
+ }
423
+ const entries = Object.entries(payload);
424
+ if (entries.some(([, value]) => typeof value !== "string")) {
425
+ throw new requirement_1.RoomException(`Invalid secret payload for ${secret.id}`);
426
+ }
427
+ return {
428
+ id: secret.id,
429
+ name: secret.name,
430
+ type: "keys",
431
+ data: Object.fromEntries(entries),
432
+ };
433
+ }
330
434
  toSecretPayload(secret) {
331
435
  if (secret.type === "docker") {
332
436
  return {
@@ -346,6 +450,68 @@ class Meshagent {
346
450
  data: { ...secret.data },
347
451
  };
348
452
  }
453
+ parseConnectorRef(data) {
454
+ if (data == null) {
455
+ return null;
456
+ }
457
+ if (typeof data !== "object") {
458
+ throw new requirement_1.RoomException("Invalid connector payload");
459
+ }
460
+ const { openai_connector_id: openaiConnectorIdRaw, openaiConnectorId, server_url: serverUrlRaw, serverUrl, client_secret_id: clientSecretIdRaw, clientSecretId, } = data;
461
+ return {
462
+ openaiConnectorId: typeof openaiConnectorId === "string"
463
+ ? openaiConnectorId
464
+ : typeof openaiConnectorIdRaw === "string"
465
+ ? openaiConnectorIdRaw
466
+ : null,
467
+ serverUrl: typeof serverUrl === "string"
468
+ ? serverUrl
469
+ : typeof serverUrlRaw === "string"
470
+ ? serverUrlRaw
471
+ : null,
472
+ clientSecretId: typeof clientSecretId === "string"
473
+ ? clientSecretId
474
+ : typeof clientSecretIdRaw === "string"
475
+ ? clientSecretIdRaw
476
+ : null,
477
+ };
478
+ }
479
+ serializeConnectorRef(connector) {
480
+ if (connector == null) {
481
+ return null;
482
+ }
483
+ const payload = {};
484
+ if (connector.openaiConnectorId) {
485
+ payload.openai_connector_id = connector.openaiConnectorId;
486
+ }
487
+ if (connector.serverUrl) {
488
+ payload.server_url = connector.serverUrl;
489
+ }
490
+ if (connector.clientSecretId) {
491
+ payload.client_secret_id = connector.clientSecretId;
492
+ }
493
+ return payload;
494
+ }
495
+ parseExternalOAuthClientRegistration(data) {
496
+ if (!data || typeof data !== "object") {
497
+ throw new requirement_1.RoomException("Invalid external oauth registration payload");
498
+ }
499
+ const { id, delegated_to: delegatedToRaw, delegatedTo, connector, oauth, client_id: clientIdRaw, clientId, client_secret: clientSecretRaw, clientSecret, } = data;
500
+ const delegatedToValue = typeof delegatedTo === "string" ? delegatedTo : delegatedToRaw;
501
+ const clientIdValue = typeof clientId === "string" ? clientId : clientIdRaw;
502
+ const clientSecretValue = typeof clientSecret === "string" ? clientSecret : clientSecretRaw;
503
+ if (typeof id !== "string" || typeof delegatedToValue !== "string" || typeof clientIdValue !== "string") {
504
+ throw new requirement_1.RoomException("Invalid external oauth registration payload: missing fields");
505
+ }
506
+ return {
507
+ id,
508
+ delegatedTo: delegatedToValue,
509
+ connector: this.parseConnectorRef(connector),
510
+ oauth: oauth && typeof oauth === "object" ? oauth : null,
511
+ clientId: clientIdValue,
512
+ clientSecret: typeof clientSecretValue === "string" ? clientSecretValue : null,
513
+ };
514
+ }
349
515
  parseOAuthClient(data) {
350
516
  if (!data || typeof data !== "object") {
351
517
  throw new requirement_1.RoomException("Invalid OAuth client payload");
@@ -824,38 +990,263 @@ class Meshagent {
824
990
  responseType: "void",
825
991
  });
826
992
  }
827
- async createSecret(projectId, secret) {
828
- await this.request(`/accounts/projects/${projectId}/secrets`, {
993
+ async createProjectSecret(params) {
994
+ const { projectId, name, type, data } = params;
995
+ const payload = await this.request(`/accounts/projects/${projectId}/secrets`, {
829
996
  method: "POST",
830
- json: this.toSecretPayload(secret),
831
- action: "create secret",
997
+ json: {
998
+ name,
999
+ type,
1000
+ data_base64: bytesToBase64(normalizeBinary(data)),
1001
+ },
1002
+ action: "create project secret",
1003
+ });
1004
+ if (!payload || typeof payload !== "object" || typeof payload.id !== "string") {
1005
+ throw new requirement_1.RoomException("Invalid create project secret response payload");
1006
+ }
1007
+ return payload.id;
1008
+ }
1009
+ async updateProjectSecret(params) {
1010
+ const { projectId, secretId, name, type, data } = params;
1011
+ await this.request(`/accounts/projects/${projectId}/secrets/${secretId}`, {
1012
+ method: "PUT",
1013
+ json: {
1014
+ name,
1015
+ type,
1016
+ data_base64: bytesToBase64(normalizeBinary(data)),
1017
+ },
1018
+ action: "update project secret",
832
1019
  responseType: "void",
833
1020
  });
834
1021
  }
1022
+ async getProjectSecret(projectId, secretId) {
1023
+ const data = await this.request(`/accounts/projects/${projectId}/secrets/${secretId}`, {
1024
+ action: "fetch project secret",
1025
+ });
1026
+ return this.parseManagedSecret(data);
1027
+ }
1028
+ async listProjectSecrets(projectId) {
1029
+ const data = await this.request(`/accounts/projects/${projectId}/secrets`, {
1030
+ action: "list project secrets",
1031
+ });
1032
+ const secrets = Array.isArray(data?.secrets) ? data.secrets : [];
1033
+ return secrets.map((item) => this.parseManagedSecretInfo(item));
1034
+ }
1035
+ async deleteProjectSecret(projectId, secretId) {
1036
+ await this.request(`/accounts/projects/${projectId}/secrets/${secretId}`, {
1037
+ method: "DELETE",
1038
+ action: "delete project secret",
1039
+ responseType: "void",
1040
+ });
1041
+ }
1042
+ async createRoomSecret(params) {
1043
+ const { projectId, roomName, data, secretId, name, type, delegatedTo, forIdentity } = params;
1044
+ const payload = await this.request(`/accounts/projects/${projectId}/rooms/${roomName}/secrets`, {
1045
+ method: "POST",
1046
+ json: {
1047
+ data_base64: bytesToBase64(normalizeBinary(data)),
1048
+ secret_id: secretId,
1049
+ name,
1050
+ type,
1051
+ delegated_to: delegatedTo,
1052
+ for_identity: forIdentity,
1053
+ },
1054
+ action: "create room secret",
1055
+ });
1056
+ if (!payload || typeof payload !== "object" || typeof payload.id !== "string") {
1057
+ throw new requirement_1.RoomException("Invalid create room secret response payload");
1058
+ }
1059
+ return payload.id;
1060
+ }
1061
+ async updateRoomSecret(params) {
1062
+ const { projectId, roomName, secretId, data, name, type, delegatedTo, forIdentity } = params;
1063
+ await this.request(`/accounts/projects/${projectId}/rooms/${roomName}/secrets/${secretId}`, {
1064
+ method: "PUT",
1065
+ json: {
1066
+ data_base64: bytesToBase64(normalizeBinary(data)),
1067
+ name,
1068
+ type,
1069
+ delegated_to: delegatedTo,
1070
+ for_identity: forIdentity,
1071
+ },
1072
+ action: "update room secret",
1073
+ responseType: "void",
1074
+ });
1075
+ }
1076
+ async getRoomSecret(params) {
1077
+ const { projectId, roomName, secretId, delegatedTo, forIdentity } = params;
1078
+ const data = await this.request(`/accounts/projects/${projectId}/rooms/${roomName}/secrets/${secretId}`, {
1079
+ query: {
1080
+ delegated_to: delegatedTo,
1081
+ for_identity: forIdentity,
1082
+ },
1083
+ action: "fetch room secret",
1084
+ });
1085
+ return this.parseManagedSecret(data);
1086
+ }
1087
+ async listRoomSecrets(params) {
1088
+ const { projectId, roomName, forIdentity } = params;
1089
+ const data = await this.request(`/accounts/projects/${projectId}/rooms/${roomName}/secrets`, {
1090
+ query: {
1091
+ for_identity: forIdentity,
1092
+ },
1093
+ action: "list room secrets",
1094
+ });
1095
+ const secrets = Array.isArray(data?.secrets) ? data.secrets : [];
1096
+ return secrets.map((item) => this.parseManagedSecretInfo(item));
1097
+ }
1098
+ async deleteRoomSecret(params) {
1099
+ const { projectId, roomName, secretId, delegatedTo, forIdentity } = params;
1100
+ await this.request(`/accounts/projects/${projectId}/rooms/${roomName}/secrets/${secretId}`, {
1101
+ method: "DELETE",
1102
+ query: {
1103
+ delegated_to: delegatedTo,
1104
+ for_identity: forIdentity,
1105
+ },
1106
+ action: "delete room secret",
1107
+ responseType: "void",
1108
+ });
1109
+ }
1110
+ async createSecret(projectId, secret) {
1111
+ await this.createProjectSecret({
1112
+ projectId,
1113
+ name: secret.name,
1114
+ type: secret.type,
1115
+ data: utils_1.encoder.encode(JSON.stringify(this.toSecretPayload(secret).data)),
1116
+ });
1117
+ }
835
1118
  async updateSecret(projectId, secret) {
836
1119
  if (!secret.id) {
837
1120
  throw new requirement_1.RoomException("Secret id is required to update a secret");
838
1121
  }
839
- await this.request(`/accounts/projects/${projectId}/secrets/${secret.id}`, {
1122
+ await this.updateProjectSecret({
1123
+ projectId,
1124
+ secretId: secret.id,
1125
+ name: secret.name,
1126
+ type: secret.type,
1127
+ data: utils_1.encoder.encode(JSON.stringify(this.toSecretPayload(secret).data)),
1128
+ });
1129
+ }
1130
+ async deleteSecret(projectId, secretId) {
1131
+ await this.deleteProjectSecret(projectId, secretId);
1132
+ }
1133
+ async listSecrets(projectId) {
1134
+ const secretInfos = await this.listProjectSecrets(projectId);
1135
+ const secrets = await Promise.all(secretInfos.map(async (secretInfo) => {
1136
+ const secret = await this.getProjectSecret(projectId, secretInfo.id);
1137
+ return this.parseSecretPayload(secret, secret.data);
1138
+ }));
1139
+ return secrets;
1140
+ }
1141
+ async createProjectExternalOAuthRegistration(params) {
1142
+ const { projectId, oauth, clientId, clientSecret, delegatedTo, connector } = params;
1143
+ const payload = await this.request(`/accounts/projects/${projectId}/external-oauth`, {
1144
+ method: "POST",
1145
+ json: {
1146
+ oauth,
1147
+ client_id: clientId,
1148
+ client_secret: clientSecret,
1149
+ delegated_to: delegatedTo,
1150
+ connector: this.serializeConnectorRef(connector),
1151
+ },
1152
+ action: "create project external oauth registration",
1153
+ });
1154
+ if (!payload || typeof payload !== "object" || typeof payload.id !== "string") {
1155
+ throw new requirement_1.RoomException("Invalid create project external oauth registration response payload");
1156
+ }
1157
+ return payload.id;
1158
+ }
1159
+ async updateProjectExternalOAuthRegistration(params) {
1160
+ const { projectId, registrationId, oauth, clientId, clientSecret, delegatedTo, connector } = params;
1161
+ await this.request(`/accounts/projects/${projectId}/external-oauth/${registrationId}`, {
840
1162
  method: "PUT",
841
- json: this.toSecretPayload(secret),
842
- action: "update secret",
1163
+ json: {
1164
+ oauth,
1165
+ client_id: clientId,
1166
+ client_secret: clientSecret,
1167
+ delegated_to: delegatedTo,
1168
+ connector: this.serializeConnectorRef(connector),
1169
+ },
1170
+ action: "update project external oauth registration",
843
1171
  responseType: "void",
844
1172
  });
845
1173
  }
846
- async deleteSecret(projectId, secretId) {
847
- await this.request(`/accounts/projects/${projectId}/secrets/${secretId}`, {
1174
+ async listProjectExternalOAuthRegistrations(params) {
1175
+ const { projectId, delegatedTo } = params;
1176
+ const data = await this.request(`/accounts/projects/${projectId}/external-oauth`, {
1177
+ query: {
1178
+ delegated_to: delegatedTo,
1179
+ },
1180
+ action: "list project external oauth registrations",
1181
+ });
1182
+ const registrations = Array.isArray(data?.registrations) ? data.registrations : [];
1183
+ return registrations.map((item) => this.parseExternalOAuthClientRegistration(item));
1184
+ }
1185
+ async deleteProjectExternalOAuthRegistration(params) {
1186
+ const { projectId, registrationId, delegatedTo } = params;
1187
+ await this.request(`/accounts/projects/${projectId}/external-oauth/${registrationId}`, {
848
1188
  method: "DELETE",
849
- action: "delete secret",
1189
+ query: {
1190
+ delegated_to: delegatedTo,
1191
+ },
1192
+ action: "delete project external oauth registration",
850
1193
  responseType: "void",
851
1194
  });
852
1195
  }
853
- async listSecrets(projectId) {
854
- const data = await this.request(`/accounts/projects/${projectId}/secrets`, {
855
- action: "list secrets",
1196
+ async createRoomExternalOAuthRegistration(params) {
1197
+ const { projectId, roomName, oauth, clientId, clientSecret, delegatedTo, connector } = params;
1198
+ const payload = await this.request(`/accounts/projects/${projectId}/rooms/${roomName}/external-oauth`, {
1199
+ method: "POST",
1200
+ json: {
1201
+ oauth,
1202
+ client_id: clientId,
1203
+ client_secret: clientSecret,
1204
+ delegated_to: delegatedTo,
1205
+ connector: this.serializeConnectorRef(connector),
1206
+ },
1207
+ action: "create room external oauth registration",
1208
+ });
1209
+ if (!payload || typeof payload !== "object" || typeof payload.id !== "string") {
1210
+ throw new requirement_1.RoomException("Invalid create room external oauth registration response payload");
1211
+ }
1212
+ return payload.id;
1213
+ }
1214
+ async updateRoomExternalOAuthRegistration(params) {
1215
+ const { projectId, roomName, registrationId, oauth, clientId, clientSecret, delegatedTo, connector } = params;
1216
+ await this.request(`/accounts/projects/${projectId}/rooms/${roomName}/external-oauth/${registrationId}`, {
1217
+ method: "PUT",
1218
+ json: {
1219
+ oauth,
1220
+ client_id: clientId,
1221
+ client_secret: clientSecret,
1222
+ delegated_to: delegatedTo,
1223
+ connector: this.serializeConnectorRef(connector),
1224
+ },
1225
+ action: "update room external oauth registration",
1226
+ responseType: "void",
1227
+ });
1228
+ }
1229
+ async listRoomExternalOAuthRegistrations(params) {
1230
+ const { projectId, roomName, delegatedTo } = params;
1231
+ const data = await this.request(`/accounts/projects/${projectId}/rooms/${roomName}/external-oauth`, {
1232
+ query: {
1233
+ delegated_to: delegatedTo,
1234
+ },
1235
+ action: "list room external oauth registrations",
1236
+ });
1237
+ const registrations = Array.isArray(data?.registrations) ? data.registrations : [];
1238
+ return registrations.map((item) => this.parseExternalOAuthClientRegistration(item));
1239
+ }
1240
+ async deleteRoomExternalOAuthRegistration(params) {
1241
+ const { projectId, roomName, registrationId, delegatedTo } = params;
1242
+ await this.request(`/accounts/projects/${projectId}/rooms/${roomName}/external-oauth/${registrationId}`, {
1243
+ method: "DELETE",
1244
+ query: {
1245
+ delegated_to: delegatedTo,
1246
+ },
1247
+ action: "delete room external oauth registration",
1248
+ responseType: "void",
856
1249
  });
857
- const secrets = Array.isArray(data?.secrets) ? data.secrets : [];
858
- return secrets.map((item) => this.parseSecret(item));
859
1250
  }
860
1251
  async createRoom(params) {
861
1252
  const { projectId, name, ifNotExists = false, metadata, annotations, permissions } = params;