@hocuspocus/extension-webhook 3.1.3 → 3.1.5
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/hocuspocus-webhook.cjs +14 -11
- package/dist/hocuspocus-webhook.cjs.map +1 -1
- package/dist/hocuspocus-webhook.esm.js +14 -11
- package/dist/hocuspocus-webhook.esm.js.map +1 -1
- package/dist/packages/common/src/auth.d.ts +2 -2
- package/dist/packages/common/src/index.d.ts +4 -4
- package/dist/packages/extension-database/src/Database.d.ts +1 -1
- package/dist/packages/extension-database/src/index.d.ts +1 -1
- package/dist/packages/extension-logger/src/Logger.d.ts +1 -1
- package/dist/packages/extension-logger/src/index.d.ts +1 -1
- package/dist/packages/extension-redis/src/index.d.ts +1 -1
- package/dist/packages/extension-sqlite/src/SQLite.d.ts +3 -3
- package/dist/packages/extension-sqlite/src/index.d.ts +1 -1
- package/dist/packages/extension-throttle/src/index.d.ts +1 -1
- package/dist/packages/extension-webhook/src/index.d.ts +3 -3
- package/dist/packages/provider/src/HocuspocusProvider.d.ts +10 -10
- package/dist/packages/provider/src/IncomingMessage.d.ts +3 -3
- package/dist/packages/provider/src/MessageReceiver.d.ts +2 -2
- package/dist/packages/provider/src/OutgoingMessage.d.ts +2 -2
- package/dist/packages/provider/src/OutgoingMessages/AuthenticationMessage.d.ts +3 -3
- package/dist/packages/provider/src/OutgoingMessages/AwarenessMessage.d.ts +4 -4
- package/dist/packages/provider/src/OutgoingMessages/CloseMessage.d.ts +4 -4
- package/dist/packages/provider/src/OutgoingMessages/QueryAwarenessMessage.d.ts +4 -4
- package/dist/packages/provider/src/OutgoingMessages/StatelessMessage.d.ts +3 -3
- package/dist/packages/provider/src/OutgoingMessages/SyncStepOneMessage.d.ts +4 -4
- package/dist/packages/provider/src/OutgoingMessages/SyncStepTwoMessage.d.ts +4 -4
- package/dist/packages/provider/src/OutgoingMessages/UpdateMessage.d.ts +3 -3
- package/dist/packages/provider/src/index.d.ts +3 -3
- package/dist/packages/provider/src/types.d.ts +14 -14
- package/dist/packages/server/src/ClientConnection.d.ts +17 -17
- package/dist/packages/server/src/Connection.d.ts +6 -6
- package/dist/packages/server/src/DirectConnection.d.ts +3 -3
- package/dist/packages/server/src/Document.d.ts +4 -4
- package/dist/packages/server/src/Hocuspocus.d.ts +8 -8
- package/dist/packages/server/src/IncomingMessage.d.ts +3 -3
- package/dist/packages/server/src/MessageReceiver.d.ts +3 -3
- package/dist/packages/server/src/OutgoingMessage.d.ts +3 -3
- package/dist/packages/server/src/Server.d.ts +5 -5
- package/dist/packages/server/src/index.d.ts +9 -9
- package/dist/packages/server/src/types.d.ts +7 -7
- package/dist/packages/server/src/util/getParameters.d.ts +5 -5
- package/dist/packages/transformer/src/Prosemirror.d.ts +3 -3
- package/dist/packages/transformer/src/Tiptap.d.ts +3 -3
- package/dist/packages/transformer/src/index.d.ts +3 -3
- package/dist/packages/transformer/src/types.d.ts +1 -1
- package/dist/playground/frontend/app/SocketContext1.d.ts +2 -0
- package/dist/playground/frontend/app/SocketContext2.d.ts +2 -0
- package/package.json +40 -40
- package/src/index.ts +207 -201
- package/dist/playground/frontend/app/SocketContext.d.ts +0 -2
|
@@ -20,12 +20,10 @@ class Webhook {
|
|
|
20
20
|
this.configuration = {
|
|
21
21
|
debounce: 2000,
|
|
22
22
|
debounceMaxWait: 10000,
|
|
23
|
-
secret:
|
|
23
|
+
secret: "",
|
|
24
24
|
transformer: transformer.TiptapTransformer,
|
|
25
|
-
url:
|
|
26
|
-
events: [
|
|
27
|
-
exports.Events.onChange,
|
|
28
|
-
],
|
|
25
|
+
url: "",
|
|
26
|
+
events: [exports.Events.onChange],
|
|
29
27
|
};
|
|
30
28
|
this.debounced = new Map();
|
|
31
29
|
this.configuration = {
|
|
@@ -33,15 +31,15 @@ class Webhook {
|
|
|
33
31
|
...configuration,
|
|
34
32
|
};
|
|
35
33
|
if (!this.configuration.url) {
|
|
36
|
-
throw new Error(
|
|
34
|
+
throw new Error("url is required!");
|
|
37
35
|
}
|
|
38
36
|
}
|
|
39
37
|
/**
|
|
40
38
|
* Create a signature for the response body
|
|
41
39
|
*/
|
|
42
40
|
createSignature(body) {
|
|
43
|
-
const hmac = crypto.createHmac(
|
|
44
|
-
return `sha256=${hmac.update(body).digest(
|
|
41
|
+
const hmac = crypto.createHmac("sha256", this.configuration.secret);
|
|
42
|
+
return `sha256=${hmac.update(body).digest("hex")}`;
|
|
45
43
|
}
|
|
46
44
|
/**
|
|
47
45
|
* debounce the given function, using the given identifier
|
|
@@ -68,7 +66,12 @@ class Webhook {
|
|
|
68
66
|
*/
|
|
69
67
|
async sendRequest(event, payload) {
|
|
70
68
|
const json = JSON.stringify({ event, payload });
|
|
71
|
-
return axios.post(this.configuration.url, json, {
|
|
69
|
+
return axios.post(this.configuration.url, json, {
|
|
70
|
+
headers: {
|
|
71
|
+
"X-Hocuspocus-Signature-256": this.createSignature(json),
|
|
72
|
+
"Content-Type": "application/json",
|
|
73
|
+
},
|
|
74
|
+
});
|
|
72
75
|
}
|
|
73
76
|
/**
|
|
74
77
|
* onChange hook
|
|
@@ -111,7 +114,7 @@ class Webhook {
|
|
|
111
114
|
});
|
|
112
115
|
if (response.status !== 200 || !response.data)
|
|
113
116
|
return;
|
|
114
|
-
const document = typeof response.data ===
|
|
117
|
+
const document = typeof response.data === "string"
|
|
115
118
|
? JSON.parse(response.data)
|
|
116
119
|
: response.data;
|
|
117
120
|
// eslint-disable-next-line guard-for-in,no-restricted-syntax
|
|
@@ -138,7 +141,7 @@ class Webhook {
|
|
|
138
141
|
requestHeaders: data.requestHeaders,
|
|
139
142
|
requestParameters: Object.fromEntries(data.requestParameters.entries()),
|
|
140
143
|
});
|
|
141
|
-
return typeof response.data ===
|
|
144
|
+
return typeof response.data === "string" && response.data.length > 0
|
|
142
145
|
? JSON.parse(response.data)
|
|
143
146
|
: response.data;
|
|
144
147
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hocuspocus-webhook.cjs","sources":["../src/index.ts"],"sourcesContent":[null],"names":["Events","TiptapTransformer","createHmac","Forbidden"],"mappings":";;;;;;;AAcYA;AAAZ,CAAA,UAAY,MAAM,EAAA;
|
|
1
|
+
{"version":3,"file":"hocuspocus-webhook.cjs","sources":["../src/index.ts"],"sourcesContent":[null],"names":["Events","TiptapTransformer","createHmac","Forbidden"],"mappings":";;;;;;;AAcYA;AAAZ,CAAA,UAAY,MAAM,EAAA;AACjB,IAAA,MAAA,CAAA,UAAA,CAAA,GAAA,QAAmB;AACnB,IAAA,MAAA,CAAA,WAAA,CAAA,GAAA,SAAqB;AACrB,IAAA,MAAA,CAAA,UAAA,CAAA,GAAA,QAAmB;AACnB,IAAA,MAAA,CAAA,cAAA,CAAA,GAAA,YAA2B;AAC5B,CAAC,EALWA,cAAM,KAANA,cAAM,GAKjB,EAAA,CAAA,CAAA;MAgBY,OAAO,CAAA;AAanB;;AAEG;AACH,IAAA,WAAA,CAAY,aAAsC,EAAA;AAflD,QAAA,IAAA,CAAA,aAAa,GAAkB;AAC9B,YAAA,QAAQ,EAAE,IAAI;AACd,YAAA,eAAe,EAAE,KAAK;AACtB,YAAA,MAAM,EAAE,EAAE;AACV,YAAA,WAAW,EAAEC,6BAAiB;AAC9B,YAAA,GAAG,EAAE,EAAE;AACP,YAAA,MAAM,EAAE,CAACD,cAAM,CAAC,QAAQ,CAAC;SACzB;AAED,QAAA,IAAA,CAAA,SAAS,GACR,IAAI,GAAG,EAAE;QAMT,IAAI,CAAC,aAAa,GAAG;YACpB,GAAG,IAAI,CAAC,aAAa;AACrB,YAAA,GAAG,aAAa;SAChB;AAED,QAAA,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,EAAE;AAC5B,YAAA,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC;;;AAIrC;;AAEG;AACH,IAAA,eAAe,CAAC,IAAY,EAAA;AAC3B,QAAA,MAAM,IAAI,GAAGE,iBAAU,CAAC,QAAQ,EAAE,IAAI,CAA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AA,OAAO,OAAO,QAAQ,CAAC,IAAI,KAAK,QAAQ,IAAI,QAAQ,CAAC,IAAI,CAAC,MAAM,GAAG;kBAChE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI;AAC1B,kBAAE,QAAQ,CAAC,IAAI;;QACf,OAAO,CAAC,EAAE;AACX,YAAA,OAAO,CAAC,KAAK,CAAC,sCAAsC,CAAC,CAAA,CAAE,CAAC;AACxD,YAAA,MAAMG,gBAAS;;;IAIjB,MAAM,YAAY,CAAC,IAAyB,EAAA;AAC3C,QAAA,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,QAAQ,CAACH,cAAM,CAAC,YAAY,CAAC,EAAE;YAC7D;;AAGD,QAAA,IAAI;AACH,YAAA,MAAM,IAAI,CAAC,WAAW,CAACA,cAAM,CAAC,YAAY,EAAE;gBAC3C,YAAY,EAAE,IAAI,CAAC,YAAY;gBAC/B,cAAc,EAAE,IAAI,CAAC,cAAc;gBACnC,iBAAiB,EAAE,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE,CAAC;gBACvE,OAAO,EAAE,IAAI,CAAC,OAAO;AACrB,aAAA,CAAC;;QACD,OAAO,CAAC,EAAE;AACX,YAAA,OAAO,CAAC,KAAK,CAAC,sCAAsC,CAAC,CAAA,CAAE,CAAC;;;AAG1D;;;;"}
|
|
@@ -18,12 +18,10 @@ class Webhook {
|
|
|
18
18
|
this.configuration = {
|
|
19
19
|
debounce: 2000,
|
|
20
20
|
debounceMaxWait: 10000,
|
|
21
|
-
secret:
|
|
21
|
+
secret: "",
|
|
22
22
|
transformer: TiptapTransformer,
|
|
23
|
-
url:
|
|
24
|
-
events: [
|
|
25
|
-
Events.onChange,
|
|
26
|
-
],
|
|
23
|
+
url: "",
|
|
24
|
+
events: [Events.onChange],
|
|
27
25
|
};
|
|
28
26
|
this.debounced = new Map();
|
|
29
27
|
this.configuration = {
|
|
@@ -31,15 +29,15 @@ class Webhook {
|
|
|
31
29
|
...configuration,
|
|
32
30
|
};
|
|
33
31
|
if (!this.configuration.url) {
|
|
34
|
-
throw new Error(
|
|
32
|
+
throw new Error("url is required!");
|
|
35
33
|
}
|
|
36
34
|
}
|
|
37
35
|
/**
|
|
38
36
|
* Create a signature for the response body
|
|
39
37
|
*/
|
|
40
38
|
createSignature(body) {
|
|
41
|
-
const hmac = createHmac(
|
|
42
|
-
return `sha256=${hmac.update(body).digest(
|
|
39
|
+
const hmac = createHmac("sha256", this.configuration.secret);
|
|
40
|
+
return `sha256=${hmac.update(body).digest("hex")}`;
|
|
43
41
|
}
|
|
44
42
|
/**
|
|
45
43
|
* debounce the given function, using the given identifier
|
|
@@ -66,7 +64,12 @@ class Webhook {
|
|
|
66
64
|
*/
|
|
67
65
|
async sendRequest(event, payload) {
|
|
68
66
|
const json = JSON.stringify({ event, payload });
|
|
69
|
-
return axios.post(this.configuration.url, json, {
|
|
67
|
+
return axios.post(this.configuration.url, json, {
|
|
68
|
+
headers: {
|
|
69
|
+
"X-Hocuspocus-Signature-256": this.createSignature(json),
|
|
70
|
+
"Content-Type": "application/json",
|
|
71
|
+
},
|
|
72
|
+
});
|
|
70
73
|
}
|
|
71
74
|
/**
|
|
72
75
|
* onChange hook
|
|
@@ -109,7 +112,7 @@ class Webhook {
|
|
|
109
112
|
});
|
|
110
113
|
if (response.status !== 200 || !response.data)
|
|
111
114
|
return;
|
|
112
|
-
const document = typeof response.data ===
|
|
115
|
+
const document = typeof response.data === "string"
|
|
113
116
|
? JSON.parse(response.data)
|
|
114
117
|
: response.data;
|
|
115
118
|
// eslint-disable-next-line guard-for-in,no-restricted-syntax
|
|
@@ -136,7 +139,7 @@ class Webhook {
|
|
|
136
139
|
requestHeaders: data.requestHeaders,
|
|
137
140
|
requestParameters: Object.fromEntries(data.requestParameters.entries()),
|
|
138
141
|
});
|
|
139
|
-
return typeof response.data ===
|
|
142
|
+
return typeof response.data === "string" && response.data.length > 0
|
|
140
143
|
? JSON.parse(response.data)
|
|
141
144
|
: response.data;
|
|
142
145
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hocuspocus-webhook.esm.js","sources":["../src/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;IAcY;AAAZ,CAAA,UAAY,MAAM,EAAA;
|
|
1
|
+
{"version":3,"file":"hocuspocus-webhook.esm.js","sources":["../src/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;IAcY;AAAZ,CAAA,UAAY,MAAM,EAAA;AACjB,IAAA,MAAA,CAAA,UAAA,CAAA,GAAA,QAAmB;AACnB,IAAA,MAAA,CAAA,WAAA,CAAA,GAAA,SAAqB;AACrB,IAAA,MAAA,CAAA,UAAA,CAAA,GAAA,QAAmB;AACnB,IAAA,MAAA,CAAA,cAAA,CAAA,GAAA,YAA2B;AAC5B,CAAC,EALW,MAAM,KAAN,MAAM,GAKjB,EAAA,CAAA,CAAA;MAgBY,OAAO,CAAA;AAanB;;AAEG;AACH,IAAA,WAAA,CAAY,aAAsC,EAAA;AAflD,QAAA,IAAA,CAAA,aAAa,GAAkB;AAC9B,YAAA,QAAQ,EAAE,IAAI;AACd,YAAA,eAAe,EAAE,KAAK;AACtB,YAAA,MAAM,EAAE,EAAE;AACV,YAAA,WAAW,EAAE,iBAAiB;AAC9B,YAAA,GAAG,EAAE,EAAE;AACP,YAAA,MAAM,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC;SACzB;AAED,QAAA,IAAA,CAAA,SAAS,GACR,IAAI,GAAG,EAAE;QAMT,IAAI,CAAC,aAAa,GAAG;YACpB,GAAG,IAAI,CAAC,aAAa;AACrB,YAAA,GAAG,aAAa;SAChB;AAED,QAAA,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,EAAE;AAC5B,YAAA,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC;;;AAIrC;;AAEG;AACH,IAAA,eAAe,CAAC,IAAY,EAAA;AAC3B,QAAA,MAAM,IAAI,G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,EAAE,CAAC;AACvE,aAAA,CAAC;AAEF,YAAA,OAAO,OAAO,QAAQ,CAAC,IAAI,KAAK,QAAQ,IAAI,QAAQ,CAAC,IAAI,CAAC,MAAM,GAAG;kBAChE,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI;AAC1B,kBAAE,QAAQ,CAAC,IAAI;;QACf,OAAO,CAAC,EAAE;AACX,YAAA,OAAO,CAAC,KAAK,CAAC,sCAAsC,CAAC,CAAA,CAAE,CAAC;AACxD,YAAA,MAAM,SAAS;;;IAIjB,MAAM,YAAY,CAAC,IAAyB,EAAA;AAC3C,QAAA,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,YAAY,CAAC,EAAE;YAC7D;;AAGD,QAAA,IAAI;AACH,YAAA,MAAM,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,YAAY,EAAE;gBAC3C,YAAY,EAAE,IAAI,CAAC,YAAY;gBAC/B,cAAc,EAAE,IAAI,CAAC,cAAc;gBACnC,iBAAiB,EAAE,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,iBAAiB,CAAC,OAAO,EAAE,CAAC;gBACvE,OAAO,EAAE,IAAI,CAAC,OAAO;AACrB,aAAA,CAAC;;QACD,OAAO,CAAC,EAAE;AACX,YAAA,OAAO,CAAC,KAAK,CAAC,sCAAsC,CAAC,CAAA,CAAE,CAAC;;;AAG1D;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as encoding from
|
|
2
|
-
import * as decoding from
|
|
1
|
+
import * as encoding from "lib0/encoding";
|
|
2
|
+
import * as decoding from "lib0/decoding";
|
|
3
3
|
export declare const writeAuthentication: (encoder: encoding.Encoder, auth: string) => void;
|
|
4
4
|
export declare const writePermissionDenied: (encoder: encoding.Encoder, reason: string) => void;
|
|
5
5
|
export declare const writeAuthenticated: (encoder: encoding.Encoder, scope: "readonly" | "read-write") => void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
1
|
+
export * from "./auth.ts";
|
|
2
|
+
export * from "./CloseEvents.ts";
|
|
3
|
+
export * from "./awarenessStatesToArray.ts";
|
|
4
|
+
export * from "./types.ts";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Extension, onChangePayload, onLoadDocumentPayload, storePayload, fetchPayload } from
|
|
1
|
+
import type { Extension, onChangePayload, onLoadDocumentPayload, storePayload, fetchPayload } from "@hocuspocus/server";
|
|
2
2
|
export interface DatabaseConfiguration {
|
|
3
3
|
/**
|
|
4
4
|
* Pass a Promise to retrieve updates from your database. The Promise should resolve to
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from "./Database.ts";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Extension, onChangePayload, onConfigurePayload, onConnectPayload, onLoadDocumentPayload, onDestroyPayload, onDisconnectPayload, onRequestPayload, onUpgradePayload } from
|
|
1
|
+
import type { Extension, onChangePayload, onConfigurePayload, onConnectPayload, onLoadDocumentPayload, onDestroyPayload, onDisconnectPayload, onRequestPayload, onUpgradePayload } from "@hocuspocus/server";
|
|
2
2
|
export interface LoggerConfiguration {
|
|
3
3
|
/**
|
|
4
4
|
* Prepend all logging message with a string.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from "./Logger.ts";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from "./Redis.ts";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { DatabaseConfiguration } from
|
|
2
|
-
import { Database } from
|
|
3
|
-
import sqlite3 from
|
|
1
|
+
import type { DatabaseConfiguration } from "@hocuspocus/extension-database";
|
|
2
|
+
import { Database } from "@hocuspocus/extension-database";
|
|
3
|
+
import sqlite3 from "sqlite3";
|
|
4
4
|
export declare const schema = "CREATE TABLE IF NOT EXISTS \"documents\" (\n \"name\" varchar(255) NOT NULL,\n \"data\" blob NOT NULL,\n UNIQUE(name)\n)";
|
|
5
5
|
export declare const selectQuery = "\n SELECT data FROM \"documents\" WHERE name = $name ORDER BY rowid DESC\n";
|
|
6
6
|
export declare const upsertQuery = "\n INSERT INTO \"documents\" (\"name\", \"data\") VALUES ($name, $data)\n ON CONFLICT(name) DO UPDATE SET data = $data\n";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from
|
|
1
|
+
export * from "./SQLite.ts";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Extension, onChangePayload, onConnectPayload, onLoadDocumentPayload, onDisconnectPayload } from
|
|
2
|
-
import type { Doc } from
|
|
3
|
-
import type { Transformer } from
|
|
1
|
+
import type { Extension, onChangePayload, onConnectPayload, onLoadDocumentPayload, onDisconnectPayload } from "@hocuspocus/server";
|
|
2
|
+
import type { Doc } from "yjs";
|
|
3
|
+
import type { Transformer } from "@hocuspocus/transformer";
|
|
4
4
|
export declare enum Events {
|
|
5
5
|
onChange = "change",
|
|
6
6
|
onConnect = "connect",
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import type { Event, MessageEvent } from
|
|
2
|
-
import { Awareness } from
|
|
3
|
-
import * as Y from
|
|
4
|
-
import EventEmitter from
|
|
5
|
-
import type { CompleteHocuspocusProviderWebsocketConfiguration } from
|
|
6
|
-
import { HocuspocusProviderWebsocket } from
|
|
7
|
-
import type { ConstructableOutgoingMessage, onAuthenticatedParameters, onAuthenticationFailedParameters, onAwarenessChangeParameters, onAwarenessUpdateParameters, onCloseParameters, onDisconnectParameters, onMessageParameters, onOpenParameters, onOutgoingMessageParameters, onStatelessParameters, onSyncedParameters, onUnsyncedChangesParameters } from
|
|
8
|
-
export type HocuspocusProviderConfiguration = Required<Pick<CompleteHocuspocusProviderConfiguration,
|
|
1
|
+
import type { Event, MessageEvent } from "ws";
|
|
2
|
+
import { Awareness } from "y-protocols/awareness";
|
|
3
|
+
import * as Y from "yjs";
|
|
4
|
+
import EventEmitter from "./EventEmitter.ts";
|
|
5
|
+
import type { CompleteHocuspocusProviderWebsocketConfiguration } from "./HocuspocusProviderWebsocket.ts";
|
|
6
|
+
import { HocuspocusProviderWebsocket } from "./HocuspocusProviderWebsocket.ts";
|
|
7
|
+
import type { ConstructableOutgoingMessage, onAuthenticatedParameters, onAuthenticationFailedParameters, onAwarenessChangeParameters, onAwarenessUpdateParameters, onCloseParameters, onDisconnectParameters, onMessageParameters, onOpenParameters, onOutgoingMessageParameters, onStatelessParameters, onSyncedParameters, onUnsyncedChangesParameters } from "./types.ts";
|
|
8
|
+
export type HocuspocusProviderConfiguration = Required<Pick<CompleteHocuspocusProviderConfiguration, "name">> & Partial<CompleteHocuspocusProviderConfiguration> & (Required<Pick<CompleteHocuspocusProviderWebsocketConfiguration, "url">> | Required<Pick<CompleteHocuspocusProviderConfiguration, "websocketProvider">>);
|
|
9
9
|
export interface CompleteHocuspocusProviderConfiguration {
|
|
10
10
|
/**
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
* The identifier/name of your document
|
|
12
|
+
*/
|
|
13
13
|
name: string;
|
|
14
14
|
/**
|
|
15
15
|
* The actual Y.js document
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Decoder } from
|
|
2
|
-
import type { Encoder } from
|
|
3
|
-
import type { MessageType } from
|
|
1
|
+
import type { Decoder } from "lib0/decoding";
|
|
2
|
+
import type { Encoder } from "lib0/encoding";
|
|
3
|
+
import type { MessageType } from "./types.ts";
|
|
4
4
|
export declare class IncomingMessage {
|
|
5
5
|
data: any;
|
|
6
6
|
encoder: Encoder;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { HocuspocusProvider } from
|
|
2
|
-
import type { IncomingMessage } from
|
|
1
|
+
import type { HocuspocusProvider } from "./HocuspocusProvider.ts";
|
|
2
|
+
import type { IncomingMessage } from "./IncomingMessage.ts";
|
|
3
3
|
export declare class MessageReceiver {
|
|
4
4
|
message: IncomingMessage;
|
|
5
5
|
constructor(message: IncomingMessage);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Encoder } from
|
|
2
|
-
import type { MessageType, OutgoingMessageArguments, OutgoingMessageInterface } from
|
|
1
|
+
import type { Encoder } from "lib0/encoding";
|
|
2
|
+
import type { MessageType, OutgoingMessageArguments, OutgoingMessageInterface } from "./types.ts";
|
|
3
3
|
export declare class OutgoingMessage implements OutgoingMessageInterface {
|
|
4
4
|
encoder: Encoder;
|
|
5
5
|
type?: MessageType;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { OutgoingMessageArguments } from
|
|
2
|
-
import { MessageType } from
|
|
3
|
-
import { OutgoingMessage } from
|
|
1
|
+
import type { OutgoingMessageArguments } from "../types.ts";
|
|
2
|
+
import { MessageType } from "../types.ts";
|
|
3
|
+
import { OutgoingMessage } from "../OutgoingMessage.ts";
|
|
4
4
|
export declare class AuthenticationMessage extends OutgoingMessage {
|
|
5
5
|
type: MessageType;
|
|
6
6
|
description: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as encoding from
|
|
2
|
-
import type { OutgoingMessageArguments } from
|
|
3
|
-
import { MessageType } from
|
|
4
|
-
import { OutgoingMessage } from
|
|
1
|
+
import * as encoding from "lib0/encoding";
|
|
2
|
+
import type { OutgoingMessageArguments } from "../types.ts";
|
|
3
|
+
import { MessageType } from "../types.ts";
|
|
4
|
+
import { OutgoingMessage } from "../OutgoingMessage.ts";
|
|
5
5
|
export declare class AwarenessMessage extends OutgoingMessage {
|
|
6
6
|
type: MessageType;
|
|
7
7
|
description: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as encoding from
|
|
2
|
-
import type { OutgoingMessageArguments } from
|
|
3
|
-
import { MessageType } from
|
|
4
|
-
import { OutgoingMessage } from
|
|
1
|
+
import * as encoding from "lib0/encoding";
|
|
2
|
+
import type { OutgoingMessageArguments } from "../types.ts";
|
|
3
|
+
import { MessageType } from "../types.ts";
|
|
4
|
+
import { OutgoingMessage } from "../OutgoingMessage.ts";
|
|
5
5
|
export declare class CloseMessage extends OutgoingMessage {
|
|
6
6
|
type: MessageType;
|
|
7
7
|
description: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as encoding from
|
|
2
|
-
import type { OutgoingMessageArguments } from
|
|
3
|
-
import { MessageType } from
|
|
4
|
-
import { OutgoingMessage } from
|
|
1
|
+
import * as encoding from "lib0/encoding";
|
|
2
|
+
import type { OutgoingMessageArguments } from "../types.ts";
|
|
3
|
+
import { MessageType } from "../types.ts";
|
|
4
|
+
import { OutgoingMessage } from "../OutgoingMessage.ts";
|
|
5
5
|
export declare class QueryAwarenessMessage extends OutgoingMessage {
|
|
6
6
|
type: MessageType;
|
|
7
7
|
description: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { OutgoingMessageArguments } from
|
|
2
|
-
import { MessageType } from
|
|
3
|
-
import { OutgoingMessage } from
|
|
1
|
+
import type { OutgoingMessageArguments } from "../types.ts";
|
|
2
|
+
import { MessageType } from "../types.ts";
|
|
3
|
+
import { OutgoingMessage } from "../OutgoingMessage.ts";
|
|
4
4
|
export declare class StatelessMessage extends OutgoingMessage {
|
|
5
5
|
type: MessageType;
|
|
6
6
|
description: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as encoding from
|
|
2
|
-
import type { OutgoingMessageArguments } from
|
|
3
|
-
import { MessageType } from
|
|
4
|
-
import { OutgoingMessage } from
|
|
1
|
+
import * as encoding from "lib0/encoding";
|
|
2
|
+
import type { OutgoingMessageArguments } from "../types.ts";
|
|
3
|
+
import { MessageType } from "../types.ts";
|
|
4
|
+
import { OutgoingMessage } from "../OutgoingMessage.ts";
|
|
5
5
|
export declare class SyncStepOneMessage extends OutgoingMessage {
|
|
6
6
|
type: MessageType;
|
|
7
7
|
description: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as encoding from
|
|
2
|
-
import type { OutgoingMessageArguments } from
|
|
3
|
-
import { MessageType } from
|
|
4
|
-
import { OutgoingMessage } from
|
|
1
|
+
import * as encoding from "lib0/encoding";
|
|
2
|
+
import type { OutgoingMessageArguments } from "../types.ts";
|
|
3
|
+
import { MessageType } from "../types.ts";
|
|
4
|
+
import { OutgoingMessage } from "../OutgoingMessage.ts";
|
|
5
5
|
export declare class SyncStepTwoMessage extends OutgoingMessage {
|
|
6
6
|
type: MessageType;
|
|
7
7
|
description: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { OutgoingMessageArguments } from
|
|
2
|
-
import { MessageType } from
|
|
3
|
-
import { OutgoingMessage } from
|
|
1
|
+
import type { OutgoingMessageArguments } from "../types.ts";
|
|
2
|
+
import { MessageType } from "../types.ts";
|
|
3
|
+
import { OutgoingMessage } from "../OutgoingMessage.ts";
|
|
4
4
|
export declare class UpdateMessage extends OutgoingMessage {
|
|
5
5
|
type: MessageType;
|
|
6
6
|
description: string;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
1
|
+
export * from "./HocuspocusProvider.ts";
|
|
2
|
+
export * from "./HocuspocusProviderWebsocket.ts";
|
|
3
|
+
export * from "./types.ts";
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import type { Encoder } from
|
|
2
|
-
import type { Event, MessageEvent } from
|
|
3
|
-
import type { Awareness } from
|
|
4
|
-
import type * as Y from
|
|
5
|
-
import type { CloseEvent } from
|
|
6
|
-
import type { IncomingMessage } from
|
|
7
|
-
import type { OutgoingMessage } from
|
|
8
|
-
import type { AuthenticationMessage } from
|
|
9
|
-
import type { AwarenessMessage } from
|
|
10
|
-
import type { QueryAwarenessMessage } from
|
|
11
|
-
import type { SyncStepOneMessage } from
|
|
12
|
-
import type { SyncStepTwoMessage } from
|
|
13
|
-
import type { UpdateMessage } from
|
|
1
|
+
import type { Encoder } from "lib0/encoding";
|
|
2
|
+
import type { Event, MessageEvent } from "ws";
|
|
3
|
+
import type { Awareness } from "y-protocols/awareness";
|
|
4
|
+
import type * as Y from "yjs";
|
|
5
|
+
import type { CloseEvent } from "@hocuspocus/common";
|
|
6
|
+
import type { IncomingMessage } from "./IncomingMessage.ts";
|
|
7
|
+
import type { OutgoingMessage } from "./OutgoingMessage.ts";
|
|
8
|
+
import type { AuthenticationMessage } from "./OutgoingMessages/AuthenticationMessage.ts";
|
|
9
|
+
import type { AwarenessMessage } from "./OutgoingMessages/AwarenessMessage.ts";
|
|
10
|
+
import type { QueryAwarenessMessage } from "./OutgoingMessages/QueryAwarenessMessage.ts";
|
|
11
|
+
import type { SyncStepOneMessage } from "./OutgoingMessages/SyncStepOneMessage.ts";
|
|
12
|
+
import type { SyncStepTwoMessage } from "./OutgoingMessages/SyncStepTwoMessage.ts";
|
|
13
|
+
import type { UpdateMessage } from "./OutgoingMessages/UpdateMessage.ts";
|
|
14
14
|
export declare enum MessageType {
|
|
15
15
|
Sync = 0,
|
|
16
16
|
Awareness = 1,
|
|
@@ -50,7 +50,7 @@ export type onAuthenticationFailedParameters = {
|
|
|
50
50
|
reason: string;
|
|
51
51
|
};
|
|
52
52
|
export type onAuthenticatedParameters = {
|
|
53
|
-
scope:
|
|
53
|
+
scope: "read-write" | "readonly";
|
|
54
54
|
};
|
|
55
55
|
export type onOpenParameters = {
|
|
56
56
|
event: Event;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { IncomingMessage } from
|
|
2
|
-
import { type CloseEvent } from
|
|
3
|
-
import type WebSocket from
|
|
4
|
-
import type Document from
|
|
5
|
-
import type { Hocuspocus } from
|
|
6
|
-
import type { onDisconnectPayload } from
|
|
1
|
+
import type { IncomingMessage } from "http";
|
|
2
|
+
import { type CloseEvent } from "@hocuspocus/common";
|
|
3
|
+
import type WebSocket from "ws";
|
|
4
|
+
import type Document from "./Document.ts";
|
|
5
|
+
import type { Hocuspocus } from "./Hocuspocus.ts";
|
|
6
|
+
import type { onDisconnectPayload } from "./types.ts";
|
|
7
7
|
/**
|
|
8
8
|
* The `ClientConnection` class is responsible for handling an incoming WebSocket
|
|
9
9
|
*
|
|
@@ -27,18 +27,18 @@ export declare class ClientConnection {
|
|
|
27
27
|
pingInterval: NodeJS.Timeout;
|
|
28
28
|
pongReceived: boolean;
|
|
29
29
|
/**
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
30
|
+
* The `ClientConnection` class receives incoming WebSocket connections,
|
|
31
|
+
* runs all hooks:
|
|
32
|
+
*
|
|
33
|
+
* - onConnect for all connections
|
|
34
|
+
* - onAuthenticate only if required
|
|
35
|
+
*
|
|
36
|
+
* … and if nothings fails it’ll fully establish the connection and
|
|
37
|
+
* load the Document then.
|
|
38
|
+
*/
|
|
39
39
|
constructor(websocket: WebSocket, request: IncomingMessage, documentProvider: {
|
|
40
|
-
createDocument: Hocuspocus[
|
|
41
|
-
}, hooks: Hocuspocus[
|
|
40
|
+
createDocument: Hocuspocus["createDocument"];
|
|
41
|
+
}, hooks: Hocuspocus["hooks"], opts: {
|
|
42
42
|
timeout: number;
|
|
43
43
|
}, defaultContext?: any);
|
|
44
44
|
private handleWebsocketClose;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { IncomingMessage as HTTPIncomingMessage } from
|
|
2
|
-
import { type CloseEvent } from
|
|
3
|
-
import type WebSocket from
|
|
4
|
-
import type Document from
|
|
5
|
-
import type { beforeSyncPayload, onStatelessPayload } from
|
|
1
|
+
import type { IncomingMessage as HTTPIncomingMessage } from "http";
|
|
2
|
+
import { type CloseEvent } from "@hocuspocus/common";
|
|
3
|
+
import type WebSocket from "ws";
|
|
4
|
+
import type Document from "./Document.ts";
|
|
5
|
+
import type { beforeSyncPayload, onStatelessPayload } from "./types.ts";
|
|
6
6
|
export declare class Connection {
|
|
7
7
|
webSocket: WebSocket;
|
|
8
8
|
context: any;
|
|
@@ -35,7 +35,7 @@ export declare class Connection {
|
|
|
35
35
|
/**
|
|
36
36
|
* Set a callback that will be triggered before a sync message is handled
|
|
37
37
|
*/
|
|
38
|
-
beforeSync(callback: (connection: Connection, payload: Pick<beforeSyncPayload,
|
|
38
|
+
beforeSync(callback: (connection: Connection, payload: Pick<beforeSyncPayload, "type" | "payload">) => Promise<any>): Connection;
|
|
39
39
|
/**
|
|
40
40
|
* Send the given message
|
|
41
41
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type Document from
|
|
2
|
-
import type { Hocuspocus } from
|
|
3
|
-
import type { DirectConnection as DirectConnectionInterface } from
|
|
1
|
+
import type Document from "./Document.ts";
|
|
2
|
+
import type { Hocuspocus } from "./Hocuspocus.ts";
|
|
3
|
+
import type { DirectConnection as DirectConnectionInterface } from "./types.ts";
|
|
4
4
|
export declare class DirectConnection implements DirectConnectionInterface {
|
|
5
5
|
document: Document | null;
|
|
6
6
|
instance: Hocuspocus;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type WebSocket from
|
|
2
|
-
import { Awareness } from
|
|
3
|
-
import { Doc } from
|
|
4
|
-
import type Connection from
|
|
1
|
+
import type WebSocket from "ws";
|
|
2
|
+
import { Awareness } from "y-protocols/awareness";
|
|
3
|
+
import { Doc } from "yjs";
|
|
4
|
+
import type Connection from "./Connection.ts";
|
|
5
5
|
export declare class Document extends Doc {
|
|
6
6
|
awareness: Awareness;
|
|
7
7
|
callbacks: {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { IncomingMessage } from
|
|
2
|
-
import type WebSocket from
|
|
3
|
-
import { DirectConnection } from
|
|
4
|
-
import Document from
|
|
5
|
-
import type { Server } from
|
|
6
|
-
import type { Configuration, ConnectionConfiguration, HookName, HookPayloadByName, onStoreDocumentPayload } from
|
|
1
|
+
import type { IncomingMessage } from "http";
|
|
2
|
+
import type WebSocket from "ws";
|
|
3
|
+
import { DirectConnection } from "./DirectConnection.ts";
|
|
4
|
+
import Document from "./Document.ts";
|
|
5
|
+
import type { Server } from "./Server.ts";
|
|
6
|
+
import type { Configuration, ConnectionConfiguration, HookName, HookPayloadByName, onStoreDocumentPayload } from "./types.ts";
|
|
7
7
|
export declare const defaultConfiguration: {
|
|
8
8
|
name: null;
|
|
9
9
|
timeout: number;
|
|
@@ -64,8 +64,8 @@ export declare class Hocuspocus {
|
|
|
64
64
|
/**
|
|
65
65
|
* Create a new document by the given request
|
|
66
66
|
*/
|
|
67
|
-
createDocument(documentName: string, request: Partial<Pick<IncomingMessage,
|
|
68
|
-
loadDocument(documentName: string, request: Partial<Pick<IncomingMessage,
|
|
67
|
+
createDocument(documentName: string, request: Partial<Pick<IncomingMessage, "headers" | "url">>, socketId: string, connection: ConnectionConfiguration, context?: any): Promise<Document>;
|
|
68
|
+
loadDocument(documentName: string, request: Partial<Pick<IncomingMessage, "headers" | "url">>, socketId: string, connectionConfig: ConnectionConfiguration, context?: any): Promise<Document>;
|
|
69
69
|
storeDocumentHooks(document: Document, hookPayload: onStoreDocumentPayload, immediately?: boolean): any;
|
|
70
70
|
/**
|
|
71
71
|
* Run the given hook on all configured extensions.
|