openrtc 0.1.3 → 0.2.1

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 (41) hide show
  1. package/LICENSE +92 -0
  2. package/README.md +73 -9
  3. package/dist/DelegatingRuntimeAdapter-BxOcVIx_.d.ts +201 -0
  4. package/dist/{IpcRuntimeAdapter-CT-W0Mtp.d.ts → IpcRuntimeAdapter-U5AEH0jn.d.ts} +6 -2
  5. package/dist/auth/index.js +1 -1
  6. package/dist/auth/internal.js +1 -1
  7. package/dist/chunk-7DN33VUQ.js +1 -0
  8. package/dist/chunk-BLOEZIFJ.js +1 -0
  9. package/dist/chunk-FQETZQPW.js +2 -0
  10. package/dist/chunk-IUHUYHNZ.js +1 -0
  11. package/dist/chunk-UBEE42VU.js +2 -0
  12. package/dist/chunk-UPO23UMZ.js +3 -0
  13. package/dist/chunk-WNJE3MJF.js +1 -0
  14. package/dist/{factories-0TxDPMeu.d.ts → framing-lxzHEuSr.d.ts} +479 -226
  15. package/dist/index.d.ts +201 -7
  16. package/dist/index.js +2 -1
  17. package/dist/openrtc_bg.wasm +0 -0
  18. package/dist/runtime/WasmRuntimeAdapter.d.ts +2 -1
  19. package/dist/runtime/WasmRuntimeAdapter.js +1 -1
  20. package/dist/runtime/index.d.ts +213 -392
  21. package/dist/runtime/index.js +1 -1
  22. package/dist/runtime/tauri.d.ts +5 -6
  23. package/dist/runtime/tauri.js +1 -1
  24. package/dist/transport/index.d.ts +11 -0
  25. package/dist/transport/index.js +1 -0
  26. package/dist/{DelegatingRuntimeAdapter-CW8d78dZ.d.ts → types-D0fRvUbN.d.ts} +222 -171
  27. package/env/index.d.ts +64 -0
  28. package/env/index.mjs +230 -0
  29. package/package.json +29 -18
  30. package/dist/chunk-26POO5PL.js +0 -4
  31. package/dist/chunk-4MH42GUI.js +0 -2
  32. package/dist/chunk-D54VGRRH.js +0 -1
  33. package/dist/chunk-DIQYFAGL.js +0 -2
  34. package/dist/chunk-PZ25OCVG.js +0 -2
  35. package/dist/chunk-UVASANPG.js +0 -1
  36. package/wasm/README.md +0 -64
  37. package/wasm/openrtc.d.ts +0 -320
  38. package/wasm/openrtc.js +0 -2290
  39. package/wasm/openrtc_bg.wasm +0 -0
  40. package/wasm/openrtc_bg.wasm.d.ts +0 -113
  41. package/wasm/package.json +0 -16
package/env/index.d.ts ADDED
@@ -0,0 +1,64 @@
1
+ /** Type declarations for the `openrtc/env` subpath (see index.mjs). */
2
+
3
+ export interface EmulatorStack {
4
+ readonly projectId: string;
5
+ readonly functions: number;
6
+ readonly firestore: number;
7
+ readonly auth: number;
8
+ readonly ui: number;
9
+ readonly hub: number;
10
+ readonly logging: number;
11
+ readonly eventarc: number;
12
+ readonly tasks: number;
13
+ readonly database?: number;
14
+ }
15
+
16
+ export declare const EMULATOR_STACKS: {
17
+ readonly identity: EmulatorStack;
18
+ readonly signaling: EmulatorStack;
19
+ };
20
+
21
+ export declare const SEEDED_INTEGRATION_IDENTITY: {
22
+ readonly appTag: string;
23
+ readonly secretKey: string;
24
+ };
25
+
26
+ export type EmulatorStackName = 'signaling' | 'identity';
27
+
28
+ export declare function emulatorEnv(stack?: EmulatorStackName): Readonly<Record<string, string>>;
29
+
30
+ export declare function emulatorFunctionsUrls(): {
31
+ readonly signaling: string;
32
+ readonly identity: string;
33
+ };
34
+
35
+ export type OpenRtcEnvTier = 'local' | 'dev' | 'staging' | 'prod';
36
+
37
+ export interface ResolvedOpenRtcEnv {
38
+ readonly tier: OpenRtcEnvTier;
39
+ readonly emulated: boolean;
40
+ readonly env: Readonly<Record<string, string>>;
41
+ readonly functionsUrls: { readonly signaling: string; readonly identity: string };
42
+ readonly seededIdentity: { readonly appTag: string; readonly secretKey: string } | null;
43
+ }
44
+
45
+ export declare function resolveOpenRtcEnv(tier?: OpenRtcEnvTier): ResolvedOpenRtcEnv;
46
+
47
+ export declare function allEmulatorPorts(): readonly number[];
48
+
49
+ export interface SeedEmulatorOptions {
50
+ readonly reset?: boolean;
51
+ readonly seedScript?: string;
52
+ readonly nodePath?: string;
53
+ readonly cwd?: string;
54
+ readonly env?: Readonly<Record<string, string>>;
55
+ readonly stdio?: 'inherit' | 'ignore' | 'pipe';
56
+ }
57
+
58
+ export interface SeedEmulatorResult {
59
+ readonly appTag: string;
60
+ readonly firestoreHost: string;
61
+ readonly seedScript: string;
62
+ }
63
+
64
+ export declare function seedEmulator(options?: SeedEmulatorOptions): Promise<SeedEmulatorResult>;
package/env/index.mjs ADDED
@@ -0,0 +1,230 @@
1
+ /**
2
+ * OpenRTC environment/testing surface (`openrtc/env`).
3
+ *
4
+ * Canonical, dependency-free constants and helpers for wiring OpenRTC into an
5
+ * app's environment tiers. Hand-written ESM (no build step) so workspace
6
+ * scripts, boilerplates, and CI can import it directly with plain Node.
7
+ *
8
+ * Consumers: instead of copying emulator ports or the seeded integration
9
+ * identity into your own scripts, import them from here.
10
+ *
11
+ * Scope note: this subpath is a workspace/test helper for OpenRTC consumers.
12
+ * The `signaling` stack belongs to OpenRTC; the `identity` stack is the
13
+ * current workspace consumer identity stack used by Plutonium tests.
14
+ */
15
+
16
+ /**
17
+ * Firebase emulator port maps for the two OpenRTC-adjacent stacks.
18
+ * `identity` = the consumer app's own Firebase project (Plutonium:
19
+ * files-bb895); `signaling` = the OpenRTC signaling project (pluto-rtc-prod).
20
+ */
21
+ export const EMULATOR_STACKS = Object.freeze({
22
+ identity: Object.freeze({
23
+ projectId: 'files-bb895',
24
+ functions: 5001,
25
+ firestore: 8080,
26
+ auth: 9099,
27
+ ui: 4000,
28
+ hub: 4400,
29
+ logging: 4500,
30
+ eventarc: 9298,
31
+ tasks: 9498,
32
+ }),
33
+ signaling: Object.freeze({
34
+ projectId: 'pluto-rtc-prod',
35
+ functions: 5002,
36
+ firestore: 8082,
37
+ auth: 9100,
38
+ database: 9001,
39
+ ui: 4001,
40
+ hub: 4401,
41
+ logging: 4501,
42
+ eventarc: 9297,
43
+ tasks: 9499,
44
+ }),
45
+ });
46
+
47
+ const HOST = '127.0.0.1';
48
+
49
+ /** Seeded emulator app identity written by seed-integration-emulator.mjs. */
50
+ export const SEEDED_INTEGRATION_IDENTITY = Object.freeze({
51
+ appTag: 'app_integration_test',
52
+ secretKey: 'sk_test_integration_plutonium',
53
+ });
54
+
55
+ /** OpenRTC signaling-stack env vars in the exact shapes the SDK and crate read. */
56
+ function signalingEmulatorEnv() {
57
+ const s = EMULATOR_STACKS.signaling;
58
+ return Object.freeze({
59
+ OPENRTC_FIRESTORE_EMULATOR_HOST: `${HOST}:${s.firestore}`,
60
+ FIRESTORE_EMULATOR_HOST: `${HOST}:${s.firestore}`,
61
+ FIREBASE_AUTH_EMULATOR_HOST: `${HOST}:${s.auth}`,
62
+ FIREBASE_DATABASE_EMULATOR_HOST: `${HOST}:${s.database}`,
63
+ VITE_OPENRTC_FIRESTORE_EMULATOR_HOST: `${HOST}:${s.firestore}`,
64
+ VITE_OPENRTC_RTDB_EMULATOR_HOST: `${HOST}:${s.database}`,
65
+ VITE_USE_EMULATORS: 'true',
66
+ FUNCTIONS_EMULATOR: 'true',
67
+ });
68
+ }
69
+
70
+ /** Consumer identity-stack env vars (Plutonium uses files-bb895 locally). */
71
+ function identityEmulatorEnv() {
72
+ const i = EMULATOR_STACKS.identity;
73
+ return Object.freeze({
74
+ FIRESTORE_EMULATOR_HOST: `${HOST}:${i.firestore}`,
75
+ FIREBASE_AUTH_EMULATOR_HOST: `${HOST}:${i.auth}`,
76
+ FUNCTIONS_EMULATOR: 'true',
77
+ VITE_USE_EMULATORS: 'true',
78
+ });
79
+ }
80
+
81
+ /**
82
+ * Emulator hosts/URLs in the exact env-var shapes local processes read.
83
+ *
84
+ * Prefer `emulatorEnv('signaling')` for OpenRTC platform processes and
85
+ * `emulatorEnv('identity')` for consumer-app identity processes. The no-arg
86
+ * form is the historical mixed map: OpenRTC-prefixed vars point at signaling,
87
+ * while unprefixed Firestore/Functions vars point at identity.
88
+ */
89
+ export function emulatorEnv(stack) {
90
+ if (stack === 'signaling') return signalingEmulatorEnv();
91
+ if (stack === 'identity') return identityEmulatorEnv();
92
+ if (stack !== undefined) {
93
+ throw new Error(`Unknown emulator stack "${stack}" (expected signaling|identity).`);
94
+ }
95
+ const s = EMULATOR_STACKS.signaling;
96
+ const i = EMULATOR_STACKS.identity;
97
+ return Object.freeze({
98
+ // Read by the Rust crate (native signaling/auth/RTDB):
99
+ OPENRTC_FIRESTORE_EMULATOR_HOST: `${HOST}:${s.firestore}`,
100
+ FIREBASE_AUTH_EMULATOR_HOST: `${HOST}:${s.auth}`,
101
+ FIREBASE_DATABASE_EMULATOR_HOST: `${HOST}:${s.database}`,
102
+ // Read by the browser SDK (Vite-prefixed):
103
+ VITE_OPENRTC_FIRESTORE_EMULATOR_HOST: `${HOST}:${s.firestore}`,
104
+ VITE_OPENRTC_RTDB_EMULATOR_HOST: `${HOST}:${s.database}`,
105
+ VITE_USE_EMULATORS: 'true',
106
+ // Consumer-app identity stack (Plutonium naming):
107
+ FIRESTORE_EMULATOR_HOST: `${HOST}:${i.firestore}`,
108
+ FUNCTIONS_EMULATOR: 'true',
109
+ });
110
+ }
111
+
112
+ /** Emulator Functions base URLs per stack. */
113
+ export function emulatorFunctionsUrls() {
114
+ const s = EMULATOR_STACKS.signaling;
115
+ const i = EMULATOR_STACKS.identity;
116
+ return Object.freeze({
117
+ signaling: `http://${HOST}:${s.functions}/${s.projectId}/us-central1`,
118
+ identity: `http://${HOST}:${i.functions}/${i.projectId}/us-central1`,
119
+ });
120
+ }
121
+
122
+ /**
123
+ * Resolve the OpenRTC-relevant environment for a canonical workspace tier
124
+ * (`emulator` | `dev` | `staging` | `prod`). `local` is accepted as a
125
+ * compatibility alias for `emulator`. Dev and staging use the hosted
126
+ * non-production project family so real-device testing does not depend on
127
+ * same-machine emulators.
128
+ */
129
+ export function resolveOpenRtcEnv(tier = 'emulator') {
130
+ const resolvedTier = tier === 'local' ? 'emulator' : tier;
131
+ if (resolvedTier === 'emulator') {
132
+ return Object.freeze({
133
+ tier: resolvedTier,
134
+ emulated: true,
135
+ env: emulatorEnv(),
136
+ functionsUrls: emulatorFunctionsUrls(),
137
+ seededIdentity: SEEDED_INTEGRATION_IDENTITY,
138
+ });
139
+ }
140
+ if (resolvedTier === 'dev' || resolvedTier === 'staging') {
141
+ return Object.freeze({
142
+ tier: resolvedTier,
143
+ emulated: false,
144
+ env: Object.freeze({ VITE_USE_EMULATORS: 'false' }),
145
+ functionsUrls: Object.freeze({
146
+ signaling: 'https://us-central1-openrtc-platform-staging.cloudfunctions.net',
147
+ identity: 'https://us-central1-plutonium-app-staging.cloudfunctions.net',
148
+ }),
149
+ seededIdentity: null,
150
+ });
151
+ }
152
+ if (resolvedTier === 'prod') {
153
+ return Object.freeze({
154
+ tier: resolvedTier,
155
+ emulated: false,
156
+ env: Object.freeze({ VITE_USE_EMULATORS: 'false' }),
157
+ functionsUrls: Object.freeze({
158
+ signaling: 'https://us-central1-pluto-rtc-prod.cloudfunctions.net',
159
+ identity: 'https://us-central1-files-bb895.cloudfunctions.net',
160
+ }),
161
+ seededIdentity: null,
162
+ });
163
+ }
164
+ throw new Error(`Unknown OpenRTC environment tier "${tier}" (expected emulator|dev|staging|prod; local is an emulator alias).`);
165
+ }
166
+
167
+ /** All emulator ports across both stacks (cleanup/port-check helpers). */
168
+ export function allEmulatorPorts() {
169
+ const ports = new Set();
170
+ for (const stack of Object.values(EMULATOR_STACKS)) {
171
+ for (const value of Object.values(stack)) {
172
+ if (typeof value === 'number') ports.add(value);
173
+ }
174
+ }
175
+ return Object.freeze([...ports].sort((a, b) => a - b));
176
+ }
177
+
178
+ /**
179
+ * Seed the OpenRTC Firestore emulator with the canonical integration identity.
180
+ *
181
+ * Node-only helper. It delegates to OpenRTC's checked-in seed script, which
182
+ * refuses non-loopback Firestore hosts. Installed npm packages do not include
183
+ * the workspace seed script; in that case this throws with a routing hint.
184
+ */
185
+ export async function seedEmulator(options = {}) {
186
+ const [
187
+ { spawnSync },
188
+ { existsSync },
189
+ { dirname, join },
190
+ { fileURLToPath },
191
+ ] = await Promise.all([
192
+ import('node:child_process'),
193
+ import('node:fs'),
194
+ import('node:path'),
195
+ import('node:url'),
196
+ ]);
197
+ const envDir = dirname(fileURLToPath(import.meta.url));
198
+ const openRtcRoot = join(envDir, '..', '..', '..');
199
+ const seedScript = options.seedScript ?? join(openRtcRoot, 'tests', 'emulator', 'seed-integration-emulator.mjs');
200
+ if (!existsSync(seedScript)) {
201
+ throw new Error(
202
+ 'OpenRTC emulator seed script was not found. Run seedEmulator() from the workspace checkout, or invoke openrtc/tests/emulator/seed-integration-emulator.mjs directly.',
203
+ );
204
+ }
205
+ const local = resolveOpenRtcEnv('emulator');
206
+ const args = [seedScript, ...(options.reset ? ['--reset'] : [])];
207
+ // Pin the child to the SIGNALING stack explicitly. `local.env`'s flat map
208
+ // sets FIRESTORE_EMULATOR_HOST to the identity stack (for consumer-app
209
+ // functions), but the seed script targets FIRESTORE_EMULATOR_HOST directly —
210
+ // spreading the flat map unpinned would seed OpenRTC app docs into the wrong
211
+ // emulator.
212
+ const result = spawnSync(options.nodePath ?? process.execPath, args, {
213
+ cwd: options.cwd ?? openRtcRoot,
214
+ env: {
215
+ ...process.env,
216
+ ...local.env,
217
+ ...emulatorEnv('signaling'),
218
+ ...(options.env ?? {}),
219
+ },
220
+ stdio: options.stdio ?? 'inherit',
221
+ });
222
+ if (result.status !== 0) {
223
+ throw new Error(`OpenRTC emulator seed failed with exit code ${result.status ?? 'unknown'}`);
224
+ }
225
+ return Object.freeze({
226
+ appTag: SEEDED_INTEGRATION_IDENTITY.appTag,
227
+ firestoreHost: local.env.OPENRTC_FIRESTORE_EMULATOR_HOST,
228
+ seedScript,
229
+ });
230
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openrtc",
3
- "version": "0.1.3",
3
+ "version": "0.2.1",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -15,11 +15,11 @@
15
15
  "runtime"
16
16
  ],
17
17
  "author": "Bryant Hargreaves",
18
- "license": "MIT",
18
+ "license": "SEE LICENSE IN LICENSE",
19
19
  "homepage": "https://openrtc.app",
20
20
  "repository": {
21
21
  "type": "git",
22
- "url": "git+https://github.com/bluestarburst/Plutonium.git"
22
+ "url": "git+https://github.com/bluestarburst/openrtc.git"
23
23
  },
24
24
  "main": "dist/index.js",
25
25
  "types": "dist/index.d.ts",
@@ -27,13 +27,10 @@
27
27
  "dist/**/*.js",
28
28
  "dist/**/*.d.ts",
29
29
  "dist/**/*.wasm",
30
- "README.md",
31
- "wasm/openrtc.js",
32
- "wasm/openrtc.d.ts",
33
- "wasm/openrtc_bg.wasm",
34
- "wasm/openrtc_bg.wasm.d.ts",
35
- "wasm/package.json",
36
- "wasm/README.md"
30
+ "env/index.mjs",
31
+ "env/index.d.ts",
32
+ "LICENSE",
33
+ "README.md"
37
34
  ],
38
35
  "exports": {
39
36
  ".": {
@@ -56,26 +53,40 @@
56
53
  "types": "./dist/runtime/tauri.d.ts",
57
54
  "import": "./dist/runtime/tauri.js"
58
55
  },
56
+ "./transport": {
57
+ "types": "./dist/transport/index.d.ts",
58
+ "import": "./dist/transport/index.js"
59
+ },
59
60
  "./auth/internal": {
60
61
  "types": "./dist/auth/internal.d.ts",
61
62
  "import": "./dist/auth/internal.js"
62
63
  },
64
+ "./env": {
65
+ "types": "./env/index.d.ts",
66
+ "import": "./env/index.mjs"
67
+ },
63
68
  "./package.json": "./package.json"
64
69
  },
65
70
  "scripts": {
66
71
  "build": "tsup",
72
+ "build:clean": "rm -rf dist && pnpm run build",
67
73
  "build:types": "tsc --noEmit",
68
- "build:wasm": "cd ../../crates/openrtc && wasm-pack build --target web --out-dir ../../packages/openrtc/wasm && rm -rf ../../packages/openrtc/wasm/.gitignore",
69
- "test": "pnpm run test:deterministic",
70
- "test:deterministic": "OPENRTC_LIVE_TESTS=0 vitest run tests/unit tests/contract",
71
- "test:emulator": "OPENRTC_EMULATOR_TESTS=1 OPENRTC_LIVE_TESTS=1 FIREBASE_AUTH_EMULATOR_HOST=127.0.0.1:9100 VITE_USE_EMULATORS=true VITE_OPENRTC_FIRESTORE_EMULATOR_HOST=127.0.0.1:8082 VITE_OPENRTC_RTDB_EMULATOR_HOST=127.0.0.1:9001 vitest run tests/emulator",
72
- "test:live": "pnpm run build:wasm && pnpm run build && OPENRTC_LIVE_TESTS=1 vitest run tests/live",
73
- "test:live:emulator": "OPENRTC_LIVE_TESTS=1 FIREBASE_AUTH_EMULATOR_HOST=127.0.0.1:9099 vitest run tests/live",
74
+ "build:wasm": "cd ../../crates/openrtc && OPENRTC_REPO_ROOT=$(cd ../.. && pwd) && CARGO_REGISTRY_ROOT=${CARGO_HOME:-$HOME/.cargo} && RUSTUP_TOOLCHAIN=nightly RUSTFLAGS=\"-Zlocation-detail=none --remap-path-prefix=$HOME=/home --remap-path-prefix=$CARGO_REGISTRY_ROOT=/cargo --remap-path-prefix=$OPENRTC_REPO_ROOT=/openrtc\" wasm-pack build --target web --out-dir ../../packages/openrtc/wasm && rm -rf ../../packages/openrtc/wasm/.gitignore",
75
+ "test": "pnpm run test:deterministic && pnpm run test:emulator",
76
+ "test:deterministic": "OPENRTC_DETERMINISTIC_TESTS=1 vitest run tests/unit tests/contract",
77
+ "test:emulator": "node ../../tests/emulator/run-emulator-suite.mjs",
78
+ "test:emulator:running": "FIREBASE_AUTH_EMULATOR_HOST=127.0.0.1:9100 FIRESTORE_EMULATOR_HOST=127.0.0.1:8082 OPENRTC_FIRESTORE_HOST=127.0.0.1:8082 VITE_USE_EMULATORS=true VITE_OPENRTC_FIRESTORE_EMULATOR_HOST=127.0.0.1:8082 VITE_OPENRTC_RTDB_EMULATOR_HOST=127.0.0.1:9001 vitest run tests/emulator --no-file-parallelism --maxWorkers=1 --maxConcurrency=1",
79
+ "test:acceptance:native:running": "FIREBASE_AUTH_EMULATOR_HOST=127.0.0.1:9100 FIRESTORE_EMULATOR_HOST=127.0.0.1:8082 OPENRTC_FIRESTORE_HOST=127.0.0.1:8082 VITE_USE_EMULATORS=true VITE_OPENRTC_FIRESTORE_EMULATOR_HOST=127.0.0.1:8082 VITE_OPENRTC_RTDB_EMULATOR_HOST=127.0.0.1:9001 vitest run tests/emulator/RealOpenRtcAcceptance.native-wasm.emulator.test.ts --no-file-parallelism --maxWorkers=1 --maxConcurrency=1",
80
+ "test:live": "pnpm run build:wasm && pnpm run build && vitest run tests/live",
81
+ "test:live:emulator": "FIREBASE_AUTH_EMULATOR_HOST=127.0.0.1:9099 vitest run tests/live",
74
82
  "test:watch": "vitest",
75
83
  "coverage": "vitest run --coverage",
76
- "prepublishOnly": "npm run build:wasm && npm run build"
84
+ "prepublishOnly": "npm run build:wasm && npm run build:clean"
77
85
  },
78
86
  "dependencies": {
87
+ "@noble/ciphers": "^2.2.0",
88
+ "@noble/curves": "^1.9.0",
89
+ "@noble/hashes": "^1.8.0",
79
90
  "firebase": "^9.0.0 || ^10.0.0 || ^11.0.0 || ^12.0.0",
80
91
  "tweetnacl": "^1.0.3"
81
92
  },
@@ -96,6 +107,6 @@
96
107
  "test": "tests"
97
108
  },
98
109
  "bugs": {
99
- "url": "https://github.com/bluestarburst/Plutonium/issues"
110
+ "url": "https://github.com/bluestarburst/openrtc/issues"
100
111
  }
101
112
  }