@meshagent/meshagent 0.42.0 → 0.43.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/dist/browser/agent-client.d.ts +4 -4
- package/dist/browser/agent-client.js +16 -16
- package/dist/browser/agent.d.ts +6 -6
- package/dist/browser/agent.js +57 -57
- package/dist/browser/api_keys.js +7 -3
- package/dist/browser/containers-client.d.ts +21 -3
- package/dist/browser/containers-client.js +126 -78
- package/dist/browser/datasets-client.d.ts +1 -1
- package/dist/browser/datasets-client.js +83 -83
- package/dist/browser/developer-client.d.ts +3 -3
- package/dist/browser/developer-client.js +11 -11
- package/dist/browser/document.d.ts +2 -2
- package/dist/browser/document.js +3 -3
- package/dist/browser/helpers.d.ts +4 -4
- package/dist/browser/helpers.js +9 -9
- package/dist/browser/index.d.ts +35 -35
- package/dist/browser/index.js +35 -35
- package/dist/browser/memory-client.d.ts +1 -1
- package/dist/browser/memory-client.js +6 -6
- package/dist/browser/meshagent-client.d.ts +1 -1
- package/dist/browser/meshagent-client.js +78 -78
- package/dist/browser/messaging-client.d.ts +4 -4
- package/dist/browser/messaging-client.js +33 -33
- package/dist/browser/participant-token.d.ts +1 -1
- package/dist/browser/participant-token.js +5 -5
- package/dist/browser/participant.d.ts +1 -1
- package/dist/browser/protocol.d.ts +7 -4
- package/dist/browser/protocol.js +36 -20
- package/dist/browser/queues-client.d.ts +1 -1
- package/dist/browser/queues-client.js +10 -10
- package/dist/browser/response.js +11 -11
- package/dist/browser/room-client.d.ts +23 -17
- package/dist/browser/room-client.js +138 -130
- package/dist/browser/room-server-client.d.ts +2 -2
- package/dist/browser/room-server-client.js +10 -10
- package/dist/browser/secrets-client.d.ts +3 -3
- package/dist/browser/secrets-client.js +30 -30
- package/dist/browser/services-client.d.ts +2 -2
- package/dist/browser/services-client.js +8 -8
- package/dist/browser/storage-client.d.ts +5 -5
- package/dist/browser/storage-client.js +30 -30
- package/dist/browser/sync-client.d.ts +4 -4
- package/dist/browser/sync-client.js +38 -38
- package/dist/browser/toolkit-config.d.ts +3 -3
- package/dist/esm/agent-client.d.ts +4 -4
- package/dist/esm/agent-client.js +19 -25
- package/dist/esm/agent.d.ts +6 -6
- package/dist/esm/agent.js +73 -93
- package/dist/esm/api_keys.js +12 -21
- package/dist/esm/client.js +7 -13
- package/dist/esm/completer.js +1 -5
- package/dist/esm/containers-client.d.ts +21 -3
- package/dist/esm/containers-client.js +132 -89
- package/dist/esm/datasets-client.d.ts +1 -1
- package/dist/esm/datasets-client.js +101 -111
- package/dist/esm/developer-client.d.ts +3 -3
- package/dist/esm/developer-client.js +11 -15
- package/dist/esm/document.d.ts +2 -2
- package/dist/esm/document.js +11 -20
- package/dist/esm/entrypoint.js +1 -12
- package/dist/esm/event-emitter.js +1 -5
- package/dist/esm/helpers.d.ts +4 -4
- package/dist/esm/helpers.js +15 -23
- package/dist/esm/index.d.ts +35 -35
- package/dist/esm/index.js +35 -51
- package/dist/esm/memory-client.d.ts +1 -1
- package/dist/esm/memory-client.js +7 -11
- package/dist/esm/meshagent-client.d.ts +1 -1
- package/dist/esm/meshagent-client.js +79 -83
- package/dist/esm/messaging-client.d.ts +4 -4
- package/dist/esm/messaging-client.js +33 -37
- package/dist/esm/oauth-scopes.js +2 -5
- package/dist/esm/participant-token.d.ts +1 -1
- package/dist/esm/participant-token.js +34 -62
- package/dist/esm/participant.d.ts +1 -1
- package/dist/esm/participant.js +3 -9
- package/dist/esm/protocol.d.ts +7 -4
- package/dist/esm/protocol.js +48 -46
- package/dist/esm/queues-client.d.ts +1 -1
- package/dist/esm/queues-client.js +12 -17
- package/dist/esm/requirement.js +4 -11
- package/dist/esm/response.js +22 -34
- package/dist/esm/room-client.d.ts +23 -17
- package/dist/esm/room-client.js +140 -137
- package/dist/esm/room-event.js +9 -21
- package/dist/esm/room-server-client.d.ts +2 -2
- package/dist/esm/room-server-client.js +13 -18
- package/dist/esm/runtime.js +1 -10
- package/dist/esm/schema.js +9 -18
- package/dist/esm/secrets-client.d.ts +3 -3
- package/dist/esm/secrets-client.js +31 -35
- package/dist/esm/services-client.d.ts +2 -2
- package/dist/esm/services-client.js +9 -13
- package/dist/esm/storage-client.d.ts +5 -5
- package/dist/esm/storage-client.js +32 -38
- package/dist/esm/stream-controller.js +1 -5
- package/dist/esm/sync-client.d.ts +4 -4
- package/dist/esm/sync-client.js +38 -42
- package/dist/esm/tool-content-type.js +1 -5
- package/dist/esm/toolkit-config.d.ts +3 -3
- package/dist/esm/toolkit-config.js +5 -13
- package/dist/esm/utils.js +10 -20
- package/dist/esm/version.js +1 -4
- package/dist/node/agent-client.d.ts +4 -4
- package/dist/node/agent-client.js +16 -16
- package/dist/node/agent.d.ts +6 -6
- package/dist/node/agent.js +57 -57
- package/dist/node/api_keys.js +7 -3
- package/dist/node/containers-client.d.ts +21 -3
- package/dist/node/containers-client.js +126 -78
- package/dist/node/datasets-client.d.ts +1 -1
- package/dist/node/datasets-client.js +83 -83
- package/dist/node/developer-client.d.ts +3 -3
- package/dist/node/developer-client.js +11 -11
- package/dist/node/document.d.ts +2 -2
- package/dist/node/document.js +3 -3
- package/dist/node/helpers.d.ts +4 -4
- package/dist/node/helpers.js +9 -9
- package/dist/node/index.d.ts +35 -35
- package/dist/node/index.js +35 -35
- package/dist/node/memory-client.d.ts +1 -1
- package/dist/node/memory-client.js +6 -6
- package/dist/node/meshagent-client.d.ts +1 -1
- package/dist/node/meshagent-client.js +78 -78
- package/dist/node/messaging-client.d.ts +4 -4
- package/dist/node/messaging-client.js +33 -33
- package/dist/node/participant-token.d.ts +1 -1
- package/dist/node/participant-token.js +5 -5
- package/dist/node/participant.d.ts +1 -1
- package/dist/node/protocol.d.ts +7 -4
- package/dist/node/protocol.js +36 -20
- package/dist/node/queues-client.d.ts +1 -1
- package/dist/node/queues-client.js +10 -10
- package/dist/node/response.js +11 -11
- package/dist/node/room-client.d.ts +23 -17
- package/dist/node/room-client.js +138 -130
- package/dist/node/room-server-client.d.ts +2 -2
- package/dist/node/room-server-client.js +10 -10
- package/dist/node/secrets-client.d.ts +3 -3
- package/dist/node/secrets-client.js +30 -30
- package/dist/node/services-client.d.ts +2 -2
- package/dist/node/services-client.js +8 -8
- package/dist/node/storage-client.d.ts +5 -5
- package/dist/node/storage-client.js +30 -30
- package/dist/node/sync-client.d.ts +4 -4
- package/dist/node/sync-client.js +38 -38
- package/dist/node/toolkit-config.d.ts +3 -3
- package/package.json +11 -5
- package/dist/browser/lk-client.d.ts +0 -18
- package/dist/browser/lk-client.js +0 -33
- package/dist/browser/lk-protocol.d.ts +0 -22
- package/dist/browser/lk-protocol.js +0 -37
- package/dist/esm/lk-client.d.ts +0 -18
- package/dist/esm/lk-client.js +0 -33
- package/dist/esm/lk-protocol.d.ts +0 -22
- package/dist/esm/lk-protocol.js +0 -37
- package/dist/node/lk-client.d.ts +0 -18
- package/dist/node/lk-client.js +0 -33
- package/dist/node/lk-protocol.d.ts +0 -22
- package/dist/node/lk-protocol.js +0 -37
package/dist/esm/room-event.js
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RoomLogEvent = exports.FileMovedEvent = exports.FileUpdatedEvent = exports.FileDeletedEvent = exports.FileCreatedEvent = exports.RoomMessageEvent = exports.RoomMessage = exports.RoomStatusEvent = exports.RoomEvent = void 0;
|
|
4
|
-
class RoomEvent {
|
|
1
|
+
export class RoomEvent {
|
|
5
2
|
}
|
|
6
|
-
|
|
7
|
-
class RoomStatusEvent extends RoomEvent {
|
|
3
|
+
export class RoomStatusEvent extends RoomEvent {
|
|
8
4
|
constructor({ status, message }) {
|
|
9
5
|
super();
|
|
10
6
|
this.status = status;
|
|
@@ -23,8 +19,7 @@ class RoomStatusEvent extends RoomEvent {
|
|
|
23
19
|
});
|
|
24
20
|
}
|
|
25
21
|
}
|
|
26
|
-
|
|
27
|
-
class RoomMessage {
|
|
22
|
+
export class RoomMessage {
|
|
28
23
|
constructor({ fromParticipantId, type, message, local = false, attachment }) {
|
|
29
24
|
this.fromParticipantId = fromParticipantId;
|
|
30
25
|
this.type = type;
|
|
@@ -33,8 +28,7 @@ class RoomMessage {
|
|
|
33
28
|
this.attachment = attachment;
|
|
34
29
|
}
|
|
35
30
|
}
|
|
36
|
-
|
|
37
|
-
class RoomMessageEvent extends RoomEvent {
|
|
31
|
+
export class RoomMessageEvent extends RoomEvent {
|
|
38
32
|
constructor({ message }) {
|
|
39
33
|
super();
|
|
40
34
|
this.message = message;
|
|
@@ -46,8 +40,7 @@ class RoomMessageEvent extends RoomEvent {
|
|
|
46
40
|
return `a message was received ${JSON.stringify(this.message.message)}`;
|
|
47
41
|
}
|
|
48
42
|
}
|
|
49
|
-
|
|
50
|
-
class FileCreatedEvent extends RoomEvent {
|
|
43
|
+
export class FileCreatedEvent extends RoomEvent {
|
|
51
44
|
constructor({ path }) {
|
|
52
45
|
super();
|
|
53
46
|
this.path = path;
|
|
@@ -59,8 +52,7 @@ class FileCreatedEvent extends RoomEvent {
|
|
|
59
52
|
return `a file was created at the path ${this.path}`;
|
|
60
53
|
}
|
|
61
54
|
}
|
|
62
|
-
|
|
63
|
-
class FileDeletedEvent extends RoomEvent {
|
|
55
|
+
export class FileDeletedEvent extends RoomEvent {
|
|
64
56
|
constructor({ path, participantId }) {
|
|
65
57
|
super();
|
|
66
58
|
this.path = path;
|
|
@@ -73,8 +65,7 @@ class FileDeletedEvent extends RoomEvent {
|
|
|
73
65
|
return `a file was deleted at the path ${this.path}`;
|
|
74
66
|
}
|
|
75
67
|
}
|
|
76
|
-
|
|
77
|
-
class FileUpdatedEvent extends RoomEvent {
|
|
68
|
+
export class FileUpdatedEvent extends RoomEvent {
|
|
78
69
|
constructor({ path, participantId }) {
|
|
79
70
|
super();
|
|
80
71
|
this.path = path;
|
|
@@ -87,8 +78,7 @@ class FileUpdatedEvent extends RoomEvent {
|
|
|
87
78
|
return `a file was updated at the path ${this.path}`;
|
|
88
79
|
}
|
|
89
80
|
}
|
|
90
|
-
|
|
91
|
-
class FileMovedEvent extends RoomEvent {
|
|
81
|
+
export class FileMovedEvent extends RoomEvent {
|
|
92
82
|
constructor({ sourcePath, destinationPath, participantId, }) {
|
|
93
83
|
super();
|
|
94
84
|
this.sourcePath = sourcePath;
|
|
@@ -102,8 +92,7 @@ class FileMovedEvent extends RoomEvent {
|
|
|
102
92
|
return `a file was moved from ${this.sourcePath} to ${this.destinationPath}`;
|
|
103
93
|
}
|
|
104
94
|
}
|
|
105
|
-
|
|
106
|
-
class RoomLogEvent extends RoomEvent {
|
|
95
|
+
export class RoomLogEvent extends RoomEvent {
|
|
107
96
|
constructor({ type, data }) {
|
|
108
97
|
super();
|
|
109
98
|
this.type = type;
|
|
@@ -116,4 +105,3 @@ class RoomLogEvent extends RoomEvent {
|
|
|
116
105
|
return JSON.stringify(this.data);
|
|
117
106
|
}
|
|
118
107
|
}
|
|
119
|
-
exports.RoomLogEvent = RoomLogEvent;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RuntimeDocument } from "./document";
|
|
2
|
-
import { MeshSchema } from "./schema";
|
|
1
|
+
import { RuntimeDocument } from "./document.js";
|
|
2
|
+
import { MeshSchema } from "./schema.js";
|
|
3
3
|
export type Uint8List = Uint8Array;
|
|
4
4
|
export declare class RoomServerException extends Error {
|
|
5
5
|
readonly statusCode?: number;
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const completer_1 = require("./completer");
|
|
7
|
-
const runtime_1 = require("./runtime");
|
|
8
|
-
class RoomServerException extends Error {
|
|
1
|
+
import { v4 as uuidv4 } from "uuid";
|
|
2
|
+
import { RuntimeDocument } from "./document.js";
|
|
3
|
+
import { Completer } from "./completer.js";
|
|
4
|
+
import { registerDocument, unregisterDocument, applyChanges, getState, getStateVector, } from "./runtime.js";
|
|
5
|
+
export class RoomServerException extends Error {
|
|
9
6
|
constructor(message, code, { statusCode, retryable = false, } = {}) {
|
|
10
7
|
super(message);
|
|
11
8
|
this.name = "RoomServerException";
|
|
@@ -14,16 +11,15 @@ class RoomServerException extends Error {
|
|
|
14
11
|
this.retryable = retryable;
|
|
15
12
|
}
|
|
16
13
|
}
|
|
17
|
-
|
|
18
|
-
class MeshDocument extends document_1.RuntimeDocument {
|
|
14
|
+
export class MeshDocument extends RuntimeDocument {
|
|
19
15
|
constructor({ schema, sendChangesToBackend }) {
|
|
20
16
|
super({
|
|
21
|
-
id: (
|
|
17
|
+
id: uuidv4(),
|
|
22
18
|
schema,
|
|
23
|
-
sendChanges: (base64) =>
|
|
19
|
+
sendChanges: (base64) => applyChanges(base64),
|
|
24
20
|
sendChangesToBackend,
|
|
25
21
|
});
|
|
26
|
-
this._synchronized = new
|
|
22
|
+
this._synchronized = new Completer();
|
|
27
23
|
this.onSendUpdateToBackend = (base64) => {
|
|
28
24
|
const parsed = JSON.parse(base64);
|
|
29
25
|
if (this.sendChangesToBackend) {
|
|
@@ -34,13 +30,13 @@ class MeshDocument extends document_1.RuntimeDocument {
|
|
|
34
30
|
const parsed = JSON.parse(base64);
|
|
35
31
|
this.receiveChanges(parsed.data);
|
|
36
32
|
};
|
|
37
|
-
|
|
33
|
+
registerDocument(this.id, null, false, this.onSendUpdateToBackend, this.onSendUpdateToClient);
|
|
38
34
|
}
|
|
39
35
|
getState(vector) {
|
|
40
|
-
return
|
|
36
|
+
return getState(this.id, vector ?? null);
|
|
41
37
|
}
|
|
42
38
|
getStateVector() {
|
|
43
|
-
return
|
|
39
|
+
return getStateVector(this.id);
|
|
44
40
|
}
|
|
45
41
|
get synchronized() {
|
|
46
42
|
return this._synchronized.fut;
|
|
@@ -53,7 +49,6 @@ class MeshDocument extends document_1.RuntimeDocument {
|
|
|
53
49
|
}
|
|
54
50
|
dispose() {
|
|
55
51
|
super.dispose();
|
|
56
|
-
|
|
52
|
+
unregisterDocument(this.id);
|
|
57
53
|
}
|
|
58
54
|
}
|
|
59
|
-
exports.MeshDocument = MeshDocument;
|
package/dist/esm/runtime.js
CHANGED
|
@@ -1,10 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.unregisterDocument = exports.registerDocument = exports.getStateVector = exports.getState = exports.applyChanges = exports.applyBackendChanges = void 0;
|
|
4
|
-
var entrypoint_js_1 = require("./entrypoint.js");
|
|
5
|
-
Object.defineProperty(exports, "applyBackendChanges", { enumerable: true, get: function () { return entrypoint_js_1.applyBackendChanges; } });
|
|
6
|
-
Object.defineProperty(exports, "applyChanges", { enumerable: true, get: function () { return entrypoint_js_1.applyChanges; } });
|
|
7
|
-
Object.defineProperty(exports, "getState", { enumerable: true, get: function () { return entrypoint_js_1.getState; } });
|
|
8
|
-
Object.defineProperty(exports, "getStateVector", { enumerable: true, get: function () { return entrypoint_js_1.getStateVector; } });
|
|
9
|
-
Object.defineProperty(exports, "registerDocument", { enumerable: true, get: function () { return entrypoint_js_1.registerDocument; } });
|
|
10
|
-
Object.defineProperty(exports, "unregisterDocument", { enumerable: true, get: function () { return entrypoint_js_1.unregisterDocument; } });
|
|
1
|
+
export { applyBackendChanges, applyChanges, getState, getStateVector, registerDocument, unregisterDocument, } from './entrypoint.js';
|
package/dist/esm/schema.js
CHANGED
|
@@ -1,20 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MeshSchema = exports.ElementType = exports.ChildProperty = exports.ValueProperty = exports.ElementProperty = exports.SimpleValue = exports.MeshSchemaValidationException = void 0;
|
|
4
|
-
class MeshSchemaValidationException extends Error {
|
|
1
|
+
export class MeshSchemaValidationException extends Error {
|
|
5
2
|
constructor(message) {
|
|
6
3
|
super(message);
|
|
7
4
|
this.name = "MeshSchemaValidationException";
|
|
8
5
|
}
|
|
9
6
|
}
|
|
10
|
-
|
|
11
|
-
var SimpleValue;
|
|
7
|
+
export var SimpleValue;
|
|
12
8
|
(function (SimpleValue) {
|
|
13
9
|
SimpleValue["number"] = "number";
|
|
14
10
|
SimpleValue["string"] = "string";
|
|
15
11
|
SimpleValue["nullValue"] = "null";
|
|
16
12
|
SimpleValue["boolean"] = "boolean";
|
|
17
|
-
})(SimpleValue || (
|
|
13
|
+
})(SimpleValue || (SimpleValue = {}));
|
|
18
14
|
(function (SimpleValue) {
|
|
19
15
|
function fromString(val) {
|
|
20
16
|
switch (val) {
|
|
@@ -31,15 +27,14 @@ var SimpleValue;
|
|
|
31
27
|
}
|
|
32
28
|
}
|
|
33
29
|
SimpleValue.fromString = fromString;
|
|
34
|
-
})(SimpleValue || (
|
|
35
|
-
class ElementProperty {
|
|
30
|
+
})(SimpleValue || (SimpleValue = {}));
|
|
31
|
+
export class ElementProperty {
|
|
36
32
|
constructor({ name, description }) {
|
|
37
33
|
this.name = name;
|
|
38
34
|
this.description = description;
|
|
39
35
|
}
|
|
40
36
|
}
|
|
41
|
-
|
|
42
|
-
class ValueProperty extends ElementProperty {
|
|
37
|
+
export class ValueProperty extends ElementProperty {
|
|
43
38
|
constructor({ name, description, type, enumValues, required = false }) {
|
|
44
39
|
super({ name, description });
|
|
45
40
|
this.type = type;
|
|
@@ -74,8 +69,7 @@ class ValueProperty extends ElementProperty {
|
|
|
74
69
|
};
|
|
75
70
|
}
|
|
76
71
|
}
|
|
77
|
-
|
|
78
|
-
class ChildProperty extends ElementProperty {
|
|
72
|
+
export class ChildProperty extends ElementProperty {
|
|
79
73
|
constructor({ name, description, childTagNames, ordered = false }) {
|
|
80
74
|
super({ name, description });
|
|
81
75
|
this._childTagNames = childTagNames;
|
|
@@ -120,8 +114,7 @@ class ChildProperty extends ElementProperty {
|
|
|
120
114
|
}
|
|
121
115
|
}
|
|
122
116
|
}
|
|
123
|
-
|
|
124
|
-
class ElementType {
|
|
117
|
+
export class ElementType {
|
|
125
118
|
constructor(params) {
|
|
126
119
|
this._propertyLookup = new Map();
|
|
127
120
|
this._tagName = params.tagName;
|
|
@@ -275,8 +268,7 @@ class ElementType {
|
|
|
275
268
|
return found;
|
|
276
269
|
}
|
|
277
270
|
}
|
|
278
|
-
|
|
279
|
-
class MeshSchema {
|
|
271
|
+
export class MeshSchema {
|
|
280
272
|
constructor(params) {
|
|
281
273
|
this.elementsByTagName = {};
|
|
282
274
|
const { rootTagName, elements } = params;
|
|
@@ -340,4 +332,3 @@ class MeshSchema {
|
|
|
340
332
|
return this._elements;
|
|
341
333
|
}
|
|
342
334
|
}
|
|
343
|
-
exports.MeshSchema = MeshSchema;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { ConnectorRef, OAuthClientConfig } from "./meshagent-client";
|
|
2
|
-
import { FileContent } from "./response";
|
|
3
|
-
import { RoomClient } from "./room-client";
|
|
1
|
+
import type { ConnectorRef, OAuthClientConfig } from "./meshagent-client.js";
|
|
2
|
+
import { FileContent } from "./response.js";
|
|
3
|
+
import { RoomClient } from "./room-client.js";
|
|
4
4
|
export interface SecretInfo {
|
|
5
5
|
id: string;
|
|
6
6
|
name: string;
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const response_1 = require("./response");
|
|
5
|
-
const room_server_client_1 = require("./room-server-client");
|
|
6
|
-
const utils_1 = require("./utils");
|
|
1
|
+
import { BinaryContent, EmptyContent, FileContent, JsonContent } from "./response.js";
|
|
2
|
+
import { RoomServerException } from "./room-server-client.js";
|
|
3
|
+
import { unpackMessage } from "./utils.js";
|
|
7
4
|
function isRecord(value) {
|
|
8
5
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
9
6
|
}
|
|
10
|
-
class SecretsClient {
|
|
7
|
+
export class SecretsClient {
|
|
11
8
|
constructor({ room, oauthTokenRequestHandler, secretRequestHandler, }) {
|
|
12
9
|
this._oauthRequestHandler = this._handleClientOAuthTokenRequest.bind(this);
|
|
13
10
|
this._secretRequestHandler = this._handleClientSecretRequest.bind(this);
|
|
@@ -18,7 +15,7 @@ class SecretsClient {
|
|
|
18
15
|
this.client.protocol.addHandler("secrets.request_secret", this._secretRequestHandler);
|
|
19
16
|
}
|
|
20
17
|
unexpectedResponse(operation) {
|
|
21
|
-
return new
|
|
18
|
+
return new RoomServerException(`unexpected return type from secrets.${operation}`);
|
|
22
19
|
}
|
|
23
20
|
async invoke(operation, input) {
|
|
24
21
|
return await this.client.invoke({
|
|
@@ -51,7 +48,7 @@ class SecretsClient {
|
|
|
51
48
|
};
|
|
52
49
|
}
|
|
53
50
|
parseAccessToken(operation, response) {
|
|
54
|
-
if (!(response instanceof
|
|
51
|
+
if (!(response instanceof JsonContent)) {
|
|
55
52
|
throw this.unexpectedResponse(operation);
|
|
56
53
|
}
|
|
57
54
|
const token = response.json["access_token"];
|
|
@@ -82,25 +79,25 @@ class SecretsClient {
|
|
|
82
79
|
void messageId;
|
|
83
80
|
void type;
|
|
84
81
|
if (bytes == null) {
|
|
85
|
-
throw new
|
|
82
|
+
throw new RoomServerException("invalid secrets.request_oauth_token payload");
|
|
86
83
|
}
|
|
87
84
|
if (this.oauthTokenRequestHandler == null) {
|
|
88
|
-
throw new
|
|
85
|
+
throw new RoomServerException("No oauth token handler registered");
|
|
89
86
|
}
|
|
90
|
-
const [request] =
|
|
87
|
+
const [request] = unpackMessage(bytes);
|
|
91
88
|
const requestId = request["request_id"];
|
|
92
89
|
const challenge = request["challenge"];
|
|
93
90
|
const requestPayload = request["request"];
|
|
94
91
|
if (typeof requestId !== "string" || !isRecord(requestPayload)) {
|
|
95
|
-
throw new
|
|
92
|
+
throw new RoomServerException("invalid secrets.request_oauth_token payload");
|
|
96
93
|
}
|
|
97
94
|
const oauth = requestPayload["oauth"];
|
|
98
95
|
if (!isRecord(oauth) || typeof oauth["authorization_endpoint"] !== "string" || typeof oauth["token_endpoint"] !== "string") {
|
|
99
|
-
throw new
|
|
96
|
+
throw new RoomServerException("invalid secrets.request_oauth_token payload");
|
|
100
97
|
}
|
|
101
98
|
const scopes = oauth["scopes"];
|
|
102
99
|
if (scopes !== undefined && scopes !== null && (!Array.isArray(scopes) || scopes.some((scope) => typeof scope !== "string"))) {
|
|
103
|
-
throw new
|
|
100
|
+
throw new RoomServerException("invalid secrets.request_oauth_token payload");
|
|
104
101
|
}
|
|
105
102
|
Promise.resolve(this.oauthTokenRequestHandler({
|
|
106
103
|
requestId,
|
|
@@ -120,16 +117,16 @@ class SecretsClient {
|
|
|
120
117
|
void messageId;
|
|
121
118
|
void type;
|
|
122
119
|
if (bytes == null) {
|
|
123
|
-
throw new
|
|
120
|
+
throw new RoomServerException("invalid secrets.request_secret payload");
|
|
124
121
|
}
|
|
125
122
|
if (this.secretRequestHandler == null) {
|
|
126
|
-
throw new
|
|
123
|
+
throw new RoomServerException("No secret handler registered");
|
|
127
124
|
}
|
|
128
|
-
const [request] =
|
|
125
|
+
const [request] = unpackMessage(bytes);
|
|
129
126
|
const requestId = request["request_id"];
|
|
130
127
|
const requestPayload = request["request"];
|
|
131
128
|
if (typeof requestId !== "string" || !isRecord(requestPayload) || typeof requestPayload["url"] !== "string" || typeof requestPayload["type"] !== "string") {
|
|
132
|
-
throw new
|
|
129
|
+
throw new RoomServerException("invalid secrets.request_secret payload");
|
|
133
130
|
}
|
|
134
131
|
Promise.resolve(this.secretRequestHandler({
|
|
135
132
|
requestId,
|
|
@@ -146,7 +143,7 @@ class SecretsClient {
|
|
|
146
143
|
code,
|
|
147
144
|
error: null,
|
|
148
145
|
});
|
|
149
|
-
if (response instanceof
|
|
146
|
+
if (response instanceof EmptyContent || response instanceof JsonContent) {
|
|
150
147
|
return;
|
|
151
148
|
}
|
|
152
149
|
throw this.unexpectedResponse("provide_oauth_authorization");
|
|
@@ -157,33 +154,33 @@ class SecretsClient {
|
|
|
157
154
|
code: null,
|
|
158
155
|
error,
|
|
159
156
|
});
|
|
160
|
-
if (response instanceof
|
|
157
|
+
if (response instanceof EmptyContent || response instanceof JsonContent) {
|
|
161
158
|
return;
|
|
162
159
|
}
|
|
163
160
|
throw this.unexpectedResponse("provide_oauth_authorization");
|
|
164
161
|
}
|
|
165
162
|
async provideSecret({ requestId, data, }) {
|
|
166
|
-
const response = await this.invoke("provide_secret", new
|
|
163
|
+
const response = await this.invoke("provide_secret", new BinaryContent({
|
|
167
164
|
data,
|
|
168
165
|
headers: {
|
|
169
166
|
request_id: requestId,
|
|
170
167
|
error: null,
|
|
171
168
|
},
|
|
172
169
|
}));
|
|
173
|
-
if (response instanceof
|
|
170
|
+
if (response instanceof EmptyContent || response instanceof JsonContent) {
|
|
174
171
|
return;
|
|
175
172
|
}
|
|
176
173
|
throw this.unexpectedResponse("provide_secret");
|
|
177
174
|
}
|
|
178
175
|
async rejectSecret({ requestId, error, }) {
|
|
179
|
-
const response = await this.invoke("provide_secret", new
|
|
176
|
+
const response = await this.invoke("provide_secret", new BinaryContent({
|
|
180
177
|
data: new Uint8Array(0),
|
|
181
178
|
headers: {
|
|
182
179
|
request_id: requestId,
|
|
183
180
|
error,
|
|
184
181
|
},
|
|
185
182
|
}));
|
|
186
|
-
if (response instanceof
|
|
183
|
+
if (response instanceof EmptyContent || response instanceof JsonContent) {
|
|
187
184
|
return;
|
|
188
185
|
}
|
|
189
186
|
throw this.unexpectedResponse("provide_secret");
|
|
@@ -210,7 +207,7 @@ class SecretsClient {
|
|
|
210
207
|
}
|
|
211
208
|
async listSecrets() {
|
|
212
209
|
const response = await this.invoke("list_secrets", {});
|
|
213
|
-
if (!(response instanceof
|
|
210
|
+
if (!(response instanceof JsonContent)) {
|
|
214
211
|
throw this.unexpectedResponse("list_secrets");
|
|
215
212
|
}
|
|
216
213
|
const secrets = response.json["secrets"];
|
|
@@ -225,7 +222,7 @@ class SecretsClient {
|
|
|
225
222
|
delegated_to: delegatedTo ?? null,
|
|
226
223
|
for_identity: forIdentity ?? null,
|
|
227
224
|
});
|
|
228
|
-
if (!(response instanceof
|
|
225
|
+
if (!(response instanceof JsonContent) || typeof response.json["exists"] !== "boolean") {
|
|
229
226
|
throw this.unexpectedResponse("exists");
|
|
230
227
|
}
|
|
231
228
|
return response.json["exists"];
|
|
@@ -235,7 +232,7 @@ class SecretsClient {
|
|
|
235
232
|
id: secretId,
|
|
236
233
|
delegated_to: delegatedTo ?? null,
|
|
237
234
|
});
|
|
238
|
-
if (response instanceof
|
|
235
|
+
if (response instanceof EmptyContent || response instanceof JsonContent) {
|
|
239
236
|
return;
|
|
240
237
|
}
|
|
241
238
|
throw this.unexpectedResponse("delete_secret");
|
|
@@ -246,7 +243,7 @@ class SecretsClient {
|
|
|
246
243
|
type,
|
|
247
244
|
delegated_to: delegatedTo ?? null,
|
|
248
245
|
});
|
|
249
|
-
if (response instanceof
|
|
246
|
+
if (response instanceof EmptyContent || response instanceof JsonContent) {
|
|
250
247
|
return;
|
|
251
248
|
}
|
|
252
249
|
throw this.unexpectedResponse("delete_requested_secret");
|
|
@@ -259,13 +256,13 @@ class SecretsClient {
|
|
|
259
256
|
timeout,
|
|
260
257
|
delegate_to: delegateTo ?? null,
|
|
261
258
|
});
|
|
262
|
-
if (response instanceof
|
|
259
|
+
if (response instanceof FileContent) {
|
|
263
260
|
return response.data;
|
|
264
261
|
}
|
|
265
262
|
throw this.unexpectedResponse("request_secret");
|
|
266
263
|
}
|
|
267
264
|
async setSecret({ secretId, type, mimeType, name, delegatedTo, forIdentity, data, }) {
|
|
268
|
-
const response = await this.invoke("set_secret", new
|
|
265
|
+
const response = await this.invoke("set_secret", new BinaryContent({
|
|
269
266
|
data,
|
|
270
267
|
headers: {
|
|
271
268
|
secret_id: secretId ?? null,
|
|
@@ -276,7 +273,7 @@ class SecretsClient {
|
|
|
276
273
|
has_data: true,
|
|
277
274
|
},
|
|
278
275
|
}));
|
|
279
|
-
if (response instanceof
|
|
276
|
+
if (response instanceof EmptyContent || response instanceof JsonContent) {
|
|
280
277
|
return;
|
|
281
278
|
}
|
|
282
279
|
throw this.unexpectedResponse("set_secret");
|
|
@@ -288,13 +285,12 @@ class SecretsClient {
|
|
|
288
285
|
name: name ?? null,
|
|
289
286
|
delegated_to: delegatedTo ?? null,
|
|
290
287
|
});
|
|
291
|
-
if (response instanceof
|
|
288
|
+
if (response instanceof EmptyContent) {
|
|
292
289
|
return null;
|
|
293
290
|
}
|
|
294
|
-
if (response instanceof
|
|
291
|
+
if (response instanceof FileContent) {
|
|
295
292
|
return response;
|
|
296
293
|
}
|
|
297
294
|
throw this.unexpectedResponse("get_secret");
|
|
298
295
|
}
|
|
299
296
|
}
|
|
300
|
-
exports.SecretsClient = SecretsClient;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ServiceSpec } from "./meshagent-client";
|
|
2
|
-
import { RoomClient } from "./room-client";
|
|
1
|
+
import type { ServiceSpec } from "./meshagent-client.js";
|
|
2
|
+
import { RoomClient } from "./room-client.js";
|
|
3
3
|
export interface ServiceRuntimeState {
|
|
4
4
|
serviceId: string;
|
|
5
5
|
state: string;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.ServicesClient = void 0;
|
|
4
|
-
const response_1 = require("./response");
|
|
5
|
-
const room_server_client_1 = require("./room-server-client");
|
|
1
|
+
import { JsonContent, EmptyContent } from "./response.js";
|
|
2
|
+
import { RoomServerException } from "./room-server-client.js";
|
|
6
3
|
function isRecord(value) {
|
|
7
4
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
8
5
|
}
|
|
@@ -14,7 +11,7 @@ function toOptionalInteger(value) {
|
|
|
14
11
|
}
|
|
15
12
|
function parseServiceRuntimeState(value) {
|
|
16
13
|
if (!isRecord(value) || typeof value["service_id"] !== "string") {
|
|
17
|
-
throw new
|
|
14
|
+
throw new RoomServerException("unexpected return type from services.list");
|
|
18
15
|
}
|
|
19
16
|
const state = value["state"];
|
|
20
17
|
const containerId = value["container_id"];
|
|
@@ -33,21 +30,21 @@ function parseServiceSpecJson(value) {
|
|
|
33
30
|
if (typeof value === "string") {
|
|
34
31
|
const parsed = JSON.parse(value);
|
|
35
32
|
if (!isRecord(parsed)) {
|
|
36
|
-
throw new
|
|
33
|
+
throw new RoomServerException("unexpected return type from services.list");
|
|
37
34
|
}
|
|
38
35
|
return parsed;
|
|
39
36
|
}
|
|
40
37
|
if (!isRecord(value)) {
|
|
41
|
-
throw new
|
|
38
|
+
throw new RoomServerException("unexpected return type from services.list");
|
|
42
39
|
}
|
|
43
40
|
return value;
|
|
44
41
|
}
|
|
45
|
-
class ServicesClient {
|
|
42
|
+
export class ServicesClient {
|
|
46
43
|
constructor({ room }) {
|
|
47
44
|
this.room = room;
|
|
48
45
|
}
|
|
49
46
|
unexpectedResponse(operation) {
|
|
50
|
-
return new
|
|
47
|
+
return new RoomServerException(`unexpected return type from services.${operation}`);
|
|
51
48
|
}
|
|
52
49
|
async list() {
|
|
53
50
|
return (await this.listWithState()).services;
|
|
@@ -58,7 +55,7 @@ class ServicesClient {
|
|
|
58
55
|
tool: "list",
|
|
59
56
|
input: {},
|
|
60
57
|
});
|
|
61
|
-
if (!(response instanceof
|
|
58
|
+
if (!(response instanceof JsonContent)) {
|
|
62
59
|
throw this.unexpectedResponse("list");
|
|
63
60
|
}
|
|
64
61
|
const servicesRaw = response.json["services_json"];
|
|
@@ -84,10 +81,9 @@ class ServicesClient {
|
|
|
84
81
|
service_id: params.serviceId,
|
|
85
82
|
},
|
|
86
83
|
});
|
|
87
|
-
if (response instanceof
|
|
84
|
+
if (response instanceof EmptyContent || response instanceof JsonContent) {
|
|
88
85
|
return;
|
|
89
86
|
}
|
|
90
87
|
throw this.unexpectedResponse("restart");
|
|
91
88
|
}
|
|
92
89
|
}
|
|
93
|
-
exports.ServicesClient = ServicesClient;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { RoomClient } from "./room-client";
|
|
2
|
-
import { Protocol } from "./protocol";
|
|
3
|
-
import { RoomEvent } from "./room-event";
|
|
4
|
-
import { BinaryContent, FileContent } from "./response";
|
|
5
|
-
import { EventEmitter } from "./event-emitter";
|
|
1
|
+
import { RoomClient } from "./room-client.js";
|
|
2
|
+
import { Protocol } from "./protocol.js";
|
|
3
|
+
import { RoomEvent } from "./room-event.js";
|
|
4
|
+
import { BinaryContent, FileContent } from "./response.js";
|
|
5
|
+
import { EventEmitter } from "./event-emitter.js";
|
|
6
6
|
type StorageClientRoom = Pick<RoomClient, "invoke" | "invokeStream" | "emit"> & {
|
|
7
7
|
isActiveProtocol(protocol: Protocol): boolean;
|
|
8
8
|
protocol: Pick<Protocol, "addHandler">;
|