jupyter-webrtc-provider 0.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.
package/LICENSE ADDED
@@ -0,0 +1,30 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2014 Kevin Jahns <kevin.jahns@rwth-aachen.de>.
4
+ Copyright (c) 2026, David Brochart
5
+ All rights reserved.
6
+
7
+ Redistribution and use in source and binary forms, with or without
8
+ modification, are permitted provided that the following conditions are met:
9
+
10
+ 1. Redistributions of source code must retain the above copyright notice, this
11
+ list of conditions and the following disclaimer.
12
+
13
+ 2. Redistributions in binary form must reproduce the above copyright notice,
14
+ this list of conditions and the following disclaimer in the documentation
15
+ and/or other materials provided with the distribution.
16
+
17
+ 3. Neither the name of the copyright holder nor the names of its
18
+ contributors may be used to endorse or promote products derived from
19
+ this software without specific prior written permission.
20
+
21
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/README.md ADDED
@@ -0,0 +1,84 @@
1
+ # jupyter_webrtc_provider
2
+
3
+ [![Github Actions Status](https://github.com/davidbrochart/jupyter-webrtc-provider/workflows/Build/badge.svg)](https://github.com/davidbrochart/jupyter-webrtc-provider/actions/workflows/build.yml)
4
+
5
+ A JupyterLab extension for a WebRTC shared document provider.
6
+
7
+ ## Requirements
8
+
9
+ - JupyterLab >= 4.0.0
10
+
11
+ ## Install
12
+
13
+ To install the extension, execute:
14
+
15
+ ```bash
16
+ pip install jupyter_webrtc_provider
17
+ ```
18
+
19
+ ## Uninstall
20
+
21
+ To remove the extension, execute:
22
+
23
+ ```bash
24
+ pip uninstall jupyter_webrtc_provider
25
+ ```
26
+
27
+ ## Contributing
28
+
29
+ ### Development install
30
+
31
+ Note: You will need NodeJS to build the extension package.
32
+
33
+ The `jlpm` command is JupyterLab's pinned version of
34
+ [yarn](https://yarnpkg.com/) that is installed with JupyterLab. You may use
35
+ `yarn` or `npm` in lieu of `jlpm` below.
36
+
37
+ ```bash
38
+ # Clone the repo to your local environment
39
+ # Change directory to the jupyter_webrtc_provider directory
40
+
41
+ # Set up a virtual environment and install package in development mode
42
+ python -m venv .venv
43
+ source .venv/bin/activate
44
+ pip install --editable "."
45
+
46
+ # Link your development version of the extension with JupyterLab
47
+ jupyter labextension develop . --overwrite
48
+
49
+ # Rebuild extension Typescript source after making changes
50
+ # IMPORTANT: Unlike the steps above which are performed only once, do this step
51
+ # every time you make a change.
52
+ jlpm build
53
+ ```
54
+
55
+ You can watch the source directory and run JupyterLab at the same time in different terminals to watch for changes in the extension's source and automatically rebuild the extension.
56
+
57
+ ```bash
58
+ # Watch the source directory in one terminal, automatically rebuilding when needed
59
+ jlpm watch
60
+ # Run JupyterLab in another terminal
61
+ jupyter lab
62
+ ```
63
+
64
+ With the watch command running, every saved change will immediately be built locally and available in your running JupyterLab. Refresh JupyterLab to load the change in your browser (you may need to wait several seconds for the extension to be rebuilt).
65
+
66
+ By default, the `jlpm build` command generates the source maps for this extension to make it easier to debug using the browser dev tools. To also generate source maps for the JupyterLab core extensions, you can run the following command:
67
+
68
+ ```bash
69
+ jupyter lab build --minimize=False
70
+ ```
71
+
72
+ ### Development uninstall
73
+
74
+ ```bash
75
+ pip uninstall jupyter_webrtc_provider
76
+ ```
77
+
78
+ In development mode, you will also need to remove the symlink created by `jupyter labextension develop`
79
+ command. To find its location, you can run `jupyter labextension list` to figure out where the `labextensions`
80
+ folder is located. Then you can remove the symlink named `jupyter-webrtc-provider` within that folder.
81
+
82
+ ### Packaging the extension
83
+
84
+ See [RELEASE](RELEASE.md)
@@ -0,0 +1,60 @@
1
+ import { ServerConnection, User } from '@jupyterlab/services';
2
+ import { IAwareness } from '@jupyter/ydoc';
3
+ import { IWebSocketFactory } from './websocket';
4
+ import { WebrtcProvider } from './webrtc';
5
+ export interface IContent {
6
+ type: string;
7
+ body: string;
8
+ }
9
+ /**
10
+ * A class to provide Yjs synchronization over WebRTC.
11
+ *
12
+ */
13
+ export declare class WebRTCAwarenessProvider extends WebrtcProvider {
14
+ /**
15
+ * Construct a new WebRTCAwarenessProvider
16
+ *
17
+ * @param options The instantiation options for a WebRTCAwarenessProvider
18
+ */
19
+ constructor(options: WebRTCAwarenessProvider.IOptions);
20
+ get isDisposed(): boolean;
21
+ dispose(): void;
22
+ private _onUserChanged;
23
+ readonly awareness: IAwareness;
24
+ private _isDisposed;
25
+ private _user;
26
+ }
27
+ /**
28
+ * A namespace for WebRTCAwarenessProvider statics.
29
+ */
30
+ export declare namespace WebRTCAwarenessProvider {
31
+ /**
32
+ * The instantiation options for a WebRTCAwarenessProvider.
33
+ */
34
+ interface IOptions {
35
+ /**
36
+ * The room ID
37
+ */
38
+ roomID: string;
39
+ /**
40
+ * The awareness object
41
+ */
42
+ awareness: IAwareness;
43
+ /**
44
+ * The user data
45
+ */
46
+ user: User.IManager;
47
+ /**
48
+ * The server settings.
49
+ */
50
+ serverSettings?: ServerConnection.ISettings;
51
+ /**
52
+ * The signaling server URLs for WebRTC.
53
+ */
54
+ signalingServers: string[];
55
+ /**
56
+ * Factory function to create WebSocket connections.
57
+ */
58
+ webSocketFactory: IWebSocketFactory;
59
+ }
60
+ }
@@ -0,0 +1,41 @@
1
+ import { WebrtcProvider } from './webrtc';
2
+ /**
3
+ * A class to provide Yjs synchronization over WebRTC.
4
+ *
5
+ */
6
+ export class WebRTCAwarenessProvider extends WebrtcProvider {
7
+ /**
8
+ * Construct a new WebRTCAwarenessProvider
9
+ *
10
+ * @param options The instantiation options for a WebRTCAwarenessProvider
11
+ */
12
+ constructor(options) {
13
+ super(options.roomID, options.awareness.doc, {
14
+ signaling: options.signalingServers,
15
+ awareness: options.awareness,
16
+ webSocketFactory: options.webSocketFactory
17
+ });
18
+ this._isDisposed = false;
19
+ this.awareness = options.awareness;
20
+ this._user = options.user;
21
+ this._user.ready
22
+ .then(() => this._onUserChanged(this._user))
23
+ .catch(e => console.error(e));
24
+ this._user.userChanged.connect(this._onUserChanged, this);
25
+ }
26
+ get isDisposed() {
27
+ return this._isDisposed;
28
+ }
29
+ dispose() {
30
+ if (this._isDisposed) {
31
+ return;
32
+ }
33
+ this._user.userChanged.disconnect(this._onUserChanged, this);
34
+ this._isDisposed = true;
35
+ this.destroy();
36
+ }
37
+ _onUserChanged(user) {
38
+ this.awareness.setLocalStateField('user', user.identity);
39
+ }
40
+ }
41
+ //# sourceMappingURL=awareness.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"awareness.js","sourceRoot":"","sources":["../src/awareness.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAO1C;;;GAGG;AACH,MAAM,OAAO,uBAAwB,SAAQ,cAAc;IACzD;;;;OAIG;IACH,YAAY,OAAyC;QACnD,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,SAAS,CAAC,GAAG,EAAE;YAC3C,SAAS,EAAE,OAAO,CAAC,gBAAgB;YACnC,SAAS,EAAE,OAAO,CAAC,SAAS;YAC5B,gBAAgB,EAAE,OAAO,CAAC,gBAAgB;SAC3C,CAAC,CAAC;QA4BG,gBAAW,GAAG,KAAK,CAAC;QA3B1B,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;QACnC,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC;QAC1B,IAAI,CAAC,KAAK,CAAC,KAAK;aACb,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aAC3C,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QAChC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC;IAC5D,CAAC;IAED,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAED,OAAO;QACL,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACrB,OAAO;QACT,CAAC;QAED,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC;QAC7D,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,IAAI,CAAC,OAAO,EAAE,CAAC;IACjB,CAAC;IAEO,cAAc,CAAC,IAAmB;QACxC,IAAI,CAAC,SAAS,CAAC,kBAAkB,CAAC,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC3D,CAAC;CAKF"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Derive a cryptographic key from a secret and room name using PBKDF2.
3
+ */
4
+ export declare const deriveKey: (secret: string, roomName: string) => Promise<CryptoKey>;
5
+ /**
6
+ * Encrypt data using AES-GCM encryption.
7
+ */
8
+ export declare const encrypt: (data: Uint8Array, key: CryptoKey | null) => Promise<Uint8Array>;
9
+ /**
10
+ * Encrypt a JSON-serializable object using AES-GCM encryption.
11
+ */
12
+ export declare const encryptJson: (data: any, key: CryptoKey | null) => Promise<Uint8Array>;
13
+ /**
14
+ * Decrypt data using AES-GCM decryption.
15
+ */
16
+ export declare const decrypt: (data: Uint8Array, key: CryptoKey | null) => Promise<Uint8Array>;
17
+ /**
18
+ * Decrypt data and parse it as JSON.
19
+ */
20
+ export declare const decryptJson: (data: Uint8Array, key: CryptoKey | null) => Promise<any>;
package/lib/crypto.js ADDED
@@ -0,0 +1,76 @@
1
+ import * as encoding from 'lib0/encoding';
2
+ import * as decoding from 'lib0/decoding';
3
+ import * as string from 'lib0/string';
4
+ /**
5
+ * Derive a cryptographic key from a secret and room name using PBKDF2.
6
+ */
7
+ export const deriveKey = (secret, roomName) => {
8
+ const secretBuffer = string.encodeUtf8(secret).buffer;
9
+ const salt = string.encodeUtf8(roomName).buffer;
10
+ return crypto.subtle
11
+ .importKey('raw', secretBuffer, 'PBKDF2', false, ['deriveKey'])
12
+ .then(keyMaterial => crypto.subtle.deriveKey({
13
+ name: 'PBKDF2',
14
+ salt,
15
+ iterations: 100000,
16
+ hash: 'SHA-256'
17
+ }, keyMaterial, {
18
+ name: 'AES-GCM',
19
+ length: 256
20
+ }, true, ['encrypt', 'decrypt']));
21
+ };
22
+ /**
23
+ * Encrypt data using AES-GCM encryption.
24
+ */
25
+ export const encrypt = (data, key) => {
26
+ if (!key) {
27
+ return Promise.resolve(data);
28
+ }
29
+ const iv = crypto.getRandomValues(new Uint8Array(12));
30
+ return crypto.subtle
31
+ .encrypt({
32
+ name: 'AES-GCM',
33
+ iv
34
+ }, key, data)
35
+ .then(cipher => {
36
+ const encryptedDataEncoder = encoding.createEncoder();
37
+ encoding.writeVarString(encryptedDataEncoder, 'AES-GCM');
38
+ encoding.writeVarUint8Array(encryptedDataEncoder, iv);
39
+ encoding.writeVarUint8Array(encryptedDataEncoder, new Uint8Array(cipher));
40
+ return encoding.toUint8Array(encryptedDataEncoder);
41
+ });
42
+ };
43
+ /**
44
+ * Encrypt a JSON-serializable object using AES-GCM encryption.
45
+ */
46
+ export const encryptJson = (data, key) => {
47
+ const dataEncoder = encoding.createEncoder();
48
+ encoding.writeAny(dataEncoder, data);
49
+ return encrypt(encoding.toUint8Array(dataEncoder), key);
50
+ };
51
+ /**
52
+ * Decrypt data using AES-GCM decryption.
53
+ */
54
+ export const decrypt = (data, key) => {
55
+ if (!key) {
56
+ return Promise.resolve(data);
57
+ }
58
+ const dataDecoder = decoding.createDecoder(data);
59
+ const algorithm = decoding.readVarString(dataDecoder);
60
+ if (algorithm !== 'AES-GCM') {
61
+ throw new Error('Unknown encryption algorithm');
62
+ }
63
+ const iv = decoding.readVarUint8Array(dataDecoder);
64
+ const cipher = decoding.readVarUint8Array(dataDecoder);
65
+ return crypto.subtle
66
+ .decrypt({
67
+ name: 'AES-GCM',
68
+ iv
69
+ }, key, cipher)
70
+ .then(decrypted => new Uint8Array(decrypted));
71
+ };
72
+ /**
73
+ * Decrypt data and parse it as JSON.
74
+ */
75
+ export const decryptJson = (data, key) => decrypt(data, key).then(decryptedValue => decoding.readAny(decoding.createDecoder(new Uint8Array(decryptedValue))));
76
+ //# sourceMappingURL=crypto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crypto.js","sourceRoot":"","sources":["../src/crypto.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AAEtC;;GAEG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,MAAc,EACd,QAAgB,EACI,EAAE;IACtB,MAAM,YAAY,GAAG,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC;IACtD,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC;IAChD,OAAO,MAAM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EAAE,CACvC,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,UAAU,CAAC,cAAc,CAAC,CAAC,CAAC,CACzE,CAAC"}
package/lib/index.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ export { IWebSocketFactory } from './websocket';
2
+ import { JupyterFrontEndPlugin } from '@jupyterlab/application';
3
+ import { awarenessProviderFactoryPlugin, documentProviderFactoryPlugin } from './provider';
4
+ export { awarenessProviderFactoryPlugin, documentProviderFactoryPlugin };
5
+ declare const plugins: JupyterFrontEndPlugin<unknown>[];
6
+ export default plugins;
package/lib/index.js ADDED
@@ -0,0 +1,9 @@
1
+ export { IWebSocketFactory } from './websocket';
2
+ import { awarenessProviderFactoryPlugin, documentProviderFactoryPlugin } from './provider';
3
+ export { awarenessProviderFactoryPlugin, documentProviderFactoryPlugin };
4
+ const plugins = [
5
+ documentProviderFactoryPlugin,
6
+ awarenessProviderFactoryPlugin
7
+ ];
8
+ export default plugins;
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAIhD,OAAO,EACL,8BAA8B,EAC9B,6BAA6B,EAC9B,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,8BAA8B,EAAE,6BAA6B,EAAE,CAAC;AAEzE,MAAM,OAAO,GAAqC;IAChD,6BAA6B;IAC7B,8BAA8B;CAC/B,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -0,0 +1,110 @@
1
+ import { IAwarenessProviderFactory, IDocumentProviderFactory } from '@jupyter/docprovider';
2
+ import { JupyterFrontEndPlugin } from '@jupyterlab/application';
3
+ import { TranslationBundle } from '@jupyterlab/translation';
4
+ import { IDocumentProvider } from '@jupyter/collaborative-drive';
5
+ import { ServerConnection, User, Contents } from '@jupyterlab/services';
6
+ import { DocumentChange, YDocument } from '@jupyter/ydoc';
7
+ import { IForkProvider } from '@jupyter/docprovider';
8
+ import { IWebSocketFactory } from './websocket';
9
+ /**
10
+ * A class to provide Yjs synchronization over WebRTC.
11
+ *
12
+ */
13
+ export declare class WebRTCProvider implements IDocumentProvider, IForkProvider {
14
+ /**
15
+ * Construct a new WebRTCProvider
16
+ *
17
+ * @param options The instantiation options for a WebRTCProvider
18
+ */
19
+ constructor(options: WebRTCProvider.IOptions);
20
+ /**
21
+ * Test whether the object has been disposed.
22
+ */
23
+ get isDisposed(): boolean;
24
+ /**
25
+ * A promise that resolves when the document provider is ready.
26
+ */
27
+ get ready(): Promise<void>;
28
+ get contentType(): string;
29
+ get format(): string;
30
+ /**
31
+ * Dispose of the resources held by the object.
32
+ */
33
+ dispose(): void;
34
+ reconnect(): Promise<void>;
35
+ private _connect;
36
+ connectToForkDoc(forkRoomId: string, sessionId: string): Promise<void>;
37
+ save(): Promise<void>;
38
+ private _disconnect;
39
+ private _onUserChanged;
40
+ private _onSynced;
41
+ private _awareness;
42
+ private _contentType;
43
+ private _format;
44
+ private _isDisposed;
45
+ private _path;
46
+ private _ready;
47
+ private _sharedModel;
48
+ private _webrtcProvider;
49
+ private _signalingServers;
50
+ private _drive;
51
+ private _webSocketFactory;
52
+ }
53
+ /**
54
+ * A namespace for WebRTCProvider statics.
55
+ */
56
+ export declare namespace WebRTCProvider {
57
+ /**
58
+ * The instantiation options for a WebRTCProvider.
59
+ */
60
+ interface IOptions {
61
+ /**
62
+ * The document file path
63
+ */
64
+ path: string;
65
+ /**
66
+ * Content type
67
+ */
68
+ contentType: string;
69
+ /**
70
+ * The source format
71
+ */
72
+ format: string;
73
+ /**
74
+ * The shared model
75
+ */
76
+ model: YDocument<DocumentChange>;
77
+ /**
78
+ * The user data
79
+ */
80
+ user: User.IManager;
81
+ /**
82
+ * The jupyterlab translator
83
+ */
84
+ translator: TranslationBundle;
85
+ /**
86
+ * The server settings.
87
+ */
88
+ serverSettings?: ServerConnection.ISettings;
89
+ /**
90
+ * The signaling server URLs for WebRTC.
91
+ */
92
+ signalingServers: string[];
93
+ /**
94
+ * The drive to use for loading and saving document content.
95
+ */
96
+ drive: Contents.IDrive;
97
+ /**
98
+ * Factory function to create WebSocket connections.
99
+ */
100
+ webSocketFactory: IWebSocketFactory;
101
+ }
102
+ }
103
+ /**
104
+ * Plugin that provides the WebRTC document provider factory.
105
+ */
106
+ export declare const documentProviderFactoryPlugin: JupyterFrontEndPlugin<IDocumentProviderFactory>;
107
+ /**
108
+ * Plugin that provides the WebRTC awareness provider factory.
109
+ */
110
+ export declare const awarenessProviderFactoryPlugin: JupyterFrontEndPlugin<IAwarenessProviderFactory>;