openrtc-tauri 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,92 @@
1
+ Required Notice: Copyright (c) 2026 Bryant Hargreaves and OpenRTC contributors.
2
+ Licensor Line of Business: OpenRTC realtime collaboration runtime, SDKs, developer services, and related tools (https://openrtc.app)
3
+
4
+ # PolyForm Shield License 1.0.0
5
+
6
+ <https://polyformproject.org/licenses/shield/1.0.0>
7
+
8
+ ## Acceptance
9
+
10
+ In order to get any license under these terms, you must agree to them as both strict obligations and conditions to all your licenses.
11
+
12
+ ## Copyright License
13
+
14
+ The licensor grants you a copyright license for the software to do everything you might do with the software that would otherwise infringe the licensor's copyright in it for any permitted purpose. However, you may only distribute the software according to [Distribution License](#distribution-license) and make changes or new works based on the software according to [Changes and New Works License](#changes-and-new-works-license).
15
+
16
+ ## Distribution License
17
+
18
+ The licensor grants you an additional copyright license to distribute copies of the software. Your license to distribute covers distributing the software with changes and new works permitted by [Changes and New Works License](#changes-and-new-works-license).
19
+
20
+ ## Notices
21
+
22
+ You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms or the URL for them above, as well as copies of any plain-text lines beginning with `Required Notice:` that the licensor provided with the software. For example:
23
+
24
+ > Required Notice: Copyright Yoyodyne, Inc. (http://example.com)
25
+
26
+ ## Changes and New Works License
27
+
28
+ The licensor grants you an additional copyright license to make changes and new works based on the software for any permitted purpose.
29
+
30
+ ## Patent License
31
+
32
+ The licensor grants you a patent license for the software that covers patent claims the licensor can license, or becomes able to license, that you would infringe by using the software.
33
+
34
+ ## Noncompete
35
+
36
+ Any purpose is a permitted purpose, except for providing any product that competes with the software or any product the licensor or any of its affiliates provides using the software.
37
+
38
+ ## Competition
39
+
40
+ Goods and services compete even when they provide functionality through different kinds of interfaces or for different technical platforms. Applications can compete with services, libraries with plugins, frameworks with development tools, and so on, even if they're written in different programming languages or for different computer architectures. Goods and services compete even when provided free of charge. If you market a product as a practical substitute for the software or another product, it definitely competes.
41
+
42
+ ## New Products
43
+
44
+ If you are using the software to provide a product that does not compete, but the licensor or any of its affiliates brings your product into competition by providing a new version of the software or another product using the software, you may continue using versions of the software available under these terms beforehand to provide your competing product, but not any later versions.
45
+
46
+ ## Discontinued Products
47
+
48
+ You may begin using the software to compete with a product or service that the licensor or any of its affiliates has stopped providing, unless the licensor includes a plain-text line beginning with `Licensor Line of Business:` with the software that mentions that line of business. For example:
49
+
50
+ > Licensor Line of Business: YoyodyneCMS Content Management System (http://example.com/cms)
51
+
52
+ ## Sales of Business
53
+
54
+ If the licensor or any of its affiliates sells a line of business developing the software or using the software to provide a product, the buyer can also enforce [Noncompete](#noncompete) for that product.
55
+
56
+ ## Fair Use
57
+
58
+ You may have "fair use" rights for the software under the law. These terms do not limit them.
59
+
60
+ ## No Other Rights
61
+
62
+ These terms do not allow you to sublicense or transfer any of your licenses to anyone else, or prevent the licensor from granting licenses to anyone else. These terms do not imply any other licenses.
63
+
64
+ ## Patent Defense
65
+
66
+ If you make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
67
+
68
+ ## Violations
69
+
70
+ The first time you are notified in writing that you have violated any of these terms, or done anything with the software not covered by your licenses, your licenses can nonetheless continue if you come into full compliance with these terms, and take practical steps to correct past violations, within 32 days of receiving notice. Otherwise, all your licenses end immediately.
71
+
72
+ ## No Liability
73
+
74
+ ***As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.***
75
+
76
+ ## Definitions
77
+
78
+ The **licensor** is the individual or entity offering these terms, and the **software** is the software the licensor makes available under these terms.
79
+
80
+ A **product** can be a good or service, or a combination of them.
81
+
82
+ **You** refers to the individual or entity agreeing to these terms.
83
+
84
+ **Your company** is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all its affiliates.
85
+
86
+ **Affiliates** means the other organizations than an organization has control over, is under the control of, or is under common control with.
87
+
88
+ **Control** means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
89
+
90
+ **Your licenses** are all the licenses granted to you for the software under these terms.
91
+
92
+ **Use** means anything you do with the software requiring one of your licenses.
package/README.md ADDED
@@ -0,0 +1,109 @@
1
+ # openrtc-tauri
2
+
3
+ First-party Tauri adapter package for [`openrtc`](https://www.npmjs.com/package/openrtc).
4
+
5
+ Use this package when you want `OpenRTC.native(...)` or a native IPC runtime in a
6
+ Tauri desktop or mobile application.
7
+
8
+ This package pairs with the first-party Rust crate `openrtc-tauri-plugin`. The
9
+ TypeScript bridge invokes the registered plugin command namespace
10
+ (`plugin:openrtc-tauri-plugin|...`) and falls back to the legacy
11
+ `plugin:openrtc|...` namespace only for older hosts during migration. It does
12
+ not fall back to bare Tauri command names unless you explicitly pass
13
+ `fallbackToBareCommands: true` to `createTauriIpcBridge(...)`. Without the Rust
14
+ plugin, `OpenRTC.native(...)` fails closed by design instead of silently falling
15
+ back to the browser/WASM runtime.
16
+
17
+ ## Install
18
+
19
+ ```bash
20
+ pnpm add openrtc openrtc-tauri @tauri-apps/api
21
+ ```
22
+
23
+ In your Tauri Rust crate:
24
+
25
+ ```toml
26
+ [dependencies]
27
+ # Use the published crate after the native release path is cut.
28
+ # Until then, workspace consumers may use a path dependency.
29
+ openrtc-tauri-plugin = "0.1"
30
+ ```
31
+
32
+ ```rust
33
+ tauri::Builder::default()
34
+ .plugin(openrtc_tauri_plugin::init_from_env())
35
+ .run(tauri::generate_context!())?;
36
+ ```
37
+
38
+ ## Usage
39
+
40
+ ```ts
41
+ import { OpenRTC } from 'openrtc';
42
+
43
+ const client = OpenRTC.native({
44
+ apiKey: 'pk_live_...',
45
+ authMode: 'external',
46
+ });
47
+ ```
48
+
49
+ For browser-only or WebView-only prototypes, use `OpenRTC(...)`. For Tauri
50
+ desktop/mobile production apps, centralize platform selection in your app:
51
+
52
+ ```ts
53
+ const client = isTauriEnvironment()
54
+ ? OpenRTC.native(options)
55
+ : OpenRTC(options);
56
+ ```
57
+
58
+ For lower-level native runtime wiring:
59
+
60
+ ```ts
61
+ import { TauriRuntimeAdapter } from 'openrtc-tauri';
62
+ ```
63
+
64
+ If you are temporarily migrating an older host that still exposes bare Tauri
65
+ commands, make the exception explicit:
66
+
67
+ ```ts
68
+ new TauriRuntimeAdapter({
69
+ apiKey: 'pk_live_...',
70
+ authMode: 'external',
71
+ ipc: { fallbackToBareCommands: true },
72
+ });
73
+ ```
74
+
75
+ ## Rust Plugin
76
+
77
+ `openrtc-tauri-plugin` owns the native lifecycle surface for Tauri apps:
78
+
79
+ - `openrtc::client::Client` construction from API key, explicit app tag, or Space Mode key
80
+ - auth token relay via `openrtc_set_auth_token`
81
+ - native device identity, Iroh startup, endpoint tickets, presence, auto-connect,
82
+ connection state, device/session subscriptions, and peer streams
83
+
84
+ Product apps should install the plugin instead of copying `rtc_commands.rs` from
85
+ another application. App-specific commands can live beside it, but OpenRTC
86
+ connection lifecycle and device discovery should remain in the plugin/runtime.
87
+
88
+ The TypeScript package is publish-ready and depends on the public `openrtc` npm
89
+ package. The Rust plugin still depends on the OpenRTC Rust crate release path:
90
+ publish `openrtc` and `openrtc-tauri-plugin` crates together before documenting
91
+ native Tauri as fully standalone for external apps.
92
+
93
+ ## Tauri Permissions
94
+
95
+ Add the plugin default permission set to the app capability that owns your
96
+ OpenRTC WebView:
97
+
98
+ ```json
99
+ {
100
+ "permissions": ["openrtc-tauri-plugin:default"]
101
+ }
102
+ ```
103
+
104
+ Messages such as `desktop_set_pluto_auth_token not allowed` or
105
+ `list_rtc_connection_states not allowed. Plugin not found` mean the Rust plugin
106
+ is not registered under `openrtc-tauri-plugin` or the capability is missing the
107
+ default permission set. Auth relay commands are required for native managed
108
+ sessions that use scoped tokens; connection-state replay is optional telemetry
109
+ and OpenRTC will continue without it.
@@ -0,0 +1,2 @@
1
+ export { createTauriIpcBridge, type TauriIpcBridgeOptions } from './runtime/ipc';
2
+ export { TauriRuntimeAdapter, type TauriRuntimeAdapterOptions } from './runtime/TauriRuntimeAdapter';
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { createTauriIpcBridge } from './runtime/ipc';
2
+ export { TauriRuntimeAdapter } from './runtime/TauriRuntimeAdapter';
@@ -0,0 +1,9 @@
1
+ import { IpcRuntimeAdapter, type RuntimeClientOptions } from 'openrtc/runtime';
2
+ import { type TauriIpcBridgeOptions } from './ipc';
3
+ export interface TauriRuntimeAdapterOptions extends RuntimeClientOptions {
4
+ allowWasmFallback?: boolean;
5
+ ipc?: TauriIpcBridgeOptions;
6
+ }
7
+ export declare class TauriRuntimeAdapter extends IpcRuntimeAdapter {
8
+ constructor(options: TauriRuntimeAdapterOptions);
9
+ }
@@ -0,0 +1,11 @@
1
+ import { IpcRuntimeAdapter } from 'openrtc/runtime';
2
+ import { createTauriIpcBridge } from './ipc';
3
+ export class TauriRuntimeAdapter extends IpcRuntimeAdapter {
4
+ constructor(options) {
5
+ super({
6
+ ...options,
7
+ bridge: createTauriIpcBridge(options.ipc),
8
+ allowWasmFallback: options.allowWasmFallback ?? false,
9
+ });
10
+ }
11
+ }
@@ -0,0 +1,7 @@
1
+ import { type PlutoIpcBridge } from 'openrtc/runtime';
2
+ export interface TauriIpcBridgeOptions {
3
+ commandNamespace?: string | null;
4
+ fallbackCommandNamespaces?: string[];
5
+ fallbackToBareCommands?: boolean;
6
+ }
7
+ export declare function createTauriIpcBridge(options?: TauriIpcBridgeOptions): PlutoIpcBridge;
@@ -0,0 +1,60 @@
1
+ import { registerDesktopAuthRelay } from 'openrtc/auth/internal';
2
+ import { isNativeIpcCommandUnavailable } from 'openrtc/runtime';
3
+ const DEFAULT_COMMAND_NAMESPACE = 'plugin:openrtc-tauri-plugin|';
4
+ const LEGACY_COMMAND_NAMESPACE = 'plugin:openrtc|';
5
+ export function createTauriIpcBridge(options = {}) {
6
+ const commandNamespace = options.commandNamespace ?? DEFAULT_COMMAND_NAMESPACE;
7
+ const fallbackCommandNamespaces = options.fallbackCommandNamespaces ??
8
+ (commandNamespace === DEFAULT_COMMAND_NAMESPACE ? [LEGACY_COMMAND_NAMESPACE] : []);
9
+ // Bare command fallback is opt-in so missing plugin/capability wiring fails
10
+ // with the namespaced command that Tauri apps must actually install.
11
+ const fallbackToBareCommands = options.fallbackToBareCommands ?? false;
12
+ const resolveCommand = (namespace, command) => namespace && !command.startsWith('plugin:') ? `${namespace}${command}` : command;
13
+ return {
14
+ async invoke(command, args) {
15
+ const { invoke } = await import('@tauri-apps/api/core');
16
+ const nativeCommand = resolveCommand(commandNamespace, command);
17
+ try {
18
+ return await invoke(nativeCommand, args);
19
+ }
20
+ catch (error) {
21
+ if (isNativeIpcCommandUnavailable(error)) {
22
+ for (const namespace of fallbackCommandNamespaces) {
23
+ const fallbackCommand = resolveCommand(namespace, command);
24
+ if (fallbackCommand === nativeCommand || fallbackCommand === command) {
25
+ continue;
26
+ }
27
+ try {
28
+ return await invoke(fallbackCommand, args);
29
+ }
30
+ catch (fallbackError) {
31
+ if (!isNativeIpcCommandUnavailable(fallbackError)) {
32
+ throw fallbackError;
33
+ }
34
+ }
35
+ }
36
+ }
37
+ if (fallbackToBareCommands && nativeCommand !== command && isNativeIpcCommandUnavailable(error)) {
38
+ return invoke(command, args);
39
+ }
40
+ throw error;
41
+ }
42
+ },
43
+ async listen(event, handler) {
44
+ const { listen } = await import('@tauri-apps/api/event');
45
+ return listen(event, (tauriEvent) => {
46
+ handler(tauriEvent.payload);
47
+ });
48
+ },
49
+ async isAvailable() {
50
+ return typeof window !== 'undefined' && !!window.__TAURI_INTERNALS__;
51
+ },
52
+ };
53
+ }
54
+ registerDesktopAuthRelay(async (payload) => {
55
+ const bridge = createTauriIpcBridge();
56
+ await bridge.invoke('openrtc_set_auth_token', {
57
+ authToken: payload.authToken,
58
+ refreshToken: payload.refreshToken,
59
+ });
60
+ });
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "openrtc-tauri",
3
+ "version": "0.1.0",
4
+ "private": false,
5
+ "type": "module",
6
+ "sideEffects": false,
7
+ "description": "First-party Tauri adapter package for OpenRTC native runtimes.",
8
+ "license": "SEE LICENSE IN LICENSE",
9
+ "main": "dist/index.js",
10
+ "types": "dist/index.d.ts",
11
+ "files": [
12
+ "dist",
13
+ "LICENSE",
14
+ "README.md"
15
+ ],
16
+ "exports": {
17
+ ".": {
18
+ "types": "./dist/index.d.ts",
19
+ "import": "./dist/index.js"
20
+ }
21
+ },
22
+ "scripts": {
23
+ "build": "pnpm --dir ../openrtc run build && tsc",
24
+ "prepublishOnly": "pnpm run build"
25
+ },
26
+ "dependencies": {
27
+ "openrtc": "^0.2.1"
28
+ },
29
+ "peerDependencies": {
30
+ "@tauri-apps/api": "^2.0.0"
31
+ },
32
+ "devDependencies": {
33
+ "typescript": "^5.0.0"
34
+ }
35
+ }