@hocuspocus/provider 1.0.0-alpha.22 → 1.0.0-alpha.26
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-provider.cjs +278 -68
- package/dist/hocuspocus-provider.cjs.map +1 -1
- package/dist/hocuspocus-provider.esm.js +278 -68
- package/dist/hocuspocus-provider.esm.js.map +1 -1
- package/dist/{shared/protocols → packages/common/src}/auth.d.ts +0 -0
- package/dist/packages/common/src/index.d.ts +1 -0
- package/dist/packages/server/src/Hocuspocus.d.ts +2 -3
- package/dist/packages/server/src/types.d.ts +5 -0
- package/package.json +3 -6
- package/src/HocuspocusProvider.ts +6 -6
- package/src/MessageReceiver.ts +1 -1
- package/src/OutgoingMessages/AuthenticationMessage.ts +1 -1
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './auth';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import WebSocket, { WebSocketServer } from 'ws';
|
|
3
3
|
import { IncomingMessage, Server as HTTPServer } from 'http';
|
|
4
|
-
import { Configuration } from './types';
|
|
4
|
+
import { Configuration, Hook } from './types';
|
|
5
5
|
import { MessageLogger } from './Debugger';
|
|
6
6
|
export declare const defaultConfiguration: {
|
|
7
7
|
name: null;
|
|
@@ -64,9 +64,8 @@ export declare class Hocuspocus {
|
|
|
64
64
|
/**
|
|
65
65
|
* Run the given hook on all configured extensions
|
|
66
66
|
* Runs the given callback after each hook
|
|
67
|
-
* @private
|
|
68
67
|
*/
|
|
69
|
-
|
|
68
|
+
hooks(name: Hook, payload: any, callback?: Function | null): Promise<any>;
|
|
70
69
|
/**
|
|
71
70
|
* Get parameters by the given request
|
|
72
71
|
* @private
|
|
@@ -45,6 +45,11 @@ export interface Extension {
|
|
|
45
45
|
onRequest?(data: onRequestPayload): Promise<any>;
|
|
46
46
|
onUpgrade?(data: onUpgradePayload): Promise<any>;
|
|
47
47
|
}
|
|
48
|
+
export declare type Hook = 'onAuthenticate' | 'onChange' | 'onConnect' | 'onConfigure' |
|
|
49
|
+
/**
|
|
50
|
+
* @deprecated onCreateDocument is deprecated, use onLoadDocument instead
|
|
51
|
+
*/
|
|
52
|
+
'onCreateDocument' | 'onLoadDocument' | 'onDestroy' | 'onDisconnect' | 'onListen' | 'onRequest' | 'onUpgrade';
|
|
48
53
|
export interface Configuration extends Extension {
|
|
49
54
|
/**
|
|
50
55
|
* A name for the instance, used for logging.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hocuspocus/provider",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.26",
|
|
4
4
|
"description": "hocuspocus provider",
|
|
5
5
|
"homepage": "https://hocuspocus.dev",
|
|
6
6
|
"keywords": [
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"module": "dist/hocuspocus-provider.esm.js",
|
|
16
16
|
"types": "dist/packages/provider/src/index.d.ts",
|
|
17
17
|
"exports": {
|
|
18
|
-
"
|
|
18
|
+
"source": {
|
|
19
19
|
"import": "./src"
|
|
20
20
|
},
|
|
21
21
|
"default": {
|
|
@@ -33,8 +33,5 @@
|
|
|
33
33
|
"y-protocols": "^1.0.5",
|
|
34
34
|
"yjs": "^13.5.0"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
37
|
-
"publishConfig": {
|
|
38
|
-
"access": "public"
|
|
39
|
-
}
|
|
36
|
+
"gitHead": "0d060abd95ec14eb7e404270e1e2338b2a0db332"
|
|
40
37
|
}
|
|
@@ -275,11 +275,11 @@ export class HocuspocusProvider extends EventEmitter {
|
|
|
275
275
|
}
|
|
276
276
|
},
|
|
277
277
|
})
|
|
278
|
-
} catch (
|
|
279
|
-
// If we aborted the connection attempt then don
|
|
278
|
+
} catch (error: any) {
|
|
279
|
+
// If we aborted the connection attempt then don’t throw an error
|
|
280
280
|
// ref: https://github.com/lifeomic/attempt/blob/master/src/index.ts#L136
|
|
281
|
-
if (
|
|
282
|
-
throw
|
|
281
|
+
if (error && error.code !== 'ATTEMPT_ABORTED') {
|
|
282
|
+
throw error
|
|
283
283
|
}
|
|
284
284
|
}
|
|
285
285
|
}
|
|
@@ -475,8 +475,6 @@ export class HocuspocusProvider extends EventEmitter {
|
|
|
475
475
|
}
|
|
476
476
|
|
|
477
477
|
this.startSync()
|
|
478
|
-
|
|
479
|
-
this.resolveConnectionAttempt()
|
|
480
478
|
}
|
|
481
479
|
|
|
482
480
|
startSync() {
|
|
@@ -504,6 +502,8 @@ export class HocuspocusProvider extends EventEmitter {
|
|
|
504
502
|
}
|
|
505
503
|
|
|
506
504
|
onMessage(event: MessageEvent) {
|
|
505
|
+
this.resolveConnectionAttempt()
|
|
506
|
+
|
|
507
507
|
this.lastMessageReceived = time.getUnixTime()
|
|
508
508
|
|
|
509
509
|
const message = new IncomingMessage(event.data)
|
package/src/MessageReceiver.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as awarenessProtocol from 'y-protocols/awareness'
|
|
2
2
|
import { readSyncMessage, messageYjsSyncStep2 } from 'y-protocols/sync'
|
|
3
|
+
import { readAuthMessage } from '@hocuspocus/common'
|
|
3
4
|
import { MessageType } from './types'
|
|
4
5
|
import { HocuspocusProvider } from './HocuspocusProvider'
|
|
5
6
|
import { IncomingMessage } from './IncomingMessage'
|
|
6
|
-
import { readAuthMessage } from '../../../shared/protocols/auth'
|
|
7
7
|
import { OutgoingMessage } from './OutgoingMessage'
|
|
8
8
|
|
|
9
9
|
export class MessageReceiver {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { writeVarUint } from 'lib0/encoding'
|
|
2
|
-
import { writeAuthentication } from '
|
|
2
|
+
import { writeAuthentication } from '@hocuspocus/common'
|
|
3
3
|
import { MessageType, OutgoingMessageArguments } from '../types'
|
|
4
4
|
import { OutgoingMessage } from '../OutgoingMessage'
|
|
5
5
|
|