@hocuspocus/extension-throttle 2.1.0-alpha.0 → 2.1.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.
Files changed (124) hide show
  1. package/dist/hocuspocus-throttle.cjs +84 -84
  2. package/dist/hocuspocus-throttle.esm.js +84 -84
  3. package/dist/packages/common/src/CloseEvents.d.ts +29 -29
  4. package/dist/packages/common/src/auth.d.ts +6 -6
  5. package/dist/packages/common/src/awarenessStatesToArray.d.ts +3 -3
  6. package/dist/packages/common/src/index.d.ts +4 -4
  7. package/dist/packages/common/src/types.d.ts +10 -10
  8. package/dist/packages/extension-database/src/Database.d.ts +30 -30
  9. package/dist/packages/extension-database/src/index.d.ts +1 -1
  10. package/dist/packages/extension-logger/src/Logger.d.ts +67 -67
  11. package/dist/packages/extension-logger/src/index.d.ts +1 -1
  12. package/dist/packages/extension-redis/src/Redis.d.ts +116 -95
  13. package/dist/packages/extension-redis/src/index.d.ts +1 -1
  14. package/dist/packages/extension-sqlite/src/SQLite.d.ts +26 -26
  15. package/dist/packages/extension-sqlite/src/index.d.ts +1 -1
  16. package/dist/packages/extension-throttle/src/index.d.ts +31 -31
  17. package/dist/packages/extension-webhook/src/index.d.ts +57 -57
  18. package/dist/packages/provider/src/EventEmitter.d.ts +9 -9
  19. package/dist/packages/provider/src/HocuspocusProvider.d.ts +110 -110
  20. package/dist/packages/provider/src/HocuspocusProviderWebsocket.d.ts +115 -115
  21. package/dist/packages/provider/src/IncomingMessage.d.ts +16 -16
  22. package/dist/packages/provider/src/MessageReceiver.d.ts +13 -13
  23. package/dist/packages/provider/src/MessageSender.d.ts +10 -10
  24. package/dist/packages/provider/src/OutgoingMessage.d.ts +9 -9
  25. package/dist/packages/provider/src/OutgoingMessages/AuthenticationMessage.d.ts +7 -7
  26. package/dist/packages/provider/src/OutgoingMessages/AwarenessMessage.d.ts +8 -8
  27. package/dist/packages/provider/src/OutgoingMessages/CloseMessage.d.ts +8 -8
  28. package/dist/packages/provider/src/OutgoingMessages/QueryAwarenessMessage.d.ts +8 -8
  29. package/dist/packages/provider/src/OutgoingMessages/StatelessMessage.d.ts +7 -7
  30. package/dist/packages/provider/src/OutgoingMessages/SyncStepOneMessage.d.ts +8 -8
  31. package/dist/packages/provider/src/OutgoingMessages/SyncStepTwoMessage.d.ts +8 -8
  32. package/dist/packages/provider/src/OutgoingMessages/UpdateMessage.d.ts +7 -7
  33. package/dist/packages/provider/src/TiptapCollabProvider.d.ts +11 -11
  34. package/dist/packages/provider/src/TiptapCollabProviderWebsocket.d.ts +11 -11
  35. package/dist/packages/provider/src/index.d.ts +5 -5
  36. package/dist/packages/provider/src/types.d.ts +84 -84
  37. package/dist/packages/server/src/Connection.d.ts +71 -71
  38. package/dist/packages/server/src/Debugger.d.ts +14 -14
  39. package/dist/packages/server/src/DirectConnection.d.ts +13 -0
  40. package/dist/packages/server/src/Document.d.ts +91 -88
  41. package/dist/packages/server/src/Hocuspocus.d.ts +111 -108
  42. package/dist/packages/server/src/IncomingMessage.d.ts +21 -21
  43. package/dist/packages/server/src/MessageReceiver.d.ts +12 -12
  44. package/dist/packages/server/src/OutgoingMessage.d.ts +20 -20
  45. package/dist/packages/server/src/index.d.ts +8 -8
  46. package/dist/packages/server/src/types.d.ts +266 -264
  47. package/dist/packages/transformer/src/Prosemirror.d.ts +11 -11
  48. package/dist/packages/transformer/src/Tiptap.d.ts +10 -10
  49. package/dist/packages/transformer/src/index.d.ts +3 -3
  50. package/dist/packages/transformer/src/types.d.ts +5 -5
  51. package/dist/playground/backend/src/default.d.ts +1 -1
  52. package/dist/playground/backend/src/express.d.ts +1 -1
  53. package/dist/playground/backend/src/koa.d.ts +1 -1
  54. package/dist/playground/backend/src/load-document.d.ts +1 -1
  55. package/dist/playground/backend/src/redis.d.ts +1 -1
  56. package/dist/playground/backend/src/slow.d.ts +1 -1
  57. package/dist/playground/backend/src/tiptapcollab.d.ts +1 -1
  58. package/dist/playground/backend/src/webhook.d.ts +1 -1
  59. package/dist/playground/frontend/src/main.d.ts +1 -1
  60. package/dist/playground/frontend/vite.config.d.ts +2 -2
  61. package/dist/tests/extension-database/fetch.d.ts +1 -1
  62. package/dist/tests/extension-logger/onListen.d.ts +1 -1
  63. package/dist/tests/extension-redis/closeConnections.d.ts +1 -1
  64. package/dist/tests/extension-redis/getConnectionCount.d.ts +1 -1
  65. package/dist/tests/extension-redis/getDocumentsCount.d.ts +1 -1
  66. package/dist/tests/extension-redis/onAwarenessChange.d.ts +1 -1
  67. package/dist/tests/extension-redis/onChange.d.ts +1 -1
  68. package/dist/tests/extension-redis/onStateless.d.ts +1 -1
  69. package/dist/tests/extension-redis/onStoreDocument.d.ts +1 -1
  70. package/dist/tests/extension-throttle/banning.d.ts +1 -1
  71. package/dist/tests/extension-throttle/configuration.d.ts +1 -1
  72. package/dist/tests/provider/observe.d.ts +1 -1
  73. package/dist/tests/provider/observeDeep.d.ts +1 -1
  74. package/dist/tests/provider/onAuthenticated.d.ts +1 -1
  75. package/dist/tests/provider/onAuthenticationFailed.d.ts +1 -1
  76. package/dist/tests/provider/onAwarenessChange.d.ts +1 -1
  77. package/dist/tests/provider/onAwarenessUpdate.d.ts +1 -1
  78. package/dist/tests/provider/onClose.d.ts +1 -1
  79. package/dist/tests/provider/onConnect.d.ts +1 -1
  80. package/dist/tests/provider/onDisconnect.d.ts +1 -1
  81. package/dist/tests/provider/onMessage.d.ts +1 -1
  82. package/dist/tests/provider/onOpen.d.ts +1 -1
  83. package/dist/tests/provider/onStateless.d.ts +1 -1
  84. package/dist/tests/provider/onSynced.d.ts +1 -1
  85. package/dist/tests/providerwebsocket/configuration.d.ts +1 -1
  86. package/dist/tests/server/address.d.ts +1 -1
  87. package/dist/tests/server/afterStoreDocument.d.ts +1 -1
  88. package/dist/tests/server/beforeBroadcastStateless.d.ts +1 -1
  89. package/dist/tests/server/beforeHandleMessage.d.ts +1 -1
  90. package/dist/tests/server/closeConnections.d.ts +1 -1
  91. package/dist/tests/server/getConnectionsCount.d.ts +1 -1
  92. package/dist/tests/server/getDocumentsCount.d.ts +1 -1
  93. package/dist/tests/server/getMessageLogs.d.ts +1 -1
  94. package/dist/tests/server/listen.d.ts +1 -1
  95. package/dist/tests/server/onAuthenticate.d.ts +1 -1
  96. package/dist/tests/server/onAwarenessUpdate.d.ts +1 -1
  97. package/dist/tests/server/onChange.d.ts +1 -1
  98. package/dist/tests/server/onClose.d.ts +1 -1
  99. package/dist/tests/server/onConfigure.d.ts +1 -1
  100. package/dist/tests/server/onConnect.d.ts +1 -1
  101. package/dist/tests/server/onDestroy.d.ts +1 -1
  102. package/dist/tests/server/onDisconnect.d.ts +1 -1
  103. package/dist/tests/server/onListen.d.ts +1 -1
  104. package/dist/tests/server/onLoadDocument.d.ts +1 -1
  105. package/dist/tests/server/onRequest.d.ts +1 -1
  106. package/dist/tests/server/onStateless.d.ts +1 -1
  107. package/dist/tests/server/onStoreDocument.d.ts +1 -1
  108. package/dist/tests/server/onUpgrade.d.ts +1 -1
  109. package/dist/tests/server/openDirectConnection.d.ts +1 -0
  110. package/dist/tests/server/requiresAuthentication.d.ts +1 -1
  111. package/dist/tests/server/websocketError.d.ts +1 -1
  112. package/dist/tests/transformer/TiptapTransformer.d.ts +1 -1
  113. package/dist/tests/utils/createDirectory.d.ts +1 -1
  114. package/dist/tests/utils/flushRedis.d.ts +1 -1
  115. package/dist/tests/utils/index.d.ts +9 -9
  116. package/dist/tests/utils/newHocuspocus.d.ts +2 -2
  117. package/dist/tests/utils/newHocuspocusProvider.d.ts +3 -3
  118. package/dist/tests/utils/newHocuspocusProviderWebsocket.d.ts +3 -3
  119. package/dist/tests/utils/randomInteger.d.ts +1 -1
  120. package/dist/tests/utils/redisConnectionSettings.d.ts +4 -4
  121. package/dist/tests/utils/removeDirectory.d.ts +1 -1
  122. package/dist/tests/utils/retryableAssertion.d.ts +2 -2
  123. package/dist/tests/utils/sleep.d.ts +1 -1
  124. package/package.json +4 -3
@@ -2,90 +2,90 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- class Throttle {
6
- /**
7
- * Constructor
8
- */
9
- constructor(configuration) {
10
- this.configuration = {
11
- throttle: 15,
12
- banTime: 5,
13
- consideredSeconds: 60,
14
- cleanupInterval: 90,
15
- };
16
- this.connectionsByIp = new Map();
17
- this.bannedIps = new Map();
18
- this.configuration = {
19
- ...this.configuration,
20
- ...configuration,
21
- };
22
- this.cleanupInterval = setInterval(this.clearMaps.bind(this), this.configuration.cleanupInterval * 1000);
23
- }
24
- onDestroy() {
25
- if (this.cleanupInterval) {
26
- clearInterval(this.cleanupInterval);
27
- }
28
- return Promise.resolve();
29
- }
30
- clearMaps() {
31
- this.connectionsByIp.forEach((value, key) => {
32
- const filteredValue = value
33
- .filter(timestamp => timestamp + (this.configuration.consideredSeconds * 1000) > Date.now());
34
- if (filteredValue.length) {
35
- this.connectionsByIp.set(key, filteredValue);
36
- }
37
- else {
38
- this.connectionsByIp.delete(key);
39
- }
40
- });
41
- this.bannedIps.forEach((value, key) => {
42
- if (!this.isBanned(key)) {
43
- this.bannedIps.delete(key);
44
- }
45
- });
46
- }
47
- isBanned(ip) {
48
- const bannedAt = this.bannedIps.get(ip) || 0;
49
- return Date.now() < (bannedAt + (this.configuration.banTime * 60 * 1000));
50
- }
51
- /**
52
- * Throttle requests
53
- * @private
54
- */
55
- throttle(ip) {
56
- if (!this.configuration.throttle) {
57
- return false;
58
- }
59
- if (this.isBanned(ip))
60
- return true;
61
- this.bannedIps.delete(ip);
62
- // add this connection try to the list of previous connections
63
- const previousConnections = this.connectionsByIp.get(ip) || [];
64
- previousConnections.push(Date.now());
65
- // calculate the previous connections in the last considered time interval
66
- const previousConnectionsInTheConsideredInterval = previousConnections
67
- .filter(timestamp => timestamp + (this.configuration.consideredSeconds * 1000) > Date.now());
68
- this.connectionsByIp.set(ip, previousConnectionsInTheConsideredInterval);
69
- if (previousConnectionsInTheConsideredInterval.length > this.configuration.throttle) {
70
- this.bannedIps.set(ip, Date.now());
71
- return true;
72
- }
73
- return false;
74
- }
75
- /**
76
- * onConnect hook
77
- * @param data
78
- */
79
- onConnect(data) {
80
- const { request } = data;
81
- // get the remote ip address
82
- const ip = request.headers['x-real-ip']
83
- || request.headers['x-forwarded-for']
84
- || request.socket.remoteAddress
85
- || '';
86
- // throttle the connection
87
- return this.throttle(ip) ? Promise.reject() : Promise.resolve();
88
- }
5
+ class Throttle {
6
+ /**
7
+ * Constructor
8
+ */
9
+ constructor(configuration) {
10
+ this.configuration = {
11
+ throttle: 15,
12
+ banTime: 5,
13
+ consideredSeconds: 60,
14
+ cleanupInterval: 90,
15
+ };
16
+ this.connectionsByIp = new Map();
17
+ this.bannedIps = new Map();
18
+ this.configuration = {
19
+ ...this.configuration,
20
+ ...configuration,
21
+ };
22
+ this.cleanupInterval = setInterval(this.clearMaps.bind(this), this.configuration.cleanupInterval * 1000);
23
+ }
24
+ onDestroy() {
25
+ if (this.cleanupInterval) {
26
+ clearInterval(this.cleanupInterval);
27
+ }
28
+ return Promise.resolve();
29
+ }
30
+ clearMaps() {
31
+ this.connectionsByIp.forEach((value, key) => {
32
+ const filteredValue = value
33
+ .filter(timestamp => timestamp + (this.configuration.consideredSeconds * 1000) > Date.now());
34
+ if (filteredValue.length) {
35
+ this.connectionsByIp.set(key, filteredValue);
36
+ }
37
+ else {
38
+ this.connectionsByIp.delete(key);
39
+ }
40
+ });
41
+ this.bannedIps.forEach((value, key) => {
42
+ if (!this.isBanned(key)) {
43
+ this.bannedIps.delete(key);
44
+ }
45
+ });
46
+ }
47
+ isBanned(ip) {
48
+ const bannedAt = this.bannedIps.get(ip) || 0;
49
+ return Date.now() < (bannedAt + (this.configuration.banTime * 60 * 1000));
50
+ }
51
+ /**
52
+ * Throttle requests
53
+ * @private
54
+ */
55
+ throttle(ip) {
56
+ if (!this.configuration.throttle) {
57
+ return false;
58
+ }
59
+ if (this.isBanned(ip))
60
+ return true;
61
+ this.bannedIps.delete(ip);
62
+ // add this connection try to the list of previous connections
63
+ const previousConnections = this.connectionsByIp.get(ip) || [];
64
+ previousConnections.push(Date.now());
65
+ // calculate the previous connections in the last considered time interval
66
+ const previousConnectionsInTheConsideredInterval = previousConnections
67
+ .filter(timestamp => timestamp + (this.configuration.consideredSeconds * 1000) > Date.now());
68
+ this.connectionsByIp.set(ip, previousConnectionsInTheConsideredInterval);
69
+ if (previousConnectionsInTheConsideredInterval.length > this.configuration.throttle) {
70
+ this.bannedIps.set(ip, Date.now());
71
+ return true;
72
+ }
73
+ return false;
74
+ }
75
+ /**
76
+ * onConnect hook
77
+ * @param data
78
+ */
79
+ onConnect(data) {
80
+ const { request } = data;
81
+ // get the remote ip address
82
+ const ip = request.headers['x-real-ip']
83
+ || request.headers['x-forwarded-for']
84
+ || request.socket.remoteAddress
85
+ || '';
86
+ // throttle the connection
87
+ return this.throttle(ip) ? Promise.reject() : Promise.resolve();
88
+ }
89
89
  }
90
90
 
91
91
  exports.Throttle = Throttle;
@@ -1,87 +1,87 @@
1
- class Throttle {
2
- /**
3
- * Constructor
4
- */
5
- constructor(configuration) {
6
- this.configuration = {
7
- throttle: 15,
8
- banTime: 5,
9
- consideredSeconds: 60,
10
- cleanupInterval: 90,
11
- };
12
- this.connectionsByIp = new Map();
13
- this.bannedIps = new Map();
14
- this.configuration = {
15
- ...this.configuration,
16
- ...configuration,
17
- };
18
- this.cleanupInterval = setInterval(this.clearMaps.bind(this), this.configuration.cleanupInterval * 1000);
19
- }
20
- onDestroy() {
21
- if (this.cleanupInterval) {
22
- clearInterval(this.cleanupInterval);
23
- }
24
- return Promise.resolve();
25
- }
26
- clearMaps() {
27
- this.connectionsByIp.forEach((value, key) => {
28
- const filteredValue = value
29
- .filter(timestamp => timestamp + (this.configuration.consideredSeconds * 1000) > Date.now());
30
- if (filteredValue.length) {
31
- this.connectionsByIp.set(key, filteredValue);
32
- }
33
- else {
34
- this.connectionsByIp.delete(key);
35
- }
36
- });
37
- this.bannedIps.forEach((value, key) => {
38
- if (!this.isBanned(key)) {
39
- this.bannedIps.delete(key);
40
- }
41
- });
42
- }
43
- isBanned(ip) {
44
- const bannedAt = this.bannedIps.get(ip) || 0;
45
- return Date.now() < (bannedAt + (this.configuration.banTime * 60 * 1000));
46
- }
47
- /**
48
- * Throttle requests
49
- * @private
50
- */
51
- throttle(ip) {
52
- if (!this.configuration.throttle) {
53
- return false;
54
- }
55
- if (this.isBanned(ip))
56
- return true;
57
- this.bannedIps.delete(ip);
58
- // add this connection try to the list of previous connections
59
- const previousConnections = this.connectionsByIp.get(ip) || [];
60
- previousConnections.push(Date.now());
61
- // calculate the previous connections in the last considered time interval
62
- const previousConnectionsInTheConsideredInterval = previousConnections
63
- .filter(timestamp => timestamp + (this.configuration.consideredSeconds * 1000) > Date.now());
64
- this.connectionsByIp.set(ip, previousConnectionsInTheConsideredInterval);
65
- if (previousConnectionsInTheConsideredInterval.length > this.configuration.throttle) {
66
- this.bannedIps.set(ip, Date.now());
67
- return true;
68
- }
69
- return false;
70
- }
71
- /**
72
- * onConnect hook
73
- * @param data
74
- */
75
- onConnect(data) {
76
- const { request } = data;
77
- // get the remote ip address
78
- const ip = request.headers['x-real-ip']
79
- || request.headers['x-forwarded-for']
80
- || request.socket.remoteAddress
81
- || '';
82
- // throttle the connection
83
- return this.throttle(ip) ? Promise.reject() : Promise.resolve();
84
- }
1
+ class Throttle {
2
+ /**
3
+ * Constructor
4
+ */
5
+ constructor(configuration) {
6
+ this.configuration = {
7
+ throttle: 15,
8
+ banTime: 5,
9
+ consideredSeconds: 60,
10
+ cleanupInterval: 90,
11
+ };
12
+ this.connectionsByIp = new Map();
13
+ this.bannedIps = new Map();
14
+ this.configuration = {
15
+ ...this.configuration,
16
+ ...configuration,
17
+ };
18
+ this.cleanupInterval = setInterval(this.clearMaps.bind(this), this.configuration.cleanupInterval * 1000);
19
+ }
20
+ onDestroy() {
21
+ if (this.cleanupInterval) {
22
+ clearInterval(this.cleanupInterval);
23
+ }
24
+ return Promise.resolve();
25
+ }
26
+ clearMaps() {
27
+ this.connectionsByIp.forEach((value, key) => {
28
+ const filteredValue = value
29
+ .filter(timestamp => timestamp + (this.configuration.consideredSeconds * 1000) > Date.now());
30
+ if (filteredValue.length) {
31
+ this.connectionsByIp.set(key, filteredValue);
32
+ }
33
+ else {
34
+ this.connectionsByIp.delete(key);
35
+ }
36
+ });
37
+ this.bannedIps.forEach((value, key) => {
38
+ if (!this.isBanned(key)) {
39
+ this.bannedIps.delete(key);
40
+ }
41
+ });
42
+ }
43
+ isBanned(ip) {
44
+ const bannedAt = this.bannedIps.get(ip) || 0;
45
+ return Date.now() < (bannedAt + (this.configuration.banTime * 60 * 1000));
46
+ }
47
+ /**
48
+ * Throttle requests
49
+ * @private
50
+ */
51
+ throttle(ip) {
52
+ if (!this.configuration.throttle) {
53
+ return false;
54
+ }
55
+ if (this.isBanned(ip))
56
+ return true;
57
+ this.bannedIps.delete(ip);
58
+ // add this connection try to the list of previous connections
59
+ const previousConnections = this.connectionsByIp.get(ip) || [];
60
+ previousConnections.push(Date.now());
61
+ // calculate the previous connections in the last considered time interval
62
+ const previousConnectionsInTheConsideredInterval = previousConnections
63
+ .filter(timestamp => timestamp + (this.configuration.consideredSeconds * 1000) > Date.now());
64
+ this.connectionsByIp.set(ip, previousConnectionsInTheConsideredInterval);
65
+ if (previousConnectionsInTheConsideredInterval.length > this.configuration.throttle) {
66
+ this.bannedIps.set(ip, Date.now());
67
+ return true;
68
+ }
69
+ return false;
70
+ }
71
+ /**
72
+ * onConnect hook
73
+ * @param data
74
+ */
75
+ onConnect(data) {
76
+ const { request } = data;
77
+ // get the remote ip address
78
+ const ip = request.headers['x-real-ip']
79
+ || request.headers['x-forwarded-for']
80
+ || request.socket.remoteAddress
81
+ || '';
82
+ // throttle the connection
83
+ return this.throttle(ip) ? Promise.reject() : Promise.resolve();
84
+ }
85
85
  }
86
86
 
87
87
  export { Throttle };
@@ -1,29 +1,29 @@
1
- export interface CloseEvent {
2
- code: number;
3
- reason: string;
4
- }
5
- /**
6
- * The server is terminating the connection because a data frame was received
7
- * that is too large.
8
- * See: https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent/code
9
- */
10
- export declare const MessageTooBig: CloseEvent;
11
- /**
12
- * The server successfully processed the request, asks that the requester reset
13
- * its document view, and is not returning any content.
14
- */
15
- export declare const ResetConnection: CloseEvent;
16
- /**
17
- * Similar to Forbidden, but specifically for use when authentication is required and has
18
- * failed or has not yet been provided.
19
- */
20
- export declare const Unauthorized: CloseEvent;
21
- /**
22
- * The request contained valid data and was understood by the server, but the server
23
- * is refusing action.
24
- */
25
- export declare const Forbidden: CloseEvent;
26
- /**
27
- * The server timed out waiting for the request.
28
- */
29
- export declare const ConnectionTimeout: CloseEvent;
1
+ export interface CloseEvent {
2
+ code: number;
3
+ reason: string;
4
+ }
5
+ /**
6
+ * The server is terminating the connection because a data frame was received
7
+ * that is too large.
8
+ * See: https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent/code
9
+ */
10
+ export declare const MessageTooBig: CloseEvent;
11
+ /**
12
+ * The server successfully processed the request, asks that the requester reset
13
+ * its document view, and is not returning any content.
14
+ */
15
+ export declare const ResetConnection: CloseEvent;
16
+ /**
17
+ * Similar to Forbidden, but specifically for use when authentication is required and has
18
+ * failed or has not yet been provided.
19
+ */
20
+ export declare const Unauthorized: CloseEvent;
21
+ /**
22
+ * The request contained valid data and was understood by the server, but the server
23
+ * is refusing action.
24
+ */
25
+ export declare const Forbidden: CloseEvent;
26
+ /**
27
+ * The server timed out waiting for the request.
28
+ */
29
+ export declare const ConnectionTimeout: CloseEvent;
@@ -1,6 +1,6 @@
1
- import * as encoding from 'lib0/encoding';
2
- import * as decoding from 'lib0/decoding';
3
- export declare const writeAuthentication: (encoder: encoding.Encoder, auth: string) => void;
4
- export declare const writePermissionDenied: (encoder: encoding.Encoder, reason: string) => void;
5
- export declare const writeAuthenticated: (encoder: encoding.Encoder) => void;
6
- export declare const readAuthMessage: (decoder: decoding.Decoder, permissionDeniedHandler: (reason: string) => void, authenticatedHandler: () => void) => void;
1
+ import * as encoding from 'lib0/encoding';
2
+ import * as decoding from 'lib0/decoding';
3
+ export declare const writeAuthentication: (encoder: encoding.Encoder, auth: string) => void;
4
+ export declare const writePermissionDenied: (encoder: encoding.Encoder, reason: string) => void;
5
+ export declare const writeAuthenticated: (encoder: encoding.Encoder, scope: 'readonly' | 'read-write') => void;
6
+ export declare const readAuthMessage: (decoder: decoding.Decoder, permissionDeniedHandler: (reason: string) => void, authenticatedHandler: (scope: string) => void) => void;
@@ -1,3 +1,3 @@
1
- export declare const awarenessStatesToArray: (states: Map<number, Record<string, any>>) => {
2
- clientId: number;
3
- }[];
1
+ export declare const awarenessStatesToArray: (states: Map<number, Record<string, any>>) => {
2
+ clientId: number;
3
+ }[];
@@ -1,4 +1,4 @@
1
- export * from './auth';
2
- export * from './CloseEvents';
3
- export * from './awarenessStatesToArray';
4
- export * from './types';
1
+ export * from './auth.js';
2
+ export * from './CloseEvents.js';
3
+ export * from './awarenessStatesToArray.js';
4
+ export * from './types.js';
@@ -1,10 +1,10 @@
1
- /**
2
- * State of the WebSocket connection.
3
- * https://developer.mozilla.org/de/docs/Web/API/WebSocket/readyState
4
- */
5
- export declare enum WsReadyStates {
6
- Connecting = 0,
7
- Open = 1,
8
- Closing = 2,
9
- Closed = 3
10
- }
1
+ /**
2
+ * State of the WebSocket connection.
3
+ * https://developer.mozilla.org/de/docs/Web/API/WebSocket/readyState
4
+ */
5
+ export declare enum WsReadyStates {
6
+ Connecting = 0,
7
+ Open = 1,
8
+ Closing = 2,
9
+ Closed = 3
10
+ }
@@ -1,30 +1,30 @@
1
- import { Extension, onChangePayload, onLoadDocumentPayload, storePayload, fetchPayload } from '@hocuspocus/server';
2
- export interface DatabaseConfiguration {
3
- /**
4
- * Pass a Promise to retrieve updates from your database. The Promise should resolve to
5
- * an array of items with Y.js-compatible binary data.
6
- */
7
- fetch: (data: fetchPayload) => Promise<Uint8Array | null>;
8
- /**
9
- * Pass a function to store updates in your database.
10
- */
11
- store: (data: storePayload) => void;
12
- }
13
- export declare class Database implements Extension {
14
- /**
15
- * Default configuration
16
- */
17
- configuration: DatabaseConfiguration;
18
- /**
19
- * Constructor
20
- */
21
- constructor(configuration: Partial<DatabaseConfiguration>);
22
- /**
23
- * Get stored data from the database.
24
- */
25
- onLoadDocument(data: onLoadDocumentPayload): Promise<any>;
26
- /**
27
- * Store new updates in the database.
28
- */
29
- onStoreDocument(data: onChangePayload): Promise<void>;
30
- }
1
+ import { Extension, onChangePayload, onLoadDocumentPayload, storePayload, fetchPayload } from '@hocuspocus/server';
2
+ export interface DatabaseConfiguration {
3
+ /**
4
+ * Pass a Promise to retrieve updates from your database. The Promise should resolve to
5
+ * an array of items with Y.js-compatible binary data.
6
+ */
7
+ fetch: (data: fetchPayload) => Promise<Uint8Array | null>;
8
+ /**
9
+ * Pass a function to store updates in your database.
10
+ */
11
+ store: (data: storePayload) => void;
12
+ }
13
+ export declare class Database implements Extension {
14
+ /**
15
+ * Default configuration
16
+ */
17
+ configuration: DatabaseConfiguration;
18
+ /**
19
+ * Constructor
20
+ */
21
+ constructor(configuration: Partial<DatabaseConfiguration>);
22
+ /**
23
+ * Get stored data from the database.
24
+ */
25
+ onLoadDocument(data: onLoadDocumentPayload): Promise<any>;
26
+ /**
27
+ * Store new updates in the database.
28
+ */
29
+ onStoreDocument(data: onChangePayload): Promise<void>;
30
+ }
@@ -1 +1 @@
1
- export * from './Database';
1
+ export * from './Database.js';
@@ -1,67 +1,67 @@
1
- import { Extension, onChangePayload, onConfigurePayload, onConnectPayload, onLoadDocumentPayload, onDestroyPayload, onDisconnectPayload, onRequestPayload, onUpgradePayload } from '@hocuspocus/server';
2
- export interface LoggerConfiguration {
3
- /**
4
- * Prepend all logging message with a string.
5
- *
6
- * @deprecated
7
- */
8
- prefix: null | string;
9
- /**
10
- * Whether to log something for the `onLoadDocument` hook.
11
- */
12
- onLoadDocument: boolean;
13
- /**
14
- * Whether to log something for the `onChange` hook.
15
- */
16
- onChange: boolean;
17
- /**
18
- * Whether to log something for the `onStoreDocument` hook.
19
- */
20
- onStoreDocument: boolean;
21
- /**
22
- * Whether to log something for the `onConnect` hook.
23
- */
24
- onConnect: boolean;
25
- /**
26
- * Whether to log something for the `onDisconnect` hook.
27
- */
28
- onDisconnect: boolean;
29
- /**
30
- * Whether to log something for the `onUpgrade` hook.
31
- */
32
- onUpgrade: boolean;
33
- /**
34
- * Whether to log something for the `onRequest` hook.
35
- */
36
- onRequest: boolean;
37
- /**
38
- * Whether to log something for the `onDestroy` hook.
39
- */
40
- onDestroy: boolean;
41
- /**
42
- * Whether to log something for the `onConfigure` hook.
43
- */
44
- onConfigure: boolean;
45
- /**
46
- * A log function, if none is provided output will go to console
47
- */
48
- log: (...args: any[]) => void;
49
- }
50
- export declare class Logger implements Extension {
51
- name: string | null;
52
- configuration: LoggerConfiguration;
53
- /**
54
- * Constructor
55
- */
56
- constructor(configuration?: Partial<LoggerConfiguration>);
57
- onConfigure(data: onConfigurePayload): Promise<void>;
58
- onLoadDocument(data: onLoadDocumentPayload): Promise<void>;
59
- onChange(data: onChangePayload): Promise<void>;
60
- onStoreDocument(data: onDisconnectPayload): Promise<void>;
61
- onConnect(data: onConnectPayload): Promise<void>;
62
- onDisconnect(data: onDisconnectPayload): Promise<void>;
63
- onUpgrade(data: onUpgradePayload): Promise<void>;
64
- onRequest(data: onRequestPayload): Promise<void>;
65
- onDestroy(data: onDestroyPayload): Promise<void>;
66
- private log;
67
- }
1
+ import { Extension, onChangePayload, onConfigurePayload, onConnectPayload, onLoadDocumentPayload, onDestroyPayload, onDisconnectPayload, onRequestPayload, onUpgradePayload } from '@hocuspocus/server';
2
+ export interface LoggerConfiguration {
3
+ /**
4
+ * Prepend all logging message with a string.
5
+ *
6
+ * @deprecated
7
+ */
8
+ prefix: null | string;
9
+ /**
10
+ * Whether to log something for the `onLoadDocument` hook.
11
+ */
12
+ onLoadDocument: boolean;
13
+ /**
14
+ * Whether to log something for the `onChange` hook.
15
+ */
16
+ onChange: boolean;
17
+ /**
18
+ * Whether to log something for the `onStoreDocument` hook.
19
+ */
20
+ onStoreDocument: boolean;
21
+ /**
22
+ * Whether to log something for the `onConnect` hook.
23
+ */
24
+ onConnect: boolean;
25
+ /**
26
+ * Whether to log something for the `onDisconnect` hook.
27
+ */
28
+ onDisconnect: boolean;
29
+ /**
30
+ * Whether to log something for the `onUpgrade` hook.
31
+ */
32
+ onUpgrade: boolean;
33
+ /**
34
+ * Whether to log something for the `onRequest` hook.
35
+ */
36
+ onRequest: boolean;
37
+ /**
38
+ * Whether to log something for the `onDestroy` hook.
39
+ */
40
+ onDestroy: boolean;
41
+ /**
42
+ * Whether to log something for the `onConfigure` hook.
43
+ */
44
+ onConfigure: boolean;
45
+ /**
46
+ * A log function, if none is provided output will go to console
47
+ */
48
+ log: (...args: any[]) => void;
49
+ }
50
+ export declare class Logger implements Extension {
51
+ name: string | null;
52
+ configuration: LoggerConfiguration;
53
+ /**
54
+ * Constructor
55
+ */
56
+ constructor(configuration?: Partial<LoggerConfiguration>);
57
+ onConfigure(data: onConfigurePayload): Promise<void>;
58
+ onLoadDocument(data: onLoadDocumentPayload): Promise<void>;
59
+ onChange(data: onChangePayload): Promise<void>;
60
+ onStoreDocument(data: onDisconnectPayload): Promise<void>;
61
+ onConnect(data: onConnectPayload): Promise<void>;
62
+ onDisconnect(data: onDisconnectPayload): Promise<void>;
63
+ onUpgrade(data: onUpgradePayload): Promise<void>;
64
+ onRequest(data: onRequestPayload): Promise<void>;
65
+ onDestroy(data: onDestroyPayload): Promise<void>;
66
+ private log;
67
+ }
@@ -1 +1 @@
1
- export * from './Logger';
1
+ export * from './Logger.js';