@meshagent/meshagent 0.0.13 → 0.0.15
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/dist/browser/entrypoint.d.ts +1 -1
- package/dist/browser/participant-token.d.ts +3 -3
- package/dist/browser/participant-token.js +1 -4
- package/dist/browser/protocol.js +1 -1
- package/dist/browser/utils.d.ts +0 -1
- package/dist/browser/utils.js +0 -9
- package/dist/node/entrypoint.d.ts +1 -1
- package/dist/node/participant-token.d.ts +3 -3
- package/dist/node/participant-token.js +1 -4
- package/dist/node/protocol.js +1 -1
- package/dist/node/utils.d.ts +0 -1
- package/dist/node/utils.js +0 -9
- package/package.json +1 -1
|
@@ -49686,7 +49686,7 @@ export var ServerXmlDocument: {
|
|
|
49686
49686
|
count: number;
|
|
49687
49687
|
write(v: T): void;
|
|
49688
49688
|
cpos: number;
|
|
49689
|
-
cbuf: Uint8Array<
|
|
49689
|
+
cbuf: Uint8Array<any>;
|
|
49690
49690
|
bufs: any[];
|
|
49691
49691
|
};
|
|
49692
49692
|
writeDsLen(len: number): void;
|
|
@@ -16,8 +16,8 @@ export declare class ParticipantToken {
|
|
|
16
16
|
extra?: Record<string, any>;
|
|
17
17
|
constructor({ name, projectId, apiKeyId, extra, grants, }: {
|
|
18
18
|
name: string;
|
|
19
|
-
projectId
|
|
20
|
-
apiKeyId
|
|
19
|
+
projectId?: string;
|
|
20
|
+
apiKeyId?: string;
|
|
21
21
|
extra?: Record<string, any>;
|
|
22
22
|
grants?: ParticipantGrant[];
|
|
23
23
|
});
|
|
@@ -25,7 +25,7 @@ export declare class ParticipantToken {
|
|
|
25
25
|
addRoleGrant(role: string): void;
|
|
26
26
|
addRoomGrant(roomName: string): void;
|
|
27
27
|
toJson(): Record<string, any>;
|
|
28
|
-
toJwt({ token }
|
|
28
|
+
toJwt({ token }?: {
|
|
29
29
|
token?: string;
|
|
30
30
|
}): Promise<string>;
|
|
31
31
|
static fromJson(json: Record<string, any>): ParticipantToken;
|
|
@@ -51,11 +51,8 @@ class ParticipantToken {
|
|
|
51
51
|
grants: this.grants.map((g) => g.toJson()),
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
|
-
async toJwt({ token }) {
|
|
54
|
+
async toJwt({ token } = {}) {
|
|
55
55
|
const secret = token || process.env.MESHAGENT_SECRET;
|
|
56
|
-
if (!secret) {
|
|
57
|
-
throw new Error("No secret provided. Provide `token` or set MESHAGENT_SECRET in environment.");
|
|
58
|
-
}
|
|
59
56
|
const secretKey = new TextEncoder().encode(secret);
|
|
60
57
|
const payload = {
|
|
61
58
|
...this.toJson(),
|
package/dist/browser/protocol.js
CHANGED
|
@@ -67,7 +67,7 @@ class WebSocketProtocolChannel {
|
|
|
67
67
|
this._onData = (event) => {
|
|
68
68
|
const data = event.data;
|
|
69
69
|
if (data instanceof Blob) {
|
|
70
|
-
|
|
70
|
+
data.arrayBuffer().then((buffer) => {
|
|
71
71
|
if (this.onDataReceived) {
|
|
72
72
|
this.onDataReceived(new Uint8Array(buffer));
|
|
73
73
|
}
|
package/dist/browser/utils.d.ts
CHANGED
|
@@ -6,7 +6,6 @@ export declare function splitMessagePayload(packet: Uint8Array): Uint8Array;
|
|
|
6
6
|
export declare function splitMessageHeader(packet: Uint8Array): string;
|
|
7
7
|
export declare function packMessage(request: Record<string, any>, data?: Uint8Array): Uint8Array;
|
|
8
8
|
export declare function mergeUint8Arrays(...arrays: Uint8Array[]): Uint8Array;
|
|
9
|
-
export declare function blobToArrayBuffer(blob: Blob): Promise<ArrayBuffer>;
|
|
10
9
|
export declare class RefCount<T> {
|
|
11
10
|
ref: T;
|
|
12
11
|
count: number;
|
package/dist/browser/utils.js
CHANGED
|
@@ -5,7 +5,6 @@ exports.splitMessagePayload = splitMessagePayload;
|
|
|
5
5
|
exports.splitMessageHeader = splitMessageHeader;
|
|
6
6
|
exports.packMessage = packMessage;
|
|
7
7
|
exports.mergeUint8Arrays = mergeUint8Arrays;
|
|
8
|
-
exports.blobToArrayBuffer = blobToArrayBuffer;
|
|
9
8
|
const text_encoding_1 = require("@kayahr/text-encoding");
|
|
10
9
|
const encoder = new text_encoding_1.TextEncoder();
|
|
11
10
|
exports.encoder = encoder;
|
|
@@ -42,14 +41,6 @@ function mergeUint8Arrays(...arrays) {
|
|
|
42
41
|
});
|
|
43
42
|
return merged;
|
|
44
43
|
}
|
|
45
|
-
function blobToArrayBuffer(blob) {
|
|
46
|
-
return new Promise((resolve, reject) => {
|
|
47
|
-
const reader = new FileReader();
|
|
48
|
-
reader.onload = () => resolve(reader.result);
|
|
49
|
-
reader.onerror = () => reject(reader.error);
|
|
50
|
-
reader.readAsArrayBuffer(blob);
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
44
|
class RefCount {
|
|
54
45
|
constructor(ref) {
|
|
55
46
|
this.ref = ref;
|
|
@@ -49686,7 +49686,7 @@ export var ServerXmlDocument: {
|
|
|
49686
49686
|
count: number;
|
|
49687
49687
|
write(v: T): void;
|
|
49688
49688
|
cpos: number;
|
|
49689
|
-
cbuf: Uint8Array<
|
|
49689
|
+
cbuf: Uint8Array<any>;
|
|
49690
49690
|
bufs: any[];
|
|
49691
49691
|
};
|
|
49692
49692
|
writeDsLen(len: number): void;
|
|
@@ -16,8 +16,8 @@ export declare class ParticipantToken {
|
|
|
16
16
|
extra?: Record<string, any>;
|
|
17
17
|
constructor({ name, projectId, apiKeyId, extra, grants, }: {
|
|
18
18
|
name: string;
|
|
19
|
-
projectId
|
|
20
|
-
apiKeyId
|
|
19
|
+
projectId?: string;
|
|
20
|
+
apiKeyId?: string;
|
|
21
21
|
extra?: Record<string, any>;
|
|
22
22
|
grants?: ParticipantGrant[];
|
|
23
23
|
});
|
|
@@ -25,7 +25,7 @@ export declare class ParticipantToken {
|
|
|
25
25
|
addRoleGrant(role: string): void;
|
|
26
26
|
addRoomGrant(roomName: string): void;
|
|
27
27
|
toJson(): Record<string, any>;
|
|
28
|
-
toJwt({ token }
|
|
28
|
+
toJwt({ token }?: {
|
|
29
29
|
token?: string;
|
|
30
30
|
}): Promise<string>;
|
|
31
31
|
static fromJson(json: Record<string, any>): ParticipantToken;
|
|
@@ -51,11 +51,8 @@ class ParticipantToken {
|
|
|
51
51
|
grants: this.grants.map((g) => g.toJson()),
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
|
-
async toJwt({ token }) {
|
|
54
|
+
async toJwt({ token } = {}) {
|
|
55
55
|
const secret = token || process.env.MESHAGENT_SECRET;
|
|
56
|
-
if (!secret) {
|
|
57
|
-
throw new Error("No secret provided. Provide `token` or set MESHAGENT_SECRET in environment.");
|
|
58
|
-
}
|
|
59
56
|
const secretKey = new TextEncoder().encode(secret);
|
|
60
57
|
const payload = {
|
|
61
58
|
...this.toJson(),
|
package/dist/node/protocol.js
CHANGED
|
@@ -67,7 +67,7 @@ class WebSocketProtocolChannel {
|
|
|
67
67
|
this._onData = (event) => {
|
|
68
68
|
const data = event.data;
|
|
69
69
|
if (data instanceof Blob) {
|
|
70
|
-
|
|
70
|
+
data.arrayBuffer().then((buffer) => {
|
|
71
71
|
if (this.onDataReceived) {
|
|
72
72
|
this.onDataReceived(new Uint8Array(buffer));
|
|
73
73
|
}
|
package/dist/node/utils.d.ts
CHANGED
|
@@ -6,7 +6,6 @@ export declare function splitMessagePayload(packet: Uint8Array): Uint8Array;
|
|
|
6
6
|
export declare function splitMessageHeader(packet: Uint8Array): string;
|
|
7
7
|
export declare function packMessage(request: Record<string, any>, data?: Uint8Array): Uint8Array;
|
|
8
8
|
export declare function mergeUint8Arrays(...arrays: Uint8Array[]): Uint8Array;
|
|
9
|
-
export declare function blobToArrayBuffer(blob: Blob): Promise<ArrayBuffer>;
|
|
10
9
|
export declare class RefCount<T> {
|
|
11
10
|
ref: T;
|
|
12
11
|
count: number;
|
package/dist/node/utils.js
CHANGED
|
@@ -5,7 +5,6 @@ exports.splitMessagePayload = splitMessagePayload;
|
|
|
5
5
|
exports.splitMessageHeader = splitMessageHeader;
|
|
6
6
|
exports.packMessage = packMessage;
|
|
7
7
|
exports.mergeUint8Arrays = mergeUint8Arrays;
|
|
8
|
-
exports.blobToArrayBuffer = blobToArrayBuffer;
|
|
9
8
|
const text_encoding_1 = require("@kayahr/text-encoding");
|
|
10
9
|
const encoder = new text_encoding_1.TextEncoder();
|
|
11
10
|
exports.encoder = encoder;
|
|
@@ -42,14 +41,6 @@ function mergeUint8Arrays(...arrays) {
|
|
|
42
41
|
});
|
|
43
42
|
return merged;
|
|
44
43
|
}
|
|
45
|
-
function blobToArrayBuffer(blob) {
|
|
46
|
-
return new Promise((resolve, reject) => {
|
|
47
|
-
const reader = new FileReader();
|
|
48
|
-
reader.onload = () => resolve(reader.result);
|
|
49
|
-
reader.onerror = () => reject(reader.error);
|
|
50
|
-
reader.readAsArrayBuffer(blob);
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
44
|
class RefCount {
|
|
54
45
|
constructor(ref) {
|
|
55
46
|
this.ref = ref;
|